Infrared LED communications using SERIN and SEROUT ... please help
KJohnson
Posts: 4
am currently working on a project that involves an IR LED (QED123) and IR RECEIVER(QSD123). According to my instructions this IR emitter will be "transmitting a standard 2400 baud, 8-N-1 UART bitstream." I have read on the Parallax site in the downloads section under Miscellaneous, "Infrared Emitting Diode & 40 kHz Infrared" (http://www.parallax.com/dl/docs/prod/audiovis/InfraredEmittingDiode.pdf) as well as have read "IR Remote with the Boe-Bot".
From the rules: (Get the code)
The ball request zone will consist of an infrared LED (Part #QED123, available at Digikey and elsewhere) transmitting a standard 2400 baud, 8-N-1 UART bitstream. The LED “on” current is set to 100mA. The data transmitted will be ASCII characters representing a three digit decimal number, enclosed by the delimiter “IEEE” before and after. This means the total transmission length is 11 bytes. As an example, if the code is 123, the transmitted sequence would be:
I-E-E-E-1-2-3-I-E-E-E, or in byte values:
0x49 0x45 0x45 0x45 0x31 0x32 0x33 0x49 0x45 0x45 0x45
A logic ‘1’ (high voltage) will cause the LED to be ON. A logic zero means the LED will be OFF. This means that the idle state (when no data is being transmitted) for the LED is ON.
Is there any other information you could give me about how to send and receive a string of characters between an IR emitter and detector on separate Basic stamps (BS2) using a 2400 baud, 8N1 UART bitstream?
Here's an example: suppose I want to send an 11 byte message IEEE123IEEE. Where 123 may be any 3 number combo, I need to capture this number using the IR rec unit. I want to also setup 2 Stamps - 1 transmits the message IEEE123IEEE and 2 will receive it.
Here's my transmission code: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
SEROUT 11, 396, 3000, [noparse][[/noparse]49,45,45,45,31,32,33,49,45,45,45]
' notes on use of SEROUT:
' 15 = pin to send data pulses out
' 396 = baudmode number for a 8N1 true 2400 baud signal transmission,
' use 16780 FOR 8n1 inverted
' [noparse][[/noparse]49, 45, ... = send out a byte equal to 49,45,... sequentially
' which as the ASCII codes for IEEE123IEEE
LOOP
```````````````````````````````````````````````````````````````````end of code
Here's my receiving code:
' {$STAMP BS2}
' {$PBASIC 2.5}
number VAR Byte 'the incoming seriel number
dig1 VAR Nib 'first digit of number
dig2 VAR Nib 'second digit of number
dig3 VAR Nib 'third digit of number
'============== MAIN ============================
Main:
INPUT 10 'define pin 10 to be an input pin
DEBUG "Seeking code . . . . "
SERIN 10, 396, [noparse][[/noparse]WAIT("IEEE"), DEC number]
'
dig1 = (number /100) ' / is integer division
dig2 = (number /10) //10 ' // is modulo
dig3 = number //10
'
DEBUG CR, CR, HOME 'here I am debug to screen, later the numbers will be displayed on a 7segment display
DEBUG ?dig1, CR ' Show contents of each cell
DEBUG ?dig2, CR
DEBUG ?dig3
END
'==================== END =======================
SO here are my initial questions:
1) Do I need to set up an individual circuit including a 555 timer for the sending side?
2) How can I use the basic stamp commands such as SEROUT and SERIN to control the emitter and receiver?
3) My programs don't seem to work, what am I doing wrong?
4) Is using FREQOUT and PULSIN more reliable to get the job done?
5) Do you know any specifics about programming for the 8n1 UART protocol?
Thank you for your time ... Kenny
From the rules: (Get the code)
The ball request zone will consist of an infrared LED (Part #QED123, available at Digikey and elsewhere) transmitting a standard 2400 baud, 8-N-1 UART bitstream. The LED “on” current is set to 100mA. The data transmitted will be ASCII characters representing a three digit decimal number, enclosed by the delimiter “IEEE” before and after. This means the total transmission length is 11 bytes. As an example, if the code is 123, the transmitted sequence would be:
I-E-E-E-1-2-3-I-E-E-E, or in byte values:
0x49 0x45 0x45 0x45 0x31 0x32 0x33 0x49 0x45 0x45 0x45
A logic ‘1’ (high voltage) will cause the LED to be ON. A logic zero means the LED will be OFF. This means that the idle state (when no data is being transmitted) for the LED is ON.
Is there any other information you could give me about how to send and receive a string of characters between an IR emitter and detector on separate Basic stamps (BS2) using a 2400 baud, 8N1 UART bitstream?
Here's an example: suppose I want to send an 11 byte message IEEE123IEEE. Where 123 may be any 3 number combo, I need to capture this number using the IR rec unit. I want to also setup 2 Stamps - 1 transmits the message IEEE123IEEE and 2 will receive it.
Here's my transmission code: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
SEROUT 11, 396, 3000, [noparse][[/noparse]49,45,45,45,31,32,33,49,45,45,45]
' notes on use of SEROUT:
' 15 = pin to send data pulses out
' 396 = baudmode number for a 8N1 true 2400 baud signal transmission,
' use 16780 FOR 8n1 inverted
' [noparse][[/noparse]49, 45, ... = send out a byte equal to 49,45,... sequentially
' which as the ASCII codes for IEEE123IEEE
LOOP
```````````````````````````````````````````````````````````````````end of code
Here's my receiving code:
' {$STAMP BS2}
' {$PBASIC 2.5}
number VAR Byte 'the incoming seriel number
dig1 VAR Nib 'first digit of number
dig2 VAR Nib 'second digit of number
dig3 VAR Nib 'third digit of number
'============== MAIN ============================
Main:
INPUT 10 'define pin 10 to be an input pin
DEBUG "Seeking code . . . . "
SERIN 10, 396, [noparse][[/noparse]WAIT("IEEE"), DEC number]
'
dig1 = (number /100) ' / is integer division
dig2 = (number /10) //10 ' // is modulo
dig3 = number //10
'
DEBUG CR, CR, HOME 'here I am debug to screen, later the numbers will be displayed on a 7segment display
DEBUG ?dig1, CR ' Show contents of each cell
DEBUG ?dig2, CR
DEBUG ?dig3
END
'==================== END =======================
SO here are my initial questions:
1) Do I need to set up an individual circuit including a 555 timer for the sending side?
2) How can I use the basic stamp commands such as SEROUT and SERIN to control the emitter and receiver?
3) My programs don't seem to work, what am I doing wrong?
4) Is using FREQOUT and PULSIN more reliable to get the job done?
5) Do you know any specifics about programming for the 8n1 UART protocol?
Thank you for your time ... Kenny
Comments
Use the RESET pin of the 555 to control it. When it's LOW, the LED (connected with a current limiting resistor between DISC and ground) will be off.
When RESET is HIGH, the LED will go on and off at a frequency controlled by the 555 (40 KHz hopefully). Similarly, the detector will go LOW when it's
active and HIGH when there's no modulated IR input. This is the opposite of the output side, so you'll have to use inverted mode in the SEROUT
statements.
4) You can use FREQOUT and PULSIN for IR communications, but these provide strictly an on/off signal, not serial data.
5) The SERIN and SEROUT normally use 8 data bits, no parity bit, one stop bit (8n1).
http://www.pmb.co.nz/hobbycorner/pages/irda_ser.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
However, the parts of the specification you've called out instead say that the LED is ON for a '1', OFF for a '0', and the default state is 'ON'. While this approach may have some noise, it's actually easier to interface.
So, you need an IR-reciever (NOT a 'decoder', which will only recieve a 38 Khz modulated IR light). You can feed the output of the IR-Reciever directly to a BS2 pin, and use "SERIN" to try to get the data. It will probably be noisy, though.
If you want to blow up your own IR LED's with 100 mA, you'll have to use a transistor, or Darlington Array chip (LM28003, something like that) to get that much current out of an I/O pin.· The BS2 is limited to 25 mA per pin, and 50 mA for the chip.
Post Edited (allanlane5) : 1/11/2007 8:19:37 PM GMT
If anyone has additional input, please post it here.
I have the complete circuit built with the 555 timer for 2400 baud, but further inspection with a Parallax oscilloscope reveals that there is still something not working right.
Again, thanks for the input!
Kenny ... see more on my project using Basic Stamps at www.smartystuff.info
(Yes, Drill Sergeant...· No, Drill Sergeant...· because you said to, Drill Sergeant.)