Download
2008 kop ir sensor workshop n.
Skip this Video
Loading SlideShow in 5 Seconds..
2008 KOP IR Sensor Workshop PowerPoint Presentation
Download Presentation
2008 KOP IR Sensor Workshop

2008 KOP IR Sensor Workshop

74 Vues Download Presentation
Télécharger la présentation

2008 KOP IR Sensor Workshop

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
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. Mark.McLeod@ngc.com

  2. IR Board

  3. Cautions • Beware Hooking Power Up Backwards! • Safer to test with 9v battery first • Beware Static Electricity! • Place on non-conductive surface (the bag it comes in is conductive) • Ground yourself while touching the board • 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 • Failure to work at all • Partial operation • Broken while using

  4. Training the IR Sensor • Needed: • IR Remote, IR sensor board/cable, 9v battery, 2 alligator leads to connect the battery • Learn: • Hold button down, add power, hold 2 secs, release • LEDs • Error, cmd0, cmd1, cmd2, cmd3 http://www.usfirst.org/uploadedFiles/Community/FRC/FRC_Documents_and_Updates/2008_Assets/FIRSTIR%20-%20Instructions%20_121007.pdf

  5. Wiring to Robot Controller • 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 • 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 • Signals: • All 0’s if none are selected • 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 • Can be powered from the fully charged 7.2v backup battery • If the voltage drops too low the IR sensor will stop operating • 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 • 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

  9. Sample Code -- version 1Checking 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) void Process_Data_From_Local_IO(void) { static char latch=0; if (latch == 1) { //**** 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 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 } } 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 // 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 IR_cmd0 = rc_dig_in15; IR_cmd1 = rc_dig_in17; IR_cmd2 = rc_dig_in18; IR_cmd3 = rc_dig_in16; 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) { pwm01 = 127; pwm02 = 127; } else if (IR_cmd1 == 1) { pwm01 = 254; pwm02 = 0; } else if (IR_cmd2 == 1) { pwm01 = 0; pwm02 = 254; } else if (IR_cmd3 == 1) { pwm01 = 254; pwm02 = 254; } }

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

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

  13. Issues • Range of IR Remote (power) • Duplicate IR remotes/protocols/buttons • 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 • Coordinate w/ Alliance partners • May get through less frequently or not at all • Sensor blocked from Robocoach at times • Turn is 180 degrees • Center wall may reflect IR

  14. Suggestions • Make sensor directional, E.g., tube • Closer / more power can override interference • 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 • 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 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 www.vishay.com • Equivalent TinyIR2 • http://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 • 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 • Distributed for each match • Details at http://www.rclapcounter.com/