Using Stamp as IR Remote Control Transmitter
Ron Czapala
Posts: 2,418
The examples of using a universal remote to send SONY IR codes to basic stamp work well, but I would like to transmit SONY IR codes from a basic stamp.
According to page 2 of the documentation for the IR Remote Parts Kit:
http://www.parallax.com/Portals/0/Downloads/docs/prod/compshop/IRremoteAppKit.pdf
there needs to be a .6ms resting state between data pulses.· I am trying to figure out how to take a pin high for .6 ms.
Here is some of the code I was trying to work out...
#SELECT $stamp
· #CASE BS2, BS2E, BS2PE···················· ' PULSE durations
··· ZeroPulse····· CON 300·················· ' .6 us
··· OnePulse······ CON 600·················· ' 1.2 us
··· StartPulse···· CON 1200················· ' 2.4 us
· #CASE BS2P, BS2SX
··· ZeroPulse····· CON 750·················· ' .6 us
··· OnePulse······ CON 1500················· ' 1.2 us
··· StartPulse···· CON 3000················· ' 2.4 us
· #CASE #ELSE
··· #ERROR This BASIC Stamp NOT supported.
#ENDSELECT
···· IrTX········· PIN···· 5
···· remoteCode···· VAR···· Byte················· ' Stores remote code
···· sendbit······· VAR···· Bit
···· mask·········· VAR···· Byte················· ' mask individual bytes
···· OUTPUT IrTX
····· HIGH IrTx
····· PULSOUT IrTX, StartPulse
····· FOR i = 0 TO 6 '7
······· ??need a .6ms PAUSE??···· ' .6 resting state HIGH
······· mask = 1 << i
······· sendbit = (mask & remotecode) >> i
······· IF sendbit· = 0 THEN
········· PULSOUT IrTX, ZeroPulse
······· ELSE
········· PULSOUT IrTX, OnePulse
······· END IF
····· NEXT
According to page 2 of the documentation for the IR Remote Parts Kit:
http://www.parallax.com/Portals/0/Downloads/docs/prod/compshop/IRremoteAppKit.pdf
there needs to be a .6ms resting state between data pulses.· I am trying to figure out how to take a pin high for .6 ms.
Here is some of the code I was trying to work out...
#SELECT $stamp
· #CASE BS2, BS2E, BS2PE···················· ' PULSE durations
··· ZeroPulse····· CON 300·················· ' .6 us
··· OnePulse······ CON 600·················· ' 1.2 us
··· StartPulse···· CON 1200················· ' 2.4 us
· #CASE BS2P, BS2SX
··· ZeroPulse····· CON 750·················· ' .6 us
··· OnePulse······ CON 1500················· ' 1.2 us
··· StartPulse···· CON 3000················· ' 2.4 us
· #CASE #ELSE
··· #ERROR This BASIC Stamp NOT supported.
#ENDSELECT
···· IrTX········· PIN···· 5
···· remoteCode···· VAR···· Byte················· ' Stores remote code
···· sendbit······· VAR···· Bit
···· mask·········· VAR···· Byte················· ' mask individual bytes
···· OUTPUT IrTX
····· HIGH IrTx
····· PULSOUT IrTX, StartPulse
····· FOR i = 0 TO 6 '7
······· ??need a .6ms PAUSE??···· ' .6 resting state HIGH
······· mask = 1 << i
······· sendbit = (mask & remotecode) >> i
······· IF sendbit· = 0 THEN
········· PULSOUT IrTX, ZeroPulse
······· ELSE
········· PULSOUT IrTX, OnePulse
······· END IF
····· NEXT
Comments
Since the other statements take a little time to execute, you may need to make the pulse width counts slightly smaller.
www.emesystems.com has some articles discussing the timing of various Stamp statements. You might browse the site.
Actually, I did read Tracy's timing appnotes section after seeing your suggestion to others in similar questions.
I was trying to figure out the best approach but doing a Pulsout on an extra pin does hold promise.
I·do need·to·minimize the time needed to retrieve and execute the Pbasic·statements in the send routine.
I know I could probably find some external ICs to encode the remote codes and drive the IR LED.
Thanks for your help!
Post Edited (ronczap) : 6/9/2009 10:46:16 AM GMT