Author Topic: PIC to PIC synchronization  (Read 13645 times)

titan2020

  • Member
  • ***
  • Posts: 7
PIC to PIC synchronization
« on: January 12, 2023, 09:39:36 am »
Hello,

I'm building a project. That consists of 3 PCBs, each with a PIC. The PIC on one of the boards must send and receive multiple bytes of data to and from the other 2 PICs as well as a PC. All transfers use the on board UARTs. I'm looking for algorithm ideas to synchronize these transfers so that data does not get scrambled and gets to the appropriate device.

Thank you,
Steve   

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: PIC to PIC synchronization
« Reply #1 on: January 12, 2023, 09:50:55 am »
If each device has a single UART, you'll need to use a hardware networking interface such as RS-485 to connect them all.

One way to manage communications is to have one device control the communications. For example, assign an address to each device. The controlling device polls each device in turn, including the address in the communication to identify the intended receiver. The other devices send data only when polled.

Renate

  • Frequent Contributor
  • ****
  • Posts: 97
Re: PIC to PIC synchronization
« Reply #2 on: January 27, 2023, 09:10:28 pm »
One protocol to use would be MODBUS.
It's not rocket science but it is standardized.
If you're talking on a bus it's good to have a bit of error detection and knowing how long a message is so you can turn around the direction and respond.
Sure, you could make your own standard, but why?

I'm running a Raspberry Pi with RS-485 to a dozen nodes.
The first one already happened to be MODBUS, so I stuck with it.

There's also CANBUS, but it's a bit more tricky to deal with.