Upload
whitney-logan
View
217
Download
3
Embed Size (px)
Citation preview
EasyC Programming EasyC Programming Workshop Workshop
January 30, 2008Hauppauge High School
SPBLI - FIRST
Mark McLeodMark McLeodAdvisorAdvisor
Hauppauge Team 358Hauppauge Team 358Northrop Grumman Corp.Northrop Grumman [email protected]@ngc.com
AgendaAgenda
FIRST Control SystemFIRST Control System C BasicsC Basics EasyC EnvironmentEasyC Environment EasyC BasicsEasyC Basics
– Robot Driver ControlRobot Driver Control Demonstration of Basic OI Controls Demonstration of Basic OI Controls
– Robot Autonomous ControlRobot Autonomous Control Demonstration of Dead ReckoningDemonstration of Dead Reckoning
FIRST Control ElementsFIRST Control Elements
HardwareHardware– Robot Controller (RC)Robot Controller (RC)
User Processor vs. Master ProcessorUser Processor vs. Master Processor PWM, Relay, Digital I/O, Analog, Misc.PWM, Relay, Digital I/O, Analog, Misc.
– Operator Interface (OI)Operator Interface (OI)– Tether cable / Programming cableTether cable / Programming cable– LaptopLaptop
ProgrammingProgramming– C Language BasedC Language Based– Application Programmer Interface (API)Application Programmer Interface (API)– Dashboard (optional)Dashboard (optional)
Robot Controller Robot Controller ArchitectureArchitecture User ProcessorUser Processor
– What we download toWhat we download to– Runs our codeRuns our code– Reads the digital/analog I/O directlyReads the digital/analog I/O directly
Master ProcessorMaster Processor– Controls Disable/Autonomous/Driver modesControls Disable/Autonomous/Driver modes– Disables OI inputs & most RC outputsDisables OI inputs & most RC outputs– Must hear from User periodically or shuts it downMust hear from User periodically or shuts it down– Master Code Software is updated each yearMaster Code Software is updated each year
Robot Controller I/ORobot Controller I/O
Banner Sensor
Touch Sensor
Switch
Gyroscope
CameraLimit Switch
Analog Rangefinder
Encoder
Potentiometer
Pressure Sensor
Servo
Solenoid Compressor
Analog
Digital
Motors
Relays
TeamLEDs
TTL
Getting StartedGetting Started
TutorialsTutorials– Help -> TutorialsHelp -> Tutorials
Create/Open an EasyC ProjectCreate/Open an EasyC Project– New Competition TemplateNew Competition Template– Controller ConfigurationController Configuration
Drag & Drop EditingDrag & Drop Editing Build & DownloadBuild & Download
– Loader Setup to select serial/USB portLoader Setup to select serial/USB port– Online Window to test & check RC Online Window to test & check RC
config.config.
.hex file
Robot Controller
Operator Interface
Dashboard (optional)
MechanicsMechanics
Prog Button
Build & Download
ProjectProject
Controller ConfigurationController Configuration– Set Digital as input or outputSet Digital as input or output
Function BlocksFunction Blocks
Add VariablesAdd Variables Inputs – Digital & Analog I/OInputs – Digital & Analog I/O Outputs – PWM, RelayOutputs – PWM, Relay Program Flow – C statementsProgram Flow – C statements RC Control – Drive style (tank, arcade)RC Control – Drive style (tank, arcade) CameraCamera Control – Know status (disable, auto)Control – Know status (disable, auto) User Functions (Initialize, Auto, User Functions (Initialize, Auto,
Operator)Operator)
Simple Operator ModeSimple Operator Mode
While (1) { // From “Program Flow – While”
Tank4(1,2,2,2,1,3,2,4,0,1,0,1);
// From “RC Control – Tank – 4 motor”
}
More Complex More Complex Operator ModeOperator Modeunsigned char LeftJoystick; // Double click “Variables”
while (1) {
LeftJoystick = GetOIAInput(1,2); // From “RC Control”
if(LeftJoystick > 137 || LeftJoystick < 117) // From “Program Flow”
{
SetPWM(1, LeftJoystick); // From “Outputs”
}
else
{
SetPWM(1, 127);
}
}
Simple AutonomousSimple Autonomous
SetPWM(1,200); // From “Outputs”
SetPWM(2,55);
Wait(10000); // From “Program Flow” (10 secs in milliseconds)
SetPWM(1,127); //Be sure to stop the robot at the end
SetPWM(2,127);
Sample IR Sensor UseSample IR Sensor Use
While(1) { if (GetDigitalInput(1) == 1) {
SetOILED(1,1); //Turn 1st OI light onSetOILED(3,0); //Turn other OI lights offSetOILED(5,0);SetOILED(7,0);
SetPWM(1,200); //Drive the robotSetPWM(2,55);
} if (GetDigitalInput(2) == 1) {
SetOILED(1,0); //Turn other OI lights offSetOILED(3,1); //Turn 2nd OI light on
SetOILED(5,0); SetOILED(7,0);
SetPWM(1,127); //Stop the robotSetPWM(2,127);
}}
More InformationMore Information
Presentation slides at: Presentation slides at:
Team358.orgTeam358.org
Questions/Help please email us. Questions/Help please email us.
[email protected]@ngc.com