0

I have a problem that might seem really easy for people used to working with serial interfaces, but it is the first time for me.

We want to automate our temperature-dependent probe station by using a temperature controller (CB100 / CB400 / CB500 / CB700 / CB900 series by RKC Instruments: https://www.rkcinst.co.jp/english/download-center/?dc_cat=15#). The controller is connected to a master Dell OptiPlex5060 small tower (https://www.dell.com/en-us/work/shop/desktops-all-in-one-pcs/optiplex-5060-small-form-factor/spd/optiplex-5060-desktop/cto01o5060sffus) running Windows 10 Pro (version 1903, build 18362.267) through a RS485 to USB adapter.

The device appears in device manager ('COM3' port), with hopefully the correct drivers installed (see this screenshot). Also, the device settings were matched between the controller and master computer to the following values (port settings in device manager):

  1. Baudrate = 9600;
  2. Bitsize = 8;
  3. Parity = None;
  4. Stop bits = 1

I think I got the device correctly connected by using the pymodbus library with the following code:

Connect to RS485 device - pymodbus

#Import useful modules
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
#For the first test, I manually read the configuration from the 
#the controller display and hard-code the values in the script.

d_port='COM3'                    #Device address

commspeed={}                #Communication speed
commspeed_table={
    '0':2400,
    '1':4800,
    '2':9600,
    '3':19200,
        }
commspeed['flag']='2'
commspeed['value']=commspeed_table[commspeed['flag']]

bitconf={}                  #Bit configuration
bitconf_table={
    '0':(8,'N',1),
    '1':(8,'N',2),
    '2':(7,'E',1),
    '3':(7,'E',2),
    '4':(7,'O',1),
    '5':(7,'O',2),
        }
bitconf['flag']='0'
bitconf['size'],bitconf['parity'],bitconf['stopbit']=\
bitconf_table[bitconf['flag']]

intime={}
intime['flag']='5'
intime['value']=round(int(intime['flag'])*1.666,0)

def main():
    modbus=ModbusClient(method='ascii',port='COM3',\
                        baudrate=commspeed['value'],stopbits=bitconf['stopbit'],\
                        bytesize=bitconf['size'],parity=bitconf['parity'],\
                        timeout=1)
    modbus.connect()

if __name__ == "__main__":
    main()

However, when I try to read it with this code (the address of the device is 001Hex):

r = modbus.read_holding_registers(0x0001,1)
print(r)

I get this error:

Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 5 bytes (1 received).

Could anyone help with suggesting where is the mistake? What is the minimal working code for making modbus work? Why it seems to be so difficult to find quick online resources?

Thank you very much, any help is highly appreciated!

Sir Fumi
  • 1
  • 1
  • 1
    `read_holding_registers` has 3 parameters; `read_holding_registers(address, count, unit)` and the `unit` parameter defaults to `0x00`? Perhaps you are reading from device with 'address' `0x00` instead? – Bosz Sep 20 '19 at 14:06
  • Hello @Bosz, thanks for taking the time to reply. I keep getting the same error even when adding unit=1 as argument of the function. – Sir Fumi Sep 23 '19 at 08:52
  • The documentation of the controller only mentions RTU (instead of ASCII) as _signal transmission mode_. – Bosz Sep 23 '19 at 20:31
  • @Bosz Where did you find it? I was using ASCII as mentioned here (https://www.rkcinst.co.jp/english/downlaods/8935/imcb03e5/, page 7 of the PDF, under "Communication Code") – Sir Fumi Sep 24 '19 at 11:12
  • MODBUS Communication Instruction Manual: http://www.turbo-control.com/wtbc1/store/F3/CB100,400,500,700,900_modbus-COM_(E).pdf – Bosz Sep 24 '19 at 11:42
  • @Bosz Thanks so much for all the help, but it was probably an hardware problem, as we could not get ANY response whatsoever from the slave. – Sir Fumi Oct 01 '19 at 08:34

1 Answers1

0

In such cases, it might be usefull to split the problem. Try an external software tester like https://www.schneider-electric.us/en/faqs/FA180037/. When your slave replies correctly, you will have a solid reference for debugging your code.Good luck.Regards

Guust-DSP
  • 1
  • 1
  • Thanks so much for all the help, but it was probably an hardware problem, as we could not get ANY response whatsoever from the slave. – Sir Fumi Oct 01 '19 at 08:34