PIC to PIC Comms

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

PIC to PIC Comms

Post by jbs4wd »

Hi,
This may have already been addressed but can't find it so please point me in the right direction.
I am using 18F46K22. My project is simple at this stage just trying to get two pic to talk to each other via I2C. I want Pic A to send a request to Pic B for an ADC value and to display this value on an LCD. Then if this value is a certain value Pic A to send a request to Pic B to turn on an LED. What I am asking is, is there a I2C tutorial or the like to get two PICs talking to each other?

Cheers
JOHN

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: PIC to PIC Comms

Post by kersing »

Check this blog post (Slave is available in the current release)
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: PIC to PIC Comms

Post by jbs4wd »

Thanks, am now trying to work on RS232. Again to no avail. Could someone please have a look at my progs and tell me what I'm doing wrong. Hardware wise the two pics are connected together via TX1 and RX1 (25 & 26), and yes Tx-Rx.
Cheers
John
Attachments
RS232B.fcfx
(9.65 KiB) Downloaded 250 times
RS232A.fcfx
(10.5 KiB) Downloaded 237 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC to PIC Comms

Post by QMESAR »

Hi
I made a small example for you which show how you can use the RS232(UART) component to make two PIC's talk

you will see that PICA reads a analog signal at AN0 (a byte) then send it to PICB over UART ,PICB receives the byte in the UART Rx Interrupt and disiplay the value of the AN0 signal on PORTB .
as you change the signal on PICA AN0 the leds on PICB will follow the Analog to digital conversion done by PICA.

You need only to change the devices selected to your devices and do the configuration
my Projects use PICA = PIC18F45K22, PICB = PIC18F4585

The Connections between the 2 PIc's is as follows

PICA PICB
Rx --> Tx
Tx --> Rx
Gnd Gnd

this is how it look on my test board

Hope this helps you :D
Attachments
PIC_PIC_UART.zip
(415.94 KiB) Downloaded 245 times
1.jpg
(396.3 KiB) Downloaded 1758 times

jbs4wd
Posts: 46
Joined: Thu Dec 03, 2009 7:29 am
Has thanked: 4 times
Contact:

Re: PIC to PIC Comms

Post by jbs4wd »

That helped heaps. Thanks.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: PIC to PIC Comms

Post by QMESAR »

you are welcome :D

Post Reply