| 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
- andyo
- MrDEB
Forum Activity
LCD / 18F1320 - mrdeb Saturday, 20 March 2010 06:21 - [3 replies]
A 'throw-away" PIC board - mrdeb Thursday, 18 March 2010 06:19 - [32 replies]
Credit Where Credit's Due - jon chandler Tuesday, 16 March 2010 12:01 - [9 replies]
Marching LEDs - mrdeb Saturday, 13 March 2010 22:54 - [7 replies]
USB 8 Channel Servo Controller - andyo Saturday, 13 March 2010 01:19 - [2 replies]
Dedicated Servo Controller - graham Friday, 12 March 2010 17:58 - [0 replies]
Must have....delta temperature glowies! - graham Friday, 12 March 2010 17:31 - [3 replies]
Recent Comments
- 2010-03-20 07:58:45 andyo
Nice. The TAP-28 boards are looking good. When I've had a buzzi...
- 2010-03-19 22:05:12 ozbec...
The author (Hop) suggests to "set the target PIC's configuratio...
- 2010-03-17 22:58:18 Jon C...
Graham, Thanks for fixing the spacing on the array. This is how i...
- 2010-03-17 21:14:34 ASDne...
Thanks Graham, It is a problem with Flowcode because the demo wa...
- 2010-03-17 19:50:32 Graha...
Looks like you've pretty much solved every minor issue that was enc...
- 2010-03-17 11:42:03 Jon C...
The low-cost servo does have one other feature. The origina...
- 2010-03-17 10:56:44 Graha...
I am not familiar with flowcode, though did you try powering the bo...
- 2010-03-15 21:47:55 ASDne...
Hello there, I am still trying to get the LCD to work but I am pro...







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