I have a problem with the above mentionend expansion shield.. I'd like to connect a device via rs485 but the manual to the shield doesn't provide much information on how to do so...
I switched the black caps (sorry I don't know the correct word in english..) as mentionend in the lilac square. Then I've connected the device via A and B.
I've tried to send data using pin 0 and 1 as rx/tx pins, which somehow worked.. but not correct.
Now I'm generally confused about how this i/o expansion works.. isn't it necesarry to enable/disable the transceiver before sending/receiving data?? how can this be done? which pins on the arduino are used for communication??
Here's a link to the only datasheet I could find...
The device I'd like to connect needs a start bit, 8 data bits and a stop bit. It communicates at 9600 Baud.
I read a lot about rs485 and I'm a bit confused now as I've read that rs485 uses 'inverted logic'. what does that exactly mean for my code? I've tried to use the SoftwareSerial Library for communication and I've tried to send single bits by setting the txPin High and Low, but nothing seems to work properly.. The device receives a value but it seems very arbitrarily... I've no idea anymore... :-/
RS485 ONLY defines the Physical Layer characteristics of the signal. What it does at the DATA layer is something you need to understand with regards to your "external" device you want to talk to.
RS232 and RS485 both do "inversion" so that's likely not your issue.
In general, the difference between RS232 and RS485 is that the RS232 standard is designed for point to point communication between a TERMINAL and a COMMUNICATIONS device and RS485 is designed as a Multi-Point DATA BUS using a Balanced Signal (A & B) to maximize noise immunity.
HOW the devices talk is important. There is MODBUS, DMX, SNAP and many more "protocol standards" and the one you use needs to be understood and coded for on the Arduino.
Also note: If you have just an A & B signal, you are likely running Half Duplex (only one device is allowed to talk) and this usually means that ONE device is acting as MASTER and all the other RS485 devices will not "talk" unless the MASTER requests it.
Igor created some good examples of how to implement RS485 (master/slave) in the forum already. A quick search should find it.
I've read about most of the things, but I can see it now in a better context..
I think the main problem is, that I have to write a protocol by myself.. All I know, is that the device communicates 8N1.. but how to write such a protocol? should I send every single bit like "serial.print(0, BIN);" or only the start and stop bit and the data bits as a byte...? or am I completely wrong with my ideas?