Presentation is loading. Please wait.

Presentation is loading. Please wait.

2008 KOP IR Sensor Workshop January 12, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.

Similar presentations


Presentation on theme: "2008 KOP IR Sensor Workshop January 12, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp."— Presentation transcript:

1 2008 KOP IR Sensor Workshop January 12, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp.

2 IR Board

3 Cautions Beware Hooking Power Up Backwards! Beware Hooking Power Up Backwards! –Safer to test with 9v battery first Beware Static Electricity! Beware Static Electricity! –Place on non-conductive surface (the bag it comes in is conductive) –Ground yourself while touching the board Compatible IR Remote Compatible IR Remote May need to test with several models of IR remotes to find a compatible frequency/protocol (universal remotes should work) A few H/W failures have been reported A few H/W failures have been reported –Failure to work at all –Partial operation –Broken while using

4 Training the IR Sensor Needed: Needed: –IR Remote, IR sensor board/cable, 9v battery, 2 alligator leads to connect the battery Learn: Learn: –Hold button down, add power, hold 2 secs, release LEDs LEDs –Error, cmd0, cmd1, cmd2, cmd3 s_and_Updates/2008_Assets/FIRSTIR%20- %20Instructions%20_ pdf

5 Wiring to Robot Controller 12v power & ground 12v power & ground –Go to breaker panel on robot--Recommend 9v battery to practice with (less chance of accidental damage) –+7-15v --Pins 1/2 –Ground --Pins ¾ –Possible to use fully charged 7.2v backup battery (4) RC Signal pins (4) RC Signal pins –Go to signal pins on Robot Controller –Cmd0 --Pin 8 –Cmd1 --Pin 6 –Cmd2 --Pin 5 –Cmd3 --Pin 7

6 Code Slow enough (.1 sec) to check from the slow loop (.026 sec)—active for 3 to 4 slow loops Slow enough (.1 sec) to check from the slow loop (.026 sec)—active for 3 to 4 slow loops Signals: Signals: –All 0’s if none are selected If using a separate 9v battery then they are all 1’s If using a separate 9v battery then they are all 1’s –All 1’s if nothing is connected or connection is loose –“1” if selected by IR remote, “0” if not selected –Save selection, don’t use signal pin directly—chance of half & half state and it will change while using it

7 Powering the IR Sensor Normally powered from a 12v breaker Normally powered from a 12v breaker Can be powered from the fully charged 7.2v backup battery Can be powered from the fully charged 7.2v backup battery If the voltage drops too low the IR sensor will stop operating If the voltage drops too low the IR sensor will stop operating Special Note when testing with a 9v battery: Special Note when testing with a 9v battery: –If 9v battery is used on a Robot Controller the input pins at rest will all register “1” (ground is not common) –If using the same 7.2v or 12v power as the Robot Controller the input pins at rest will register “0” (common ground) –So the code is slightly different for independent 9v battery testing

8 Coding Notes The IR sensor signal will start and last for 3 or 4 of our slow loops The IR sensor signal will start and last for 3 or 4 of our slow loops At the end of the signal there is a window where some pins can start to change & be in an intermediate state At the end of the signal there is a window where some pins can start to change & be in an intermediate state Capture the value of the pins all at once or when they first start to be received and you’ll avoid any half & half states Capture the value of the pins all at once or when they first start to be received and you’ll avoid any half & half states

9 Sample Code -- version 1 Checking individual pins char IR_cmd0=0, IR_cmd1=0, IR_cmd2=0, IR_cmd3=0; //declare as extern to use elsewhere // Can use a single “IR_cmd” variable to indicate the command received (1,2,3,4) // Can use a single “IR_cmd” variable to indicate the command received (1,2,3,4) void Process_Data_From_Local_IO(void) { static char latch=0; static char latch=0; if (latch == 1) if (latch == 1) { //**** Use this check when an independent 9v battery to power the IR Sensor //**** Use this check when an independent 9v battery to power the IR Sensor // if (rc_dig_in15 == 1 && rc_dig_in16 == 1 && rc_dig_in17 == 1 && rc_dig_in18 == 1) // **** Use this check when the Robot Controller 7.2v or 12v powers the IR Sensor // **** Use this check when the Robot Controller 7.2v or 12v powers the IR Sensor if (rc_dig_in15 == 0 && rc_dig_in16 == 0 && rc_dig_in17 == 0 && rc_dig_in18 == 0) // Normal common ground if (rc_dig_in15 == 0 && rc_dig_in16 == 0 && rc_dig_in17 == 0 && rc_dig_in18 == 0) // Normal common ground { latch = 0; // Avoid being caught by a half & half state of the IR sensor by taking the first change latch = 0; // Avoid being caught by a half & half state of the IR sensor by taking the first change } } else if (rc_dig_in15 == 0 || rc_dig_in16 == 0 || rc_dig_in17 == 0 || rc_dig_in18 == 0) else if (rc_dig_in15 == 0 || rc_dig_in16 == 0 || rc_dig_in17 == 0 || rc_dig_in18 == 0) { // Checking the pins individually like this can leave a window for the IR sensor to change in the middle { // Checking the pins individually like this can leave a window for the IR sensor to change in the middle // We avoid that problem by taking only the first change, but a better way would be to capture the pins all at once. // We avoid that problem by taking only the first change, but a better way would be to capture the pins all at once. //When the IR Sensor sends us a command it will stay steady for at least four or more times before the next change //When the IR Sensor sends us a command it will stay steady for at least four or more times before the next change IR_cmd0 = rc_dig_in15; IR_cmd0 = rc_dig_in15; IR_cmd1 = rc_dig_in17; IR_cmd1 = rc_dig_in17; IR_cmd2 = rc_dig_in18; IR_cmd2 = rc_dig_in18; IR_cmd3 = rc_dig_in16; IR_cmd3 = rc_dig_in16; latch = 1; latch = 1; }}

10 Sample Code Use – version 1 extern char IR_cmd0, IR_cmd1, IR_cmd2, IR_cmd3; void Default_Routine(void) { if (IR_cmd0 == 1) if (IR_cmd0 == 1) { pwm01 = 127; pwm01 = 127; pwm02 = 127; pwm02 = 127; } else if (IR_cmd1 == 1) else if (IR_cmd1 == 1) { pwm01 = 254; pwm01 = 254; pwm02 = 0; pwm02 = 0; } else if (IR_cmd2 == 1) else if (IR_cmd2 == 1) { pwm01 = 0; pwm01 = 0; pwm02 = 254; pwm02 = 254; } else if (IR_cmd3 == 1) else if (IR_cmd3 == 1) { pwm01 = 254; pwm01 = 254; pwm02 = 254; pwm02 = 254; }}

11 Sample Code – Better Version Grabbing all the pins at once Void Default_Routine(void) { static char latch=0; static char latch=0; unsigned char sensorReading; unsigned char sensorReading; //**** Check the IR Sensor for a new command //**** Check the IR Sensor for a new command sensorReading = PORTJ>>4; // Combined digital inputs sensorReading = PORTJ>>4; // Combined digital inputs if (latch == 1) if (latch == 1) { if (sensorReading == 0) if (sensorReading == 0) { latch = 0; // Take only the 1st reading to avoid latch = 0; // Take only the 1st reading to avoid // being caught by a half & half state of the IR sensor // being caught by a half & half state of the IR sensor } } else if (sensorReading != 0) else if (sensorReading != 0) { latch = 1; latch = 1; if (sensorReading == 8) IR_cmd = 1; if (sensorReading == 8) IR_cmd = 1; else if (sensorReading == 4) IR_cmd = 4; else if (sensorReading == 4) IR_cmd = 4; else if (sensorReading == 2) IR_cmd = 2; else if (sensorReading == 2) IR_cmd = 2; else if (sensorReading == 1) IR_cmd = 3; else if (sensorReading == 1) IR_cmd = 3;} switch(IR_cmd) switch(IR_cmd) case 1: case 1: pwm01 = 127; pwm01 = 127; pwm02 = 127; pwm02 = 127;break; case 2: case 2: pwm01 = 254; pwm01 = 254; pwm02 = 0; pwm02 = 0; break; break; case 3: case 3: pwm01 = 0; pwm01 = 0; pwm02 = 254; pwm02 = 254; break; break; case 4: case 4: pwm01 = 254; pwm01 = 254; pwm02 = 254; pwm02 = 254; }}

12 Potential Use Four Commands ONLY (but can be a different set each match) Basic Drive Control: Basic Drive Control: –forward, reverse, left, right –forward, left, right, raise arm to hit ball –Left, right, arm up, arm down Autonomous Assist: Autonomous Assist: –Trackball position-left / center / right –Trigger to hit ball –Stop current action and go to next pre-programmed act Driver Assist: Driver Assist: –Signals to help herd ball on far side of field, make turns, negotiate traffic jams

13 Issues Range of IR Remote (power) Range of IR Remote (power) Duplicate IR remotes/protocols/buttons Duplicate IR remotes/protocols/buttons Repeat or once only IR signal Repeat or once only IR signal –Repeat will case more interference –Once only may be hard to drive by IR Interference with partners and opponents IR Interference with partners and opponents –Coordinate w/ Alliance partners –May get through less frequently or not at all Sensor blocked from Robocoach at times Sensor blocked from Robocoach at times –Turn is 180 degrees –Center wall may reflect IR

14 Suggestions Make sensor directional, E.g., tube Make sensor directional, E.g., tube Closer / more power can override interference Closer / more power can override interference Plan for the IR commands to fail and still have your robot accomplish something during Hybrid, e.g., Plan for the IR commands to fail and still have your robot accomplish something during Hybrid, e.g., –Basic auto command to drive straight to get the first 4 points –Further action commanded by Robocoach at far end controlling the turn and backstretch Shield sensor from overhead ambient light Shield sensor from overhead ambient light Watch the FIRST Q&A for rulings that change things Watch the FIRST Q&A for rulings that change things

15 Alternatives Can modify the IR sensor to another frequency by replacing the sensor Can modify the IR sensor to another frequency by replacing the sensor Can use a different technology within the rules, e.g. no lasers, to send your four commands to the robot during Hybrid Mode Can use a different technology within the rules, e.g. no lasers, to send your four commands to the robot during Hybrid Mode –Visible light –Sound Replacement Replacement Equivalent TinyIR2 Equivalent TinyIR2 –http://www.tauntek.com/tinyir2-learning-ir- remote-control-receiver.htm remote-control-receiver.htmhttp://www.tauntek.com/tinyir2-learning-ir- remote-control-receiver.htm

16 Lap Counter Mounts on your flag holder-- The top of the holder must be 51” high Mounts on your flag holder-- The top of the holder must be 51” high 180 degree horizontal arc around the top of the flag holder must be kept clear within a 2-inch radius and be uncovered and visible from above. 180 degree horizontal arc around the top of the flag holder must be kept clear within a 2-inch radius and be uncovered and visible from above. The LAP INDICATOR is powered via a standard three-wire PWM cable. An easily accessible, powered, male PWM connector must be located at the top of the flag holder The LAP INDICATOR is powered via a standard three-wire PWM cable. An easily accessible, powered, male PWM connector must be located at the top of the flag holder Distributed for each match Distributed for each match Details at Details at


Download ppt "2008 KOP IR Sensor Workshop January 12, 2008 Hauppauge High School SPBLI - FIRST Mark McLeod Advisor Hauppauge Team 358 Northrop Grumman Corp."

Similar presentations


Ads by Google