| Swordfish Tutorial/Library - Infrared (IR) Modulated UART |
|
|
| Saturday, 04 April 2009 09:58 | |
|
Want to be able to transmit data effectively, reliably, and most importantly wirelessly? Well Infrared modulated UART could be the cheapest and most effective solution. This guide provides a great solution for remote control and wireless data communication, and while it only covers the fundamentals, the possibilities are up to you. With the circuits/products and programs listed below, I have been able to achieve over 20 meters of IR data communication.
The next task is to somehow turn UART data signals into 38Khz modulated IR... Why don't we utilise the onboard Pulse Width Modulation built into almost every PIC? If you setup the PWM output for 38Khz and 50% Duty Cycle, then the next objective is to somehow turn it on/off at the same time a UART output is normally on/off. I can think of two methods, one is to use a Logic AND gate, placing the PWM signal on one input, and the UART TX on the other - the result would be Modulated UART with a 38Khz carrier. But you can do this without the requirement of external components by controlling the Tristate status (input/output) of the PWM Pin. By making the PWM pin an input, you are turning off the 38Khz signal, and of course enabling it again when returned to an output. Here's what a snippet of a modulated signal would look like;
The library I modified can be found here. For more information on how to use Swordfish libraries, have a look here. Now you can send/receive data just as if it were a normal UART connection, here's an example program;
Device = 18F2550 Clock = 8 Config FOSC = INTOSCIO_EC Include "INTOSC8.bas" Include "PWM2.bas" Include "IR_UART.bas" Dim Variable As Byte // start of main program PWM.SetFreq(38000) PWM.Start1 PWM.SetDuty1Percent(50) IR_UART.SetTX(PORTC.2) IR_UART.SetMode(umTrue) IR_UART.SetBaudrate(sbr300) Variable = 0 Low(PORTC.0) While True Inc(Variable) IR_UART.Write(Variable) DelayMS(500) Wend
Receiver Program:
Device = 18F2550 Clock = 8 Config FOSC = INTOSCIO_EC #option LCD_DATA = PORTB.4 #option LCD_RS = PORTB.0 #option LCD_EN = PORTB.1 Include "INTOSC8.bas" Include "IR_UART.bas" Include "convert.bas" Include "lcd.bas" Dim Variable As Byte IR_UART.SetRX(PORTC.2) IR_UART.SetMode(umTrue) IR_UART.SetBaudrate(sbr300) DelayMS(150) LCD.Cls LCD.WriteAt(1,1,"IR UART") While True IR_UART.Read(Variable) LCD.WriteAt(2,1,Convert.DecToStr(Variable,3)) Wend
Comments (2)
Joomla components by Compojoom
|
|
| Last Updated ( Friday, 02 October 2009 07:57 ) |
Whos Online
- MrDEB
Forum Activity
simulation program - mrdeb Thursday, 11 March 2010 22:52 - [0 replies]
MARCHING ledS - mrdeb Thursday, 11 March 2010 19:13 - [3 replies]
REALISTIC LED candle flicker - mrdeb Wednesday, 10 March 2010 05:48 - [0 replies]
the LCD demo hello world - mrdeb Wednesday, 10 March 2010 05:41 - [29 replies]
USB problem - jon chandler Tuesday, 09 March 2010 11:31 - [3 replies]
Servo Module - andyo Tuesday, 09 March 2010 03:39 - [3 replies]
pic to ps2 communication - roshan Friday, 05 March 2010 01:30 - [7 replies]
Recent Comments
- 2010-03-11 21:03:32 Jon C...
If this wasn't a class project that had to be done on a PIC16F690 u...
- 2010-03-11 15:30:06 uuu
I am going to send two data from ADC to USART(async mode) to serial...
- 2010-03-05 13:24:23 mrpse...
I was thinking of battery with powered routers or powered for every...
- 2010-03-05 12:17:40 andyo
50 rooms - wow. The XBee modules are very easy to use but I'm not ...
- 2010-03-05 11:46:37 mrpse...
Thanks AndyO. What I have to do is design a device to monitor temp...
- 2010-03-05 03:08:58 andyo
The circuit used for the remote sensor can be found here: [url]http...
- 2010-03-04 07:19:06 renno
plz i need help do u know from where i could download it or how cou...
- 2010-03-04 07:16:05 renno
hello everyone i'm trying to finish my final project and i want to ...







Dear Sir
How can i simulate the ir communication with proteus,please explain in detail
Best Regards
Medhat