CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232 IR Link to PC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Samuel Shelton
Guest







RS232 IR Link to PC
PostPosted: Tue Feb 25, 2003 2:03 pm     Reply with quote

<font face="Courier New" size=-1>Hi All!

I am working on a Infrared one way link from a 16F628 to a PC. The PC receiver needs to be really simple, just a IR reciever (TSOP 1738) connected to a MAX232 that plugs into the PC serial port. I would like to use the USART of the 16F628 to modulate the output of its PWM. I would appreciate guidance on the circuit and especially on the source code (in C ;). Would it be possible to do the same using a 12F629, which does not have a PWM. Thanks for any help.

Regards,
Sam.

PS. Sorry about the double post, but deletion seems to cause a server error:(</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12094
Dale Botkin
Guest







Re: RS232 IR Link to PC
PostPosted: Tue Feb 25, 2003 9:05 pm     Reply with quote

:=<font face="Courier New" size=-1>Hi All!
:=
:=I am working on a Infrared one way link from a 16F628 to a PC. The PC receiver needs to be really simple, just a IR reciever (TSOP 1738) connected to a MAX232 that plugs into the PC serial port. I would like to use the USART of the 16F628 to modulate the output of its PWM. I would appreciate guidance on the circuit and especially on the source code (in C ;). Would it be possible to do the same using a 12F629, which does not have a PWM. Thanks for any help.
:=

Well, I have used the 16F877's PWM module to modulate an IR LED for comms. It's actually more simple than you may think... once you have the PWM module set up to generate a stream of pulses at your desired rate (40KHz in my case), you can connect the IR LED and a current limiting resistor between the PWM output and the serial data out pin. Switching the orientation of the LED will give you either true or inverted data, modulated at the PWM rate. That's good for up to 20mA or so of drive to the LED, which should be way more than sufficient for short range comms.

As for doing it with a 12F629, let's see... you might be able to use an oscillator 4x your desired pulse rate (160kHz, for example) and use CLKOUT to modulate the LED, but it might be tough getting sane baud rates. Or you *could* *maybe* use TIMER0 to interrupt every 62 cycles (at 20MHz) and toggle the LED pin, but I doubt you'd have a lot of luch with that. For one thing, the 'F629 has no hardware UART, and software serial and interrupts rarely mix well. Especially really fast interrupts, like 2x your IR pulse rate. I think a 16F628 might be as small as you can go, it's got CCP and USART.

Hope this helps... I can dig up the code for the PWM setup, but it's pretty simpe to figure out. Mine is specific to a 16F877 with 20MHz xtal and a 40kHz rate.

Dale
___________________________
This message was ported from CCS's old forum
Original Post ID: 12107
Samuel Shelton
Guest







Re: RS232 IR Link to PC
PostPosted: Wed Feb 26, 2003 5:55 am     Reply with quote

Thanks Dale!

Do you think adding a 12F629 on the reciever side, and using some kind of custom protocol (morse code ;)) will work?.

I also am tempted to try a 555 based signal generator to modulate the LED and then use a software UART. Any suggestions for a simple low power generator, I have very little luck with analog stuff.

I was trying out your suggestion on the 16F628 and am quite pleased thanks again.

Sam
___________________________
This message was ported from CCS's old forum
Original Post ID: 12114
Dale Botkin
Guest







Re: RS232 IR Link to PC
PostPosted: Wed Feb 26, 2003 5:12 pm     Reply with quote

:=Do you think adding a 12F629 on the reciever side, and using some kind of custom protocol (morse code ;)) will work?.
:=
:=I also am tempted to try a 555 based signal generator to modulate the LED and then use a software UART. Any suggestions for a simple low power generator, I have very little luck with analog stuff.
:=
:=I was trying out your suggestion on the 16F628 and am quite pleased thanks again.
:=

Well, a 555 should work... setting it up for free-running astable operation is pretty well documented. I would thing a 12F629 would work fine for a receiver, assuming you're using one of the many available modulated-IR receivers like the Sharp I use. No real need for a custom protocol, I would think regular old async serial would work. I have Morse code transmit functions I use a LOT, but no receive routines -- though it's been done.

Good luck --

Dale
___________________________
This message was ported from CCS's old forum
Original Post ID: 12144
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group