Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write reliable communication interface?

Status
Not open for further replies.

msmax

Full Member level 1
Full Member level 1
Joined
May 6, 2001
Messages
99
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Pays Bas
Activity points
919
how to write communication interface

I made a multiPIC system iusing F628 devices and soft UART. Used RB0 as comms pin.

Now running with about 16 PIC's on 1 bus with 1 master.

The pin is always in receive mode and switches to output for transmit.

Wrote some assembler routines to TX/Rx 5 bytes of data inc. checksum and using interupt for receive.

All seems to work well. But...

CAn ne1 explain what exactly the right way is to program reliable comms between several processors wher always comms is initiated by 1 master?

What are the steps to take in account when programming?
What are the steps to check for?

Thanks for your input!
 

You could try some software and/or hardware solutions.

Thin/Thick-wire Ethernet uses a single cable, and implements CSMA/CD - Collision Sense Multiple Access/Colllision Detect. That's what you need.

1. First thing is, when a node wants to xmit, it makes sure line is free by checking for idle for longer than several bit-periods. This stops a node jumping into the middle of another transmission.
2. Once it decides line is free, it starts transmitting a preamble, making sure what is seen on the line is what it is transmitting. You could implement this by making each station send it's own address (so they're all unique) and the xmitting station can check the line has what it is sending. Need to make sure max length of repeated 1s or 0s in this preamble won't allow another node to think the line is idle and start xmitting.
3. If a xmitting station detects a collision, it backs off for a 'random' time and then starts all over again - so two colliding nodes won't repeatedly collide by trying again at the same time.
4. All transmissions have a CRC, so the rx station can discard the packet if corrupt.

H/w could help with collision detect, in ethernet each transmitting station puts DC current onto the 75-ohm terminated line, as well as the AC signal, so if two nodes transmit at the same time the DC voltage goes up by twice what it would normally, so collision can be detected by comparator.

All-in-all, it would probably be simpler for the master to poll the slaves in some way.

If you've got a spare line to share around, you could get any slave wanting attention to pull it to generate an interrupt at the master, and then get the master to scan around the slaves one by one.

HTH
Barny
 

Thanks Barny for your valuable input.

My system has 1 master scanning about 127 slaves maximum.
Master addresses 1 slave and waits for 1 byte period for an reply. If not, then tries again. If still no reply received, check the next address.

I need info on what the time outs should be (and how to calculate them) for:
Transmitting:
- Between 2 bytes in 1 packet ( if neccesary to have a time out)
- Between 2 packets

Receiving:
- Between 2 bytes before discard byte
- Between 2 packets

I use 9600,n,8,1 as comms parameters.

I can't use collission detection in the way of receive back and compare cause I use the same pin for RX as TX.

Any one has some samples in assembler of how to implement packet data receive & transmit for PIC processors?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top