1 / 11

IR Control

IR Control. Materials taken from IR Remote for the Boe-Bot by Andy Lindsay. The Plan: Use a TV Remote to Control the Boe-Bot. IR Signal: 980 nm, 38.5 kHz. Sony TV Remote Control. Note Typo In last Week’s Notes. Basic Stamp Program to Guide the Boe-Bot Based on IR signals. PWM:

kitra
Download Presentation

IR Control

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IR Control Materials taken from IR Remote for the Boe-Bot by Andy Lindsay

  2. The Plan: Use a TV Remote to Control the Boe-Bot IR Signal: 980 nm, 38.5 kHz Sony TV Remote Control. Note Typo In last Week’s Notes Basic Stamp Program to Guide the Boe-Bot Based on IR signals PWM: Inverted, 0.6ms PW-off 1.2ms PW-on

  3. How It Works RCTIME is used because the IF…THEN statement does not finish until after the next data pulse has already begun. Since the start of the pulse (its negative edge) is missed while the IF…THEN statement is executing, PULSIN cannot properly detect the beginning of the pulse.

  4. Last Week’s Program: Decoding the IR Signal time VAR Word ' SONY TV remote variables. remoteCode VAR Byte DEBUG "Binary Val Decimal Val", CR, "Bit 76543210 ", CR, "------------ -------------" DO ' Beginning of main loop. remoteCode = 0 ' Clear all bits in remoteCode. DO ' Wait for rest between messages. RCTIME 9, 1, time LOOP UNTIL time > 1000 PULSIN 9, 0, time ' Measure pulse. IF time > 500 THEN remoteCode.BIT0 = 1 RCTIME 9, 0, time ' Measure next pulse. IF time > 300 THEN remoteCode.BIT1 = 1 RCTIME 9, 0, time ' etc. IF time > 300 THEN remoteCode.BIT2 = 1 RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT3 = 1 RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT4 = 1 RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT5 = 1 RCTIME 9, 0, time IF time > 300 THEN remoteCode.BIT6 = 1 DEBUG CRSRXY, 4, 3, BIN8 remoteCode, CRSRXY, 14, 3, DEC2 remoteCode LOOP

  5. Building an Application for Controlling the Boe-Bot New Features: • Constants – keypad values will be assigned meaningful names using the CONdirective. • Subroutines – break the program into chunks of code that can be separately executed; each chunks is called a subrountine. • SELECT…CASE statement – use the SELECT…CASEstatement to recognizes all the different remote keys.

  6. The CON Statement ' {$STAMP BS2} ' {$PBASIC 2.5} ' -----[ I/O Definitions ]------------------------------------------------- ' SONY TV IR remote declaration - input received from IR detector IrPin PIN 9 ' -----[ Constants ]------------------------------------------------------- ' SONY TV IR remote constants for non-keypad buttons Enter CON 11 ChUp CON 16 ChDn CON 17 VolUp CON 18 VolDn CON 19 Power CON 21 ' include VCR keys too ' -----[ Variables ]------------------------------------------------------- ' SONY TV IR remote variables irPulse VAR Word remoteCode VAR Byte

  7. The SELECT…CASEStatement Can be any expression Case labels are compared To the expression value DEBUG CLS, "Remote code: " SELECT remoteCode CASE 0 TO 9 DEBUG DEC remoteCode CASE Enter DEBUG "ENTER" CASE ChUp DEBUG "CH+" CASE ChDn DEBUG "CH-" CASE VolUp DEBUG "VOL+" CASE VolDn DEBUG "VOL-" CASE Power DEBUG "POWER" CASE ELSE DEBUG DEC remoteCode, " (unrecognized)" ENDSELECT DEBUG CLREOL Statement(s) executed when case label matches expression

  8. Subroutines DO GOSUB Get_Ir_Remote_Code DEBUG CLS, "Remote code: ", DEC remoteCode … LOOP Get_Ir_Remote_Code: remoteCode = 0 ' Clear all bits DO ' Rest between messages. RCTIME IrPin, 1, irPulse LOOP UNTIL irPulse > 1000 PULSIN IrPin, 0, irPulse ' Measure pulse. IF irPulse > 500 THEN remoteCode.BIT0 = 1 ' Set (or leave clear) bit-0. RCTIME IrPin, 0, irPulse ' Measure next pulse. IF irPulse > 300 THEN remoteCode.BIT1 = 1 ' Set (or leave clear) bit-1. RCTIME IrPin, 0, irPulse ' etc. IF irPulse > 300 THEN remoteCode.BIT2 = 1 RCTIME IrPin, 0, irPulse … IF irPulse > 300 THEN remoteCode.BIT6 = 1 RETURN

  9. Boe-Bot Control SELECT remoteCode CASE 2, ChUp ' Forward PULSOUT 13, 850 PULSOUT 12, 650 CASE 4, VolDn ' Rotate Left PULSOUT 13, 650 PULSOUT 12, 650 CASE 6, VolUp ' Rotate Right PULSOUT 13, 850 PULSOUT 12, 850 … CASE 7 ' Pivot Back-left PULSOUT 13, 750 PULSOUT 12, 850 CASE 9 ' Pivot Back-right PULSOUT 13, 650 PULSOUT 12, 750 CASE ELSE ' Hold Position PULSOUT 13, 750 PULSOUT 12, 750 ENDSELECT

  10. Putting It All Together ' -----[ I/O Definitions ]------------------------------------------------- IrPin PIN 9 ' -----[ Constants ]------------------------------------------------------- ChUp CON 16 ChDn CON 17 … ' -----[ Variables ]------------------------------------------------------- remoteCode VAR Byte … ' -----[ Main Routine ]---------------------------------------------------- DO GOSUB Get_Ir_Remote_Code DEBUG CLS, "Remote code: ", DEC remoteCode GOSUB Bot_Command LOOP ' -----[ Subroutines ]--------------------------------------------------------- Get_Ir_Remote_Code: remoteCode = 0 … RETURN Bot_Command: SELECT remoteCode … ENDSELECT RETURN

  11. Other IR Remote Applications • Applications Described in Chapter 3 of IR Remote for the Boe-Bot: • Remote speed control • Selecting among pre-programmed functions

More Related