Shop OBEX P1 Docs P2 Docs Learn Events
Low-Tech IR Remote — Parallax Forums

Low-Tech IR Remote

ercoerco Posts: 20,257
edited 2011-04-09 21:16 in General Discussion
I had to make my own IR remote for faster recognition than the venerable and well-documented Sony protocol. Specifically, I needed my BS2 to complete the whole read routine in 10 milliseconds, between sending servo pulses and reading sensors each 20 ms on my balancing robot. The Sony codes take ~8-15 ms each and repeat after a 20-30 ms pause, so those wouldn't work in my application. I just needed 4 commands for driving: forward, reverse, left & right.

As usual, I sought a quick & dirty but effective analog method. I modified my favorite LM556-based IR homing beacon circuit to send out 4 different user-selected frequencies on a 38 kHz carrier. The Stamp COUNTs the pulses in a 10 ms period. The numbers fluctuate a count every so often, so I spaced the frequencies apart enough to avoid any possible overlap.

Schematic & photo attached. Hope it may help someone somewhere somehow someday. BTW, you could also use these as beacons for robot navigation that your bot could tell one from the other.

Sample code:

' {$STAMP BS2}
' {$PBASIC 2.5}
'homemade IR for balance bot
'IR input on PIN 14
a:COUNT 14,10,B0
IF B0>=18 THEN DEBUG "reverse",CR:GOTO a
IF B0>=15 THEN DEBUG "left",CR:GOTO a
IF B0>=13 THEN DEBUG "forward",CR:GOTO a
IF B0>=10 THEN DEBUG "right",CR:GOTO a
IF B0=0 THEN DEBUG "stop",CR
GOTO a
630 x 600 - 68K
600 x 695 - 63K

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-04-09 08:22
    Very clever and well done, erco! I guess you could say that timer chips are to microcontrollers as wood is to plastic ... right? :)

    -Phil
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-09 08:46
    What if someone lights a match?
    (I jest.)
  • ercoerco Posts: 20,257
    edited 2011-04-09 14:50
    @PhiPi: High praise indeed! Whatever you do, don't tell Matt that my balancing robot is all plastic. My Hypocritic oath remains intact.

    @PJ: A match? Right now I'm only working on IR signals, but I suppose I'll get around to smoke signals eventually, thanks...
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-09 15:40
    stash  VAR  Byte
    
    A:
     COUNT 14, 10, stash
     IF (stash < 10) THEN GOTO S
     stash = stash - 10
     ON stash GOTO R,R,R,F,F,L,L,L,B,B,B,B
    '              1 1 1 1 1 1 1 1 1 1 2 2
    '              0 1 2 3 4 5 6 7 8 9 0 1
    
    S:
     DEBUG "Stop", CR
     GOTO A
    R:
     DEBUG "Right", CR
     GOTO A
    F:
     DEBUG "Forward", CR
     GOTO A
    L:
     DEBUG "Left", CR
     GOTO A
    B:
     DEBUG "Backward", CR
     GOTO A
    
    
  • Martin_HMartin_H Posts: 4,051
    edited 2011-04-09 16:28
    Very clever. Four values good, many values is better. So how many discrete values do you think you can encode and then uniquely decode with count?
  • ercoerco Posts: 20,257
    edited 2011-04-09 21:16
    @Martin_H: Probably 8 with my current analog setup, using resistors and a 556. More if you lengthen the COUNT interval or generate more accurate pulses digitally, using another micro on the transmitter end.

    I'm at the high end of the modulation frequency with that 556. Much higher and the IR modules stop detecting the 556's signal. I think it's the duty cycle causing the problem. It won't work at all without that 1N914 diode, which drops the duty cycle below 50% per http://electronicsclub.info/555timer.htm .

    @PJ: Nice codin', ToughGuy!
Sign In or Register to comment.