Yes, perfectly possible, and quite easy. One of my tutorials shows how to set up two channel PWM and vary it by simple data changes - it's intended for speed control of a robot.
I was actually playing around with IR not that long ago, and customized one of the Swordfish (a PIC Basic compiler) UART libraries to modulate the signal for infrared data transmission, the results were great.
Like most compilers, SF has its own software UART routines, but when modified to turn on/off a 38Khz PWM signal instead of making a pin high/low, the result looks like this; **broken link removed**
And what does that look like? Well its now modulated UART ready to control an infrared LED to transmit the data!! **broken link removed**
How do you go about recieving the signal? The use of a "logic output" IR reciever makes life easy. It will provide a logic high (5V) should a 38Khz signal be detected. You have now successfully demodulated the IR encoded UART data! **broken link removed**
It was as if two PIC's were connected by a wire and UART data was being sent from one to another, but of course they can be many many meters away (my hall way is 17 meters and I did not get any errors - it would even work around corners and into other rooms because of the high intensity IR Leds I was using)
Transmit Program:
Code:
Device = 18F2550
Clock = 8
Config FOSC = INTOSCIO_EC
Include "INTOSC8.bas"
Include "PWM.bas"
Include "IR_UART.bas"
Dim Variable As Byte
// start of main program
PWM.SetFreq(38000)
PWM.SetDuty1(50)
PWM.Start1
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:
Code:
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
Of course a lot more information can be found here **broken link removed**
Might help you out on the IR side of things, manipulating PWM is extremely easy as well, consider **broken link removed**
The only downside to all of that is I use Swordfish to create my programs, you can download a free version of it here
(note, it only supports 18F devices.. 18F PIC's are simply an advancement in micro controller technology. They are 16F's without the drawbacks, and have more hardware peripheral features built in)