Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/16/00 09:10
Read: times


 
#5108 - RS485 networking - for Raul
Hi Raul!

My application runs, while serial receive interrupt is enabled to receive
any serial data transmitted from the master. The format of the received data
on RS485 is still the same like serial RS232 format, only the hardware
interface is different. You should implement 2 wire RS485 that can run in
half-duplex (Only ONE device on the RS485 bus can be a transmitter at a
time). In the serial interrupt routine you check the address received, this
is the first byte in the data packet. If address == own_module_address, then
receive the data into the input buffer and do some actions, otherwise do
nothing and ignore incoming frame. This is handled in an interrupt routine.

So you can see that each controller module has to have assigned a unique
address - 8 bit is enough for 255 modules on the bus. Module nr. 256 is then the master - maybe it is a PC computer.

Next byte in a frame that has been sent to the module is a command byte.
With the command byte you tell the module what to do with the additional
data that has been sent to him. (To change a parameter, to do a measurement,
to switch on a paraticular output port, to display something on the internal
display of the module etc.). If the command requires also an answer, then
the addressed module should transmit the answering frame right after it has
received a command from the master. If no answer is required from the
master, it is a good choice to acknowledge the received command with the acknowledge frame.

Master will wait for the replying frame from the addressed module a predefined time before timeout. If an answer is received, it is considered
OK, otherwise it is considered that the addressed module is not functioning
or is damaged. This way you can keep the state of each module in the
master's internal memory. In the replying frame the slave module address can also be included for double checking - safety reasons.

At the end of the message frame CRC control should be added - 16 bit CRC is
good enough, to prevent errors and enable error correction procedures to be
implemented. If a faulty frame is received, frame retransmission should be
requested from the module.


To increase the reliability and to make your "RS485 network" even more
secure, each transmitted frame can be numbered with an 8 - bit number that
enables the synchronizm between the transmiting and receiving module.The
transmitting and receiving module count the transmitted frames and
acknowledge the frame with the correct frame number.

This make the application very complex and at this point it is good to split
the software into several "layers". Like: hardware layer, link layer,
network layer, application layer etc.

This technique enables to retransmit a few frames that were not received
Frame numbering enables you to disconnect and reconnect the module from the RS485 network without any harm. This should be the task of "link layer".
Upper layer - "network layer", should not notice a short "RS485 link"
disconnection even if it happened during the receiving or transmitting time on the bus.
But this is probably too complex since you will probably not implement such
high level networking like ISDN-digital network.

Regards Franc




List of 3 messages in thread
TopicAuthorDate
RS485 networking - for Raul            01/01/70 00:00      
RE: RS485 networking - for Raul            01/01/70 00:00      
RE: RS485 networking - for Raul            01/01/70 00:00      

Back to Subject List