Shop OBEX P1 Docs P2 Docs Learn Events
generating ir signals to control a tv — Parallax Forums

generating ir signals to control a tv

cayfordbcayfordb Posts: 22
edited 2009-04-23 19:50 in Accessories
Hi.

Anyone have experience sending IR signals from their BS2 to their TV?

I'm attempting to create a thing that gets TV Remote Control input signals, maps them, and outputs other IR codes accepted by the TV and related gear. Reason is too many remotes, and the fact that the all-in-one Harmony remote just isn't as nice as the Tivo remotes.

The thing will be a BS2sx with IR detector and IR transmitter, with extension wires to put the detector where it can "see" the remotes from where I sit on the couch, and the transmitter can blast into the rack of AV gear.

I got the Read part working, I'm proud to say, using a bs2sx and the IR detector. With help from the LIRC website (Linux Infrared Remote Control), and the examples in the Parallax study guides for IR remotes with the BoeBots, I was able to read the IR signals from nearly all the remotes I have now, and get things to the point where I'm ready to send out IR signals. Nice to see the debug window say "Got the Tivo TV-Input Button", and "Got the Onkyo DVD Button". It even reads the string of commands coming out of the Harmony Remote.

Now on to the IR output part: hoping to be able to tell the AV receiver to change inputs, to send dvd player commands mapped from the tivo remote control.

I'm assuming I'll use the FREQOUT command to light up the IR Led. The trouble is going to be controlling the pulse durations, and more difficulty, controlling the "space" duration. The Tivo, Onkyo, and Toshiba IR remotes use "space encoding" rather than "pulse encoding", meaning the data bitstream is encoded with constant width pulses buy variable length spaces between the pulses. Pulse width appears to be 600 usec, and space with is 600 usec for a zero, 1800 usec for a one.

The bs2sx has a time unit of 0.4 msec for the FREQOUT. I am hoping hoping hoping that 2 of those for 800 u-sec will be tolerated by the Tivos and AV gear. But the spaces???? I'm guessing I tune this by simply adding busy work inside the loop, something like this:


ir_out   PIN 6      ' plug it in here

OUTPUT ir_out

...

' send out 16 bits of IR pulses with each bit encoded in the space after the pulse

for i = 0 to 15
     FREQOUT ir_out, 2, 38000          ' one 800-usec pulse

     if (output_bits.lowbit(i) = 1) then
         x = 1      'stall for about 1500 to 1600 u-sec 
         x = 2      ' the loop setup and the IF statement probably eat up 200 to 300 usec
         x = 1      ' fine tune by adding/deleting lines
         x = 1      ' would use PAUSE 1 but the smallest time is 1 m-sec.  Maybe one of those and fewer x=1 lines
         x = 2
         x = 1
         x = 2
         x = 1
         x = 2
         x = 1
         x = 2
         x = 1
     else
          x = 1       ' stall for a shorter time, 600 u-sec.   
          x = 2
     endif

next




Does this stand a chance of working? I'm guessing I might need to unwind the loop and just repeat the code for each of the 32 bits to be sent out.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-30 18:17
    You can also use PULSOUT to an unsed pin to get fine control (0.8µS on a BS2sx) over your delay times.

    -Phil
  • cayfordbcayfordb Posts: 22
    edited 2009-03-30 20:19
    Thanks! Cool trick!

    How long does the PULSOUT instruction itself last? For that matter, is there any reference info on instruction duration, at the level of a Basic statement, a Token, or a machine instruction?

    I'm going on the simple statement of 10,000 instructions per second on the bs2sx, up at the top of the manual, but I know not all instructions take the same time.

    Any other tricks to control the duration of the FREQOUT command at a finer granularity? On the off chance that neither 400 nor 800 µsec is close enough to 600 µsec to make this work?

    Reread ing the pulsout and freqout sections in the manual I just noticed the frequency output is relative to the cpu chip., and it's 2.5Hz for the sx. That would be hard to figure out without reading that little bit of documentation.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-30 20:22
    Instruction overhead is just something you have to determine empirically. An oscilloscope will help with that.

    -Phil
  • stephenwagnerstephenwagner Posts: 147
    edited 2009-03-31 21:03
    Phil,

    Check out the customer application page. IR Repeater.

    http://www.parallax.com/tabid/321/Default.aspx

    I have some code that will support what you want to do. RCA 24 bit and NEC 32 bit.

    I was able to control a knock off Magnavox TV and RCA receiver.

    I just don't have it here at work.

    I will post it soon.

    Just like in the previous post. I have fine tuned PULSOUT to create the necessary delays.


    SJW
  • stephenwagnerstephenwagner Posts: 147
    edited 2009-04-02 13:10
    Stamp Source Code:
    ·
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    'RCA 24 bits. 8 bits highcode.lowbyte, 16 bits lowcode (Four (4) groups of six (6))
    'Magnavox TV 32 bits. 16bits highcode, 16 bits lowcode (Four (4) groups of eight (8))
    'RCA 24 bits. 6 bits custom/appliance code, 6 bits data, 6 bits NOT custom/appliance code, 6 bits NOT data.
    'Magnavox TV 32 bits. 8 bits custom/appliance code, 8 bits NOT custom/appliance code, 8 bits data, 8 bits NOT data.
    'PINS
    det PIN 1
    mod PIN 0
    delaypin PIN 4
    'variables
    pulse VAR Word
    idx VAR Nib
    codehigh VAR Word
    codelow VAR Word
    reps VAR Nib
    transmit VAR Bit
    delay VAR Word
    burst CON 52 'Note used right now
    adjust1 CON 562
    adjust2 CON 276
    'RCA Receiver V1 Code
    start:
    LOW mod
    codehigh = 0
    codelow = 0
    checking:
    IF det = 1 THEN checking
    PULSIN det, 1, pulse
    IF pulse < 1935 OR pulse > 2005 THEN checking 'check for 4000 uSec (3930)/2 = 1965 +/- 30 =
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT7 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT6 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT5 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT4 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT3 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT2 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT1 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codehigh.BIT0 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT15 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT14 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT13 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT12 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT11 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT10 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT9 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT8 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT7 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT6 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT5 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT4 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT3 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT2 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT1 = 1
    RCTIME det, 1, pulse
    IF pulse > 557 THEN codelow.BIT0 = 1
    transmit = 0
    SELECT· codelow
    CASE = 43221 'RCA Sat. Receiver on/off
    codehigh = 189 'Magnavox power code high
    codelow = 32895 'Magnavox power low
    reps = 1
    delay = 250
    transmit = 1
    CASE = 57553 'RCA TV -volume code
    codehigh = 189 'Magnavox -volume code high
    codelow = 2295 'Magnavox -volume code low
    reps = 15
    delay = 150
    Transmit = 1
    CASE = 61648 'RCA TV +volume code
    codehigh = 189 'Magnavox +volume code high
    codelow = 12495 ' Magnavox +volume code low
    reps = 5
    delay = 200
    Transmit = 1
    CASE = 61632 'RCA TV mute code
    codehigh = 189 'Magnavox mute code high
    codelow = 8415 'Magnavox mute code low
    reps = 1
    delay = 250
    transmit = 1
    ENDSELECT
    IF transmit = 0 THEN start
    PAUSE 1000
    FOR idx = 1 TO reps
    'Magnivox Transmitter code V2. 9000 uSec burst, 4500 uSec off followed by 32 data (564/566 uSec or 2690 uSec)· and 33 burst (560/572 uSec.)
    HIGH mod 'Turn on Transmitter
    PULSOUT delaypin, 4254 ' 9000 uSec burst. On for 9000 uSec
    PULSOUT mod, 2247 'Off for 4500 Usec
    'PULSOUT delaypin, 4254 ' 9000 uSec burst. On for 8990 uSec
    'PULSOUT mod, 2247 'Off for 4500 Usec
    'PULSOUT delaypin, 4254 ' 9000 uSec burst. On for 8990 uSec
    'PULSOUT mod, 2247 'Off for 4500 Usec
    'bit 15 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 282' bit 15 564/566 uSec or 1690 uSec
    'bit 14 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 13 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 282' 564 uSec
    'bit 12 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 11 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 282' 564 uSec
    'bit 10 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 9 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 282' 564 uSec
    'bit 8 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 7 = 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 6 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'Bit 5 = 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 4 = 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 3 = 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 2 = 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 1 = 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 282' 564 uSec
    'bit 0 = 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 15 (572 uSec and 552/554 uSec or 1678 uSec)
    'No instruction before .bit math yields 572 uSec. 12 uSec over. Therefor the below code must be 12 uSec under. total 1125 or 2250
    PULSOUT mod, codelow.BIT15 * adjust1 + adjust2
    'bit 14
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 13
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT13 * adjust1 + adjust2
    'bit 12
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT12 * adjust1 + adjust2
    'bit 11
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT11 * adjust1 + adjust2
    'bit 10
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 9
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 282' 564 uSec
    'bit 8
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 283' 566 uSec
    'bit 7
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT7 * adjust1 + adjust2
    'bit 6
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 5
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT5 * adjust1 + adjust2
    'bit 4
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT4 * adjust1 + adjust2
    'bit 3
    'No instruction befor .bit math yields 572 uSec.
    PULSOUT mod, codelow.BIT3 * adjust1 + adjust2
    'bit 2
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 1
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'bit 0
    PULSOUT delaypin, 52' to yield 560 uSec
    PULSOUT mod, 845' 1690 uSec
    'stop bit = 560 uSec
    PULSOUT delaypin, 99 '99 yields 560 uSec Last One
    LOW mod 'Turn transmitter off
    PAUSE delay
    NEXT
    GOTO start
  • cayfordbcayfordb Posts: 22
    edited 2009-04-06 20:25
    Hey, thanks! I see how you have turned on the emitter pin full time, and basically go back and forth between pulsing it at "zero" for the space, and pulsing on a dead pin for the actual pulse.

    Seems funny that the instruction time is so close to the pulse width times that we can't use a loop to step through the bits. I had to "unwind the loop" too, to be able to see the pulse and space widths.

    Question: on sending the IR bitstream output, you are using PULSOUT for both the pulse itself and the space between. How do you get 38k hz output on the IR transmitter? I though I would have to use FREQOUT instead of PULSOUT. The examples from the "Weekend Special Project on IR Leds" show using the Freqout command at 38k hz to send the IR signal. Yet, you are just using Pulsout. Much better resolution compared to FREQOUT. Are you using a regular IR led that Parallax sells?

    I see how you determined the cpu instruction time to adjust the pulse width for a zero or a one. You have a Bit*X+Y, with X about 1000 and Y about 600, giving 1600 or 600 depending on the bit. I was thinking using an array indexed by the bit, pulsetime(2) with values 600 and 1600, to get the same effect. Probably about the same cpu overhead.

    I think I better get a scope. How do you like the Velleman HPS10 for this kind of stuff?

    -- Cayford
  • cayfordbcayfordb Posts: 22
    edited 2009-04-06 20:37
    Duhhhh.... just looked at your schematic, and I see you have an oscillator at 38khz. Makes sense. Explains PULSOUT instead of FREQOUT.

    Did you need all 4 LED's just to get the power output level strong enough to reach the TV?
  • ZootZoot Posts: 2,227
    edited 2009-04-06 20:41
    See his writeup on the app page -- he is using an oscillator to modulate at 38.5khz. Not sure precisely what he used, but the IR write-ups from Parallax include a schematic for using a 555 timer and it's RST pin to drive the LED. Basically when you take the RST pin high (via a Stamp pin) you get a 38.5khz out to your LED. That is why he can PULSOUT for a very precise length of time -- he knows that the HIGH from the pulsout to the 555 timer (or similar) will get him a 38.5khz modulated output for just that length of time. It's a very simple circuit that uses a 555 8-pin timer and a few resistors and caps.

    This is a pretty common setup on the Stamp -- using a small peripheral chip to offload some of the work like PWM or IR generation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • cayfordbcayfordb Posts: 22
    edited 2009-04-06 21:36
    Hmmm.... finding a 38khz oscillator on google is not turning up quick easy answers. Maybe the 555 timer the place to start? Or get an Atmel Tiny 12? Steve Wagner, what did you use?
  • ZootZoot Posts: 2,227
    edited 2009-04-06 21:46
    Time to hit the books; do some homework. Wealth of info here:

    www.parallax.com/Portals/0/Downloads/docs/prod/sic/WebIR-%20v1.1.pdf

    Page 191 (as "printed" on the actual "pages") or page 201 (as "go to page..." in the PDF would be numbered) has a 555 circuit, some easily translated Basic code for pulsing the RST line to more accurately and quickly time IR transmission, etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • cayfordbcayfordb Posts: 22
    edited 2009-04-06 21:54
    Thanks. I'm on it.
  • cayfordbcayfordb Posts: 22
    edited 2009-04-06 23:35
    Too easy! Appendix C has the parts, the schematic, the explanation, everything. Parts add up to less than $4.00.
  • stephenwagnerstephenwagner Posts: 147
    edited 2009-04-07 12:02
    I purchased an IR oscillator from http://www.rentron.com/remote_control/TX-IR.htm·along with the 4MHz resonator. The 555 is to unstable to work over long distances. The 555 timer is fine for short distances and educational experiments.

    I did not need all four IR LEDs. With the stable TX-IR above, one (1) LED worked well over 30 ft. line of sight. However, since this project needed to work indirectly, I jammed as many LEDs as my power budget would allow. four (4) LED consumed my available power budget.

    I also purchase the IR LEDs from http://www.rentron.com/PicBasic/RemoteControl.htm·bottom right of link.

    To get the transmitter timing to work, I just used a second BS2 to measure the light on and light off times. You might get better results if you lengthen the light on time by one (1) 38KHz cycle and shorten the light off time by one (1) 38KHz cycle and keep the total time the same as specified in the protocols.

    Good luck. You are on the right track.

    I sure could use some help doing this with an SX.

    Stephen Wagner

    ·
  • ZootZoot Posts: 2,227
    edited 2009-04-07 12:37
    I don't see why the 555 should be unstable if the components (resistors & caps) are in tolerance and if the circuit is relatively noise free? 555 timers have been used for precise timing for decades. Seems odd somehow.

    In any case, Stephen, you may want to check out the SX SIRCS (Sony IR protocol) code that JonnyMac posted. It's got all the basic RX/TX material; you would just need to adjust your pulse times for ones/zeros and code in for the two remotes. Should get you started, though: http://forums.parallax.com/showthread.php?p=794429

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • stephenwagnerstephenwagner Posts: 147
    edited 2009-04-07 15:29
    Zoot,

    You are correct. The 555 is a great device.

    I studied the sensativity responce curves of the various IR receivers available and compared those to the 555 frequency drift over time measured, the sensativity of the IR receivers drop by about 60%.

    For this application, receiving IR off of walls, the ceramic resonator controlled oscillator seemed a wiser choice. The frequency of oscillation remained within 90% of the receivers sensativity curve.

    Should a location missalignment occure between the TV and the IR repaeter, further reducing the signal strength received, the systems still works. I am dealing with elder parrents and old world thoughts. They need a knob on their TV and a rotory phone.

    Thanks for the link to the SX SIRCS (Sony IR protocol) code that JonnyMac posted.



    SJW
  • cayfordbcayfordb Posts: 22
    edited 2009-04-07 17:53
    Stephen-- thanks for posting the parts. If I can't get the 555 timer to work (reliably) I'll switch over to your design.

    Zoot-- thanks for the link to the web_IR documentation. I scanned through that a few weeks ago when I was first starting out, but didn't comprehend any of it. Now I get it.

    I picked up the 555 and a few resistors last night at the Radio Shack. They had no clue what I was looking for, but I found it all. Right in the same drawer as the timer chip I saw a bunch of Parallax components. I knew I was in the right place.

    I got it wired up last night, with the design from Appendix C in the web_ir document. The Board of Education is chock full. Probably risking a short due to resistor wires touching.

    I'm guessing it will be tough to get the timing nailed down without an oscilloscope, so I sent off for a Velleman HPS10. Should be here in a week. WIth the BS2SX, I'm guessing I'll need the PULSOUT for each pulse and each space. In Stephens code, you don't need one of them because the CPU time ends up taking just the right amount of time.

    I found info on tons of remote controls at the LIRC www.lirc.org website. It lists the start pulse time, the wait, the pulse and space width for zero and one, the bit count, the repeated values, the the values for each button. Interesting that some remotes use the pulse width to show a zero or one while others use the width of the space between pulses. Anyway, I've got all the codes for the Tivos, my AV Receiver, and the blueray player that I don't even own yet. The "IR receive and decode" part of my project is done, as is the mapping to new codes, jumping between code slots on the BS2SX, and keeping track of the state of the devices. All that remains is the "IR Send" part.

    This is going to be very cool. Thanks again for the guidance and examples! I haven't had this much fun in years.
  • ZootZoot Posts: 2,227
    edited 2009-04-08 03:52
    stephenwagner -- actually I agree with you in the strictest sense, and in my own projects I only used a triggered 555 if the host is a Stamp or some other interpreted language micro that won't be able to do the modulation in the "background", e.g. an interrupt service routine, or hardware PWM or the like. Most of my IR ready work uses an SX with a resonator; a single IR modulated pin is enabled disabled on the cathode side of 1-n IR LEDs; any anode pin set high/low for a precise time gives me very cleanly timed pulses.

    That said, even w/a 555 I think that all that's needed is a bit of slop in the code --- almost all the IR protocols are very forgiving. For Sony, say, if a 0 is 600us and 1 is 1200us, you can have the host decide that a 1 is anything from 1100us to 1300us, etc. So even if your modulator is a 555, there is no reason not to use any arbitrary or particular standard and have it both be read and duplicated relatively error free. Given that many remotes also send "repeating" messages, you can do tricks like read the incoming byte/word 3x -- if you have 3 matches in a row, it's probably a valid message.
    cayfordb said...
    I'm guessing it will be tough to get the timing nailed down without an oscilloscope, so I sent off for a Velleman HPS10. Should be here in a week. WIth the BS2SX, I'm guessing I'll need the PULSOUT for each pulse and each space. In Stephens code, you don't need one of them because the CPU time ends up taking just the right amount of time.

    No, it's easy. USE YOUR STAMP. Set up the 555 circuit and hook the output THROUGH A 220 OHM RESISTOR to a Stamp pin configured as an INPUT (i.e., instead of hooking up the output of the 555 circuit to an LED and/or transistor, run through a resistor to your Stamp). Then use COUNT to read the incoming pulses for some reasonabe length of time (see the Stamp Pbasic Manual for details and units for different flavors of Stamps). Read the output of the 555 five or ten times. Average the results, divide or multiply by your time base (the length of the COUNT sample -- i.e. if you sample for 250ms, you would multiply by 4 to get the Hz) and send it to the DEBUG window. Set the pot on the 555 circuit until you get the modulation frequency you want. 38.5khz (38,500 times per second) is a good default, but some detectors may have a different "sweet spot", usually available in the data sheet.

    I thought this trick was mentioned in the IR write-up from Parallax? But it's been a long day and I'm not sure I have the moxie to re-read it right now smile.gif But the Stamp itself can always be programmed to be a fairly useful, "one-off" frequency counter, pulse counter and/or logic analyzer if nothing else is available.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • cayfordbcayfordb Posts: 22
    edited 2009-04-08 18:29
    Zoot said...
    I thought this trick was mentioned in the IR write-up from Parallax? But it's been a long day and I'm not sure I have the moxie to re-read it right now But the Stamp itself can always be programmed to be a fairly useful, "one-off" frequency counter, pulse counter and/or logic analyzer if nothing else is available.

    Yep, and I wired it up that way. That's for tuning the IR Output Led to be at 38khz. But I was thinking that in order to get the duration of the variable width spaces, I'd need to "see" the output waveform, and dial in the right amount of delay by varying the time for the PULSOUT command on the "dead" pin. I guess getting a second Stamp would work too. Well too late, the Velleman is in the air.

    As of this morning, though, I have some badness in my setup, because the tuning program is showing 0 Hz, no matter how I twist the pot. It looked perfect, but I've got a wiring problem in there somewhere. Back at it after work tonight.

    The circuit with the Rentron chip and the 4mhz resonator looks a lot simpler to wire up, and much less birdsnest wiring on the breadboard. And no pot to tune!
  • cayfordbcayfordb Posts: 22
    edited 2009-04-11 06:00
    Dang, I think I fried the IR led. Got things looking like they were working, but seems that no IR light was being emitted. The Digital Camera test shows nothing lighting up. I swapped the IR Led with a regular Green Led, and tried the Digital Camera test again. Nuthin. No light coming out of the IR. Plenty coming out of the Green one. Putting the oscilloscope on it, I see that signal is getting to it. (Yes, I have the short leg going to ground and the long leg getting the signal). Guess I gotta go find a replacement.
  • cayfordbcayfordb Posts: 22
    edited 2009-04-12 01:27
    Ok, got a new IR Led, and the Camera Test indicates it is indeed flashing. Yay. I'm not making it through to the TV yet, but Im sure that's due to usec timing on the pulse widths, and I need to get the scope to see in close enough to tune/tweak the PULSOUT times.

    BUT, here's a bit of oddness I would love to understand:

    I wired up the circuit exactly as in Appendex C of the Web_IR PDF. When I run the "tuner" program to dial in the 38KHZ, when the IR Led is in the circuit I get 0Hz. If I pull it out, I'm getting the expected 38k, plus or minus a few cycles. Put it in, and the Hz count goes to zero. Is this because with the LED in the circuit there isn't enough "juice" to drive it AND the input pin back to the BS2? If so, the moment I fried the old one is probably the exact moment that the tuner circuit started showing numbers. Initially it was at zero.

    Also, trying to do the math to see if I have the right resistance going into the new IR Led. The package says this has 1.2V forward voltage, and 100mA. Anyone know the voltage and current levels for the IR LED that Parallax sells? With 5v coming off the 555 timer, and 1.2v wanted by the LED, I need to have the resistor consume 3.8v at 0.1 Amp, so that would be a 38 ohm resistor. Hmmmm, the design in Appendix C calls for a 220 ohm resistor. I'm guessing the LED from the Parallax site has different voltage and current values, and that I'll need a lower resistor to drive this one. Yet I am getting IR light out of it, according to the camera.

    Thanks in advance for any help, including pointers to where I should read up on this. I've already learned a lot just googling for things like "led forward voltage".

    -- Cayford
  • ZootZoot Posts: 2,227
    edited 2009-04-12 02:53
    Measure without the LED in place. The LED may be drawing enough current that the Stamp pin can't see the "high" for the count.

    The 220 resistor is common because it won't allow more current than Stamp pin can handle. Since you are not driving the LED directly from a Stamp pin, you can use lower values -- this will just make the IR LED "brighter", and able to send it's signal further. You may want to experiment with values that give you the best range.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • cayfordbcayfordb Posts: 22
    edited 2009-04-12 15:41
    Ok! Thanks, that makes sense. Could be that the IR leds have a lot less resistance than the regular ones. 12 ohms compared to 50 ohms, if I read the charts right.

    I think I know how I fried the led--- the path from the input pin (pin 7) to the IR Led has no resistor inline. The resistor is between the 555 output and the junction of the pin7 and the Led. Pin 7 is by default an input pin. If somehow I accidentally had a line of code that said "high 7" , scorch goes the led!
  • cayfordbcayfordb Posts: 22
    edited 2009-04-18 17:11
    I am happy to report SUCCESS!!!! My remote translator is working! The BasicStamp is able to control 3 Tivos and 1 Onkyo AV Receiver, all from a single Tivo remote control. It keeps track of what Tivo is selected, tells the Onkyo which input to use, cycles through the inputs on the Onkyo with the Input button on the Tivo remote, and maps Tivo remote buttons to the command set for the currently selected Tivo. Nifty-keen-eroo!

    A little more tweaking to go, to dial in the right amount of pause between commands, and to put the IR LED on a long wire so it can dangle in front of the equipment in the right place. And maybe boost the IR output with a second IR Led.

    I found that the Pin-7 wire from the diagram in Web_IR1.1.pdf App C has to be unplugged in order to send any IR light out of the LED. With the pin plugged in, I get no IR output. Similarly, I can't "tune" the timer with the IR Led plugged in. Must have it pulled out. I wonder if this is due to the Radio Shack IR Led having different resistance and current values than the standard Parallax IR Led? If not, I'd suggest a sentence or two to this effect be put into the document.

    This website was really helpful, explaining more details about various IR Protocols: www.sbprojects.com/knowledge/ir/ir.htm Seems that the Tivo and the Onkyo use the NEC protocol, and the Blueray player I'm getting (soon) also uses that. Oddly, they each have a different setting for the "gap time", but the same basic structure. So it should be simple to add this device to the BasicStamp. I've done so already, but until the player arrives, I don't know for sure.

    All for now.
  • cayfordbcayfordb Posts: 22
    edited 2009-04-20 00:50
    Here are a few pictures. The Development Lab (also known as the Dining Room table), the BS2-SX professionally installed behind the TV, and the view from the front.


    basicstamp_remote4.jpg

    Ugly from the back:

    basicstamp_remote5.jpg

    But looks fairly decent from the front:

    basicstamp_remote6.jpg

    I really don't know how that guy in the picture knew I was doing this. Really.

    -- Cayford
  • cayfordbcayfordb Posts: 22
    edited 2009-04-20 00:57
    One more thing, on Timing:

    With the oscilloscope, I was able to determine the time for various lines of code in Basic 2.5.

    I found that the statement

    pulsout 6, timearray(command.bit3) was 150 microseconds faster than the command

    pulsout 6, 400 + command.bit3 * 1000

    This is used in the part where you send out pulses and pauses between pulses.

    The cpu time is dangerously close to the time for each pulse, so saving 150 microsecs is a nice thing. It might be an even bigger difference on a Basicstamp 2, which is lot slower than the BS2SX.
  • stephenwagnerstephenwagner Posts: 147
    edited 2009-04-22 12:20
    Cayfordb,

    Congradulations on your project. I also found the sbprojects sight to be helpful. I did break down and eventully purchase IR emitter bugs from parts express. This eliminated the necessary 1 sec delay in my posted code.

    SJW
  • cayfordbcayfordb Posts: 22
    edited 2009-04-22 20:09
    I see a bunch of ir emitters, from xantech and audioplex etc. Do these work the same as the IR Led? The only specs I can find on these relate to a controller box. Sure would be nice if I could plug one if these where the LED plugs in now. Or two or three of them, for that matter....
  • ZootZoot Posts: 2,227
    edited 2009-04-22 20:23
    You want to check the frequency of IR it emits (this is not the same as the modulation of on/off on the emitter, rather the actual frequency of the lightwave emitted). Generally it's in nm -- nanometers, the distance between peaks of the light carrier. Remote control IR is generally in the 940nm range, so if the emitter is around there, and the detector is sensitive in that range, you're good, and the decision would be based on brightness, package, power, price, etc. Your remote control detectors have additional circuitry and characteristics that make the part output a low when a 940nm light wave is detected AND that light wave is being turned on/off about 38,500 times per second (though some detectors have "sweet" spots that may be slightly higher or lower in modulation frequency -- generally the datasheet will show a response curve through a range around the sweet spot).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • cayfordbcayfordb Posts: 22
    edited 2009-04-23 19:50
    I heard back from audioplex. Indeed, the irBug is simply an IR Led in a nice package with a long wire. Some with a 1/8' miniplug. Very nice. I'll get a couple.

    I thought I was done with this project. Now that the family is using it, I see I'm getting only 80% success on the Onkyo Reciever. I get 100% on the Tivo boxes. Bummer about the Onkyo. The irBug idea may help.
Sign In or Register to comment.