2

I am a beginner in Python (FYI) and trying to communicate with the Gefran 800P programmer/controller using minimalmodbus library (Python + Mac). I am using USB to RS485 Serial Converter Cable (http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_USB_RS485_CABLES.pdf) to communicate with the Gefran device. Pins from the rear of the device (15+17(Rx+Tx) & 16+18(Gnd+Gnd)) are connected to Data +(A) and Data -(B) of the converter cable, respectively (RS485-2wired connection). I don't know the slave address for this device and there is no where mentioned about the address in the manual (http://www.primusthai.com/marketing/Gefran%20800%20(Controller).pdf).

I have tried:

  1. Changing address of the slave form 0 to 247 and I always get the same message.
  2. Tried checking for different register address and played around with function codes (3&4), played around with the programmer settings making sure both parameters in the code and the device are the same. Nothing works! Maybe I am missing something. Looking forward for your help. I am really stuck at this point for more than a week now!

Below is my code and when I run it, it gives me an error "ValueError: Too short Modbus RTU response (minimum length 4 bytes). Response: '\x00' ".

import minimalmodbus
import serial
import sys
import time
import sh

minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL = False 
print "scanning for addresses..."
for i in range(1,247):


    programmer = minimalmodbus.Instrument('/dev/tty.usbserial-FT0C9E5S', i, 'rtu') 
    print "address is", i
    programmer.mode = minimalmodbus.MODE_RTU
    programmer.serial.timeout = 8
    programmer.handle_local_echo = False
    # If RS-485 adapter has local echo enabled  
    programmer.serial.bytesize = 8
    programmer.precalculate_read_size = True  
    programmer.serial.baudrate = 9600
    programmer.serial.parity = minimalmodbus.serial.PARITY_NONE
    programmer.debug = True
    print "all parameters set... now reading"
    print programmer 


    try:

       setpoint = programmer.read_register(79,1,4)
       print setpoint
       print "This is the address", i
    except sh.ErrorReturnCode_1:
        print "no response"
MMR
  • 31
  • 4
  • Did you checked all serial port settings like baudrate, parity, etc.? – Jacek Szumigaj Feb 08 '17 at 13:54
  • Yes I tried with all the possible baudrates and parity, basic settings are baudrate :9600,19200 with No parity.. Tried this too.. – MMR Feb 10 '17 at 09:15
  • [At LabView forum](https://www.labviewforum.de/attachment.php?aid=31258) you can find some information about 4-wire RS485 in Gefran controllers. Quick reading brings me idea that your connections my be right but you should try to swap Data A and B, that is: connect (18+16) to A and (17+15) to B. And decrease speed to 1200. I assume, that you checked and set the same baud rate, stop and parity in Gefran controller menu. Only after successful communication increase speed. – Jacek Szumigaj Feb 11 '17 at 10:32
  • I have been following the same document that you mentioned and I have tried interchanging the connections too. When I do what you mentioned, I get no reply from the device. MinimalModbus debug mode. Response from instrument: '' () (0 bytes), roundtrip time: 5001.0 ms. Timeout setting: 5000.0 ms. raise IOError('No communication with the instrument (no answer)') IOError: No communication with the instrument (no answer) – MMR Feb 13 '17 at 09:31
  • Okay. I don't know if its some progress, When I connect the device in the original software (GF_eXpress for Windows only), and then when I run my python code with the same pins (15&17 to + and 16&18 to -) connected to my Mac, I get this error now : ValueError: Checksum error in rtu mode: '\x00\xff' instead of '\xd6\xda' . The response is: '\x00\xff\xff\xba\xd6\x00\xff' (plain response: '\x00\xff\xff\xba\xd6\x00\xff') I am not sure what is working , what is not... I am so stuck at this for weeks now :( Any suggestions please ? – MMR Feb 13 '17 at 13:49

2 Answers2

1

Okay Jacek, thanks for all the hints.. I finally managed to get the device communicating using Gefran Cable. I am not 100% sure what really worked, but I tried the following:

  1. Install software "modpoll" to poll for the modbus devices to compare the parameters in the GF_eXpress software and the device and to know what is happening in the background.

  2. Tried to use pyserial to serially communicate with the device - I think this did the trick, you have to first initialise the port and then communicate. In my case opening a serial port and connecting to the port and then using modbus, worked like magic.

  3. I restarted the programmer, my Mac, gave basic parameters baudrate - 9600, parity - none, address - 1 and stop bits - 1 and it started working..

I am guessing all of these could have helped plus if nothing works, it is always good to restart every single device that you are using and reset the parameters and set it again to basic/standard values.

MMR
  • 31
  • 4
0

Pins from the rear of the device (15+17(Rx+Tx) & 16+18(Gnd+Gnd)) are connected to Data +(A) and Data -(B) of the converter cable

Maybe I'm wrong, but IMHO, you should use pins 16 & 15 for + and -

Pins 18 and 17 are described as:

Configurable serial line isolated to 1500V Passive current loop (max. 1200 baud)

maybe you shouldn't wire them together with 15 & 16?

Jacek Szumigaj
  • 113
  • 2
  • 8
  • Thanks for the hint. I shall try this configuration and update you! – MMR Feb 10 '17 at 09:17
  • I did what you said. I take four different wires from the device and connect it separately to Data + and Data - . I connected 16 and 18 to Data (+) and 15 and 17 to Data(-). Also I connected 16 & 15 to Data (+) and 18& 17 to Data(-). I get no response from the device: MinimalModbus debug mode. Response from instrument: '' () (0 bytes), roundtrip time: 5001.0 ms. Timeout setting: 5000.0 ms. raise IOError('No communication with the instrument (no answer)') IOError: No communication with the instrument (no answer) – MMR Feb 10 '17 at 10:15
  • The only configuration that gives me the error ""ValueError: Too short Modbus RTU response (minimum length 4 bytes). Response: '\x00' " is by connecting 15&17 to Data(+) and 16&18 to Data(-). – MMR Feb 10 '17 at 10:17
  • I suggested you to connect 15 to + (or -) Data and 16 to - (or +) and leave 16 and 18 not connected. The manual (serial line description) is unclear to me, but information near pin 18 and 16 _"max. 1200 baud"_ suggests (for me) that this pins have some special function. You may try communication via pins 16 & 18 only, but with max 1200 baud. – Jacek Szumigaj Feb 10 '17 at 11:35
  • Ok.. Like you say, I tried communicating at 1200 only via 16 & 18 left the other two(15&17) unconnected. I get this error : MinimalModbus debug mode. Response from instrument: '' () (0 bytes), roundtrip time: 5001.0 ms. Timeout setting: 5000.0 ms. raise IOError('No communication with the instrument (no answer)') IOError: No communication with the instrument (no answer) – MMR Feb 10 '17 at 12:50