PDA

View Full Version : IR-RS232 with pic 16F628A



aloncha
- 8th September 2005, 15:53
Hi,
I am new in the forum and want to create some proyect but I need some help.
I am going to design a universal bidirectional interface IR-RS232 with the PIC and extra hardware.
The function of the pic is to translate IR codes to 232 and viceversa.
I´m planning to use a MAX232 to turn from -12 V and 12 V to TTL logic.
How can I program the pic in order to contemplate all carry frecuences, not only one, it may work on the range of 33KHz - 45KHz approximately.
Also if anyone has code examples, can you send it to me?
Thanks a lot!!

[email protected]

sougata
- 9th September 2005, 06:49
Hi there,

Please clarify if you intend to use the IR as medium of Transmission only or intending a full blown IrDA interface for your PIC. Microchip makes a chip that has the IrDA stack built into it. I don't recall the number but will post later.
If you intednd only a simple communication then select a PIC that has an onboard PWM generator (for theTx part anded with the serial data and thrown to an IR LED)and use a TSOP1736 or similar IR sensor-decoder to interface as the receiver.

Regards

Sougata

mthogan1997
- 9th September 2005, 13:19
This might help you:

http://www.rentron.com/Infrared_Communication.htm

Mike

aloncha
- 10th September 2005, 01:00
Thanks to both of you!
I only want to make a simple communication and PIC 16F628A has on board PWM, but I don´t know how it works.
Can you help me?

sougata
- 10th September 2005, 03:55
Hi there,

The mentioned sensor is a three pin IR sensor/demodulator. It receives a modulated stream of 38/36 KHz IR and gives the output via its pulled up open collector port. So the output for a valid 1 is 0 that is inverted. It works best when the duty cycle for the carrier (38KHz nominal depends on the last two digits of the sensor part no.).

Take an AND gate. Feed 1 input with the 38KHz output from your PWM module. You can set up your PWM module in the PIC by the PBP HPWM command. Now feed the data (non-inverted) to the other input of the AND gate. Amplify (a higher current is needed for effective IR transmission over the ranage of 5 to 10 meters) the output of the AND gate and drive some IR LED. That goes for the Tx part.

For the Rx part , just invert the output from the sensor and feed it to the PIC.

for the software you can use the Serial Out and Serial In of PBP. A maximum possible speed is 2400bps.

Regards

Sougata

jj 2
- 12th September 2005, 18:08
I too am new to this forum. There are a lot of questions to be clarified.

I assume the IR device output is TTL, 0-5 volts, 0 with no IR input and 5V with IR input. If so, why the Max232? Is the purpose of the Max 232 to provide output to go to a PC?

I assume the device will output a sequence of ON/OFF TTL transitions similar to an RS-232 character - correct? Does the IR device output a RS-232 code? If not, then you need to decode the output some way. Assuming it is "RS-232 like" you will need to determine the bit timing and program the pic to detect the bit sequence.

What is the data bit rate? I took a class once and we did some 1200 baud pic to PC RS-232 experiments using a 4MHz frequency for the pic. If the baud rate is faster you may need to go to a higher pic oscillator frequency.

Google the Microchip web site and check out some of the application notes and sample code to get help on programming the pic to handle RS-232. Decoding another format code can be handled similarly.

Hope this helps.

jj 2

aloncha
- 12th September 2005, 20:52
Sougata,

Could you make some code examples in assembler about the Tx and help me?
Thanks a lot!
Alan

DynamoBen
- 13th September 2005, 00:39
Hold on a second, this has already been done.

I built one myself a few years ago and it worked great.

http://www.fukushima.us/UIRT2/

I have since upgraded to the newest usb version.

http://www.usbuirt.com/

aloncha
- 13th September 2005, 17:19
Thanks!
But I want to create my own, so can you send me some code examples in assembly languaje, not an hex file???
Again, thanks!

DynamoBen
- 13th September 2005, 17:31
I can't send you anything, its not my code. You could contact the author and see if he is willing to send it to you.

aloncha
- 13th September 2005, 17:31
Thanks for your help!
The purpose of the MAX232 is to provide output to go to a pc and input from the pc.
I want to send some string by RS-232 and output a IR signal, so I want to use the PIC as a translator.
I want to save in PIC the IR code of the equipment and make correspond some string to an IR code, example: typing "PL" on the hyperterminal I want the pic to send de PLAY IR code, previously known.
I´m planning to use the 4MHz oscilator, so what is the maximum speed allowed for that crystal?
If you have some code examples you will help me a lot!!
Thanks

aloncha
- 13th September 2005, 17:33
Ok, can you send me his E-mail?