[moved] Communication Problem RS-485 MASTER and SLAVE

Status
Not open for further replies.

aacs

Newbie level 2
Joined
Sep 3, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
17


Hi does your code work out? can you help me please i could not communicate between master and slave using rs485
 
Last edited by a moderator:

Hi,

To hardware:
* RS485 is a two wire bus, differential signalling, plus ground signal.
* It needs differential pair wiring with a wave impedance of about 120 Ohms.
* All devices are connected in a string ==> No star wiring.
* The master does not need tof be connected at one end, it may be placed anywhere in the bus,
* Both bus ends need to be terminated with 120 Ohms each (independent of master connection)
* The bus should be biased to get a valid high signal when bus is idle = all drivers are off.
* All receiver may be enabled all the time. If disabling, then TTL Rx data output needs a pullup.
* Only one (or none) driver should be enabled in a time

Software:
* when interrupt flags are used, but no ISR, then the flags need to be cleared manually (I don't see here)
* The bus must be released after transmission (Disable driver). This can be done after each byte or after each frame. But take care not to disable the transmitter too early. Not after storing the byte into the UART transmit buffer, but after the STOP bit is transfered to the bus.
* there is no need to disable/enable UART receive/transmit periferal. Both may be ON all the time, but you will receive your own sent out data (echo).

Klaus
 


Thanks Klaus,
I understand what you are saying but I do not know how to start. If you have any sample with this can you please post it.
 

Hi,

I don't have code.

You now need to think about a protocol.
Either you use a standard one like modbus (check if this is what you needs)
Or you need to develop your own protocol.

Before starting to program you need to decide about:
* baud rate,
* min bus idle timing
* arbitration
* addressing
* frame sync
* frame size (variable/fixed)
* crc, and how to handle bad packets (discard/resend)
* slave respond time
* timeouts
* how to detect and how to handle, if one device freezes the bus
...
Please do the paperwork first, then start to program.

Klaus
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…