Thanks for the response dhouston. I looked over the information. I think that is were I eventually want to get to. However, I don't think I am ready to take that big of jump yet.
I have been working on trying to do simple IR communications between 2 PICs. I basically used the codes from http://www.rentron.com/Infrared_Communication.htm.
I used a PIC627 with this code for the PWM and SEROUT.
Code:
DEFINE OSC 4
TRISB.3 = 0 ' CCP1 (PortB.3 = Output)
PR2 = 25 ' Set PWM Period for approximately 38KHz
CCPR1L = 13 ' Set PWM Duty-Cycle to 50%
CCP1CON = %00001100 ' Select PWM Mode
T2CON = %00000100 ' Timer2 = ON + 1:1 prescale
TRISB.0 = 0
ADDRESS VAR BYTE
DAT VAR BYTE
ID VAR BYTE
ADDRESS = 10
ID = 25
BEGIN:
FOR DAT = 0 TO 255
SEROUT PORTB.0,4,[ID,ADDRESS,DAT]
PAUSE 100
NEXT
GOTO BEGIN
END
And I used a PIC628A with this code for SERIN. The code Rentron had listed was BS2 code. I did my best to convert it to picbasic. I used SERIN2 instead of SERIN.
Code:
DEFINE OSC 4
CMCON = 7
VRCON = 0
TRISA = 0
TRISB = 1
SYNCH CON 25 'Establish synchronization byte
BAUD CON 396 'NON INVERTED 2400 baud (MAX)
DAT VAR byte 'Data storage variable
ADDRESS VAR BYTE
START:
SERIN2 PORTB.0,BAUD,[WAIT(SYNCH),ADDRESS,DAT]
PORTA = DAT
GOTO START
END
Was it okay to use SERIN2 with SEROUT?
I connected 4 LEDs to porta.0 thru porta.3. I am getting a response from the LEDs. I am just not sure if it representing the correct data. When I try something like:
Code:
ADDRESS VAR BYTE
DAT VAR BYTE
ID VAR BYTE
ADDRESS = 10
ID = 25
DAT = 10
BEGIN:
SEROUT PORTB.0,4,[ID,ADDRESS,DAT]
PAUSE 100
GOTO BEGIN
END
I get the correct LEDs to light up initially for about a second. Then, the other LEDs start flashing.
I will continue to experiment and hopefully I will get the communications figured out.
I do have a question about the schematic Rentron uses for the IR Transmitter. Is there a reason why 2 Infrared LEDs are used to transmit the signal?
Bookmarks