No RS-485 communication
Home › Forums › Conduit: mLinux Model › No RS-485 communication
- This topic has 2 replies, 3 voices, and was last updated 9 years ago by
Peter Ferland.
-
AuthorPosts
-
February 10, 2017 at 6:15 am #16967
prakash shinde
ParticipantI have installed the RS-485 DCE accessory card in AP2 slot of Multitech.
My slave device has address 2 and baud as 38400.
I ran below commands from serial debug console of Multitech to enable 485 communication:root@mtcdt:~# mts-io-sysfs store ap2/serial-mode rs485-half
root@mtcdt:~# set-rs485 /dev/ttyAP2 1When I am trying to communicate with the slave device from python interpreter using minimalmodbus, I am getting no communication error:
>>> inst = minimalmodbus.Instrument(‘/dev/ttyAP2’, 2, minimalmodbus.MODE_ASCII)
>>> inst.serial.baudrate = 38400
>>> hp_in_value = inst.read_register(40605, 4)
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “/usr/lib/python2.7/site-packages/minimalmodbus.py”, line 258, in read_register
return self._genericCommand(functioncode, registeraddress, numberOfDecimals=numberOfDecimals, signed=signed)
File “/usr/lib/python2.7/site-packages/minimalmodbus.py”, line 697, in _genericCommand
payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
File “/usr/lib/python2.7/site-packages/minimalmodbus.py”, line 795, in _performCommand
response = self._communicate(request, number_of_bytes_to_read)
File “/usr/lib/python2.7/site-packages/minimalmodbus.py”, line 930, in _communicate
raise IOError(‘No communication with the instrument (no answer)’)
IOError: No communication with the instrument (no answer)I tried swapping the communication lines on RS-485 bus but still getting same error. Any suggestions would help me to move on.
Thanks,
PrakashFebruary 10, 2017 at 8:44 am #16973Jeff Hatch
KeymasterPrakash,
The setup commands look correct for setting up rs485-half duplex mode on accessory card port 2.
I don’t know a lot about python minimalmodbus, but when you create the instrument object “inst” I’m assuming that you have the correct slave address. Also, when you call read_register you are asking for four decimals. Is that correct? Another note is that 40605 is a pretty high register number, is that correct?
Jeff
February 10, 2017 at 9:51 am #16976Peter Ferland
BlockedHi Prakash,
Can you try putting the set-rs485 call inside the python script after you open the tty like this:import minimalmodbus import os instrument = minimalmodbus.Instrument('/dev/ttyAP2', 1) os.system('set-rs485 /dev/ttyAP2 1') reading = instrument.read_register(40605, 4) -
AuthorPosts
- You must be logged in to reply to this topic.