1- Managing the send / recieve modes by soft will result most likely in failure for the communication
[Ref.Link to be inserted here]
I am trying to hook up a Tristar TS-MPPT-60 to a Pi using a rs485 chip connected to the Pi UART, and eventually add my Arduinos to the network.
I have some MAX485 chips and a Sparkfun rs-485 BOB to do my tests.
TS-MPPT-60 Manual: http://africanenergy.com/new/wp-content/uploads/2012/08/tsmppt_english-manual.pdf
TS-MPPT-60 MODBUS: http://www.soligent.net/uploads/products/24886_7.pdf
rs-485 BOB: https://www.sparkfun.com/products/10124
2-To let the pi control the RTS / CTS you need access to Pins 30 and 31
Here is what I got hooked up but not tested yet:
original img: http://www.homegenie.it/forum/index.php?topic=208.0
3-To use the UART you need to have it released by the Pi internal use(undesired traffic):
The MakeFile is broken,
do not forget to fix this code for the gpio_setfunc function to compile:
In the Makefile change the line:
cp $(BINARIES) $(SCRIPTS) $(BINDIR)
cp $(BINARIES) $(BINDIR)
To make this restart safe, we put the command into /etc/rc.local:
# enable CTS+RTS on P5 header for onboard serial
/usr/local/bin/gpio_setfunc 31 ALT3
/usr/local/bin/gpio_setfunc 30 ALT3
3-Here is a sample of code that should allow to communicate with slaves.
pymodbus rtu rs-485 communication
Pay attention to the corrections below the code block in the previous link.
temps = client.read_input_registers(30001, 4, unit=0x0a) # address, count, slave address
coil = client.read_coils(10001, 8, unit=0x0a) # address, count, slave address
In the sample code, replace the undesired usb port with the TTL one:
All of this is untested, but that is a resume of all my findings up to now.
Now my latest issue is that the Slave has a big 12v mark on the Modbus port.
Will my Pi get fried? I'll keep you posted.