Modbus Register read

E

Thread Starter

Erik

Hello,

I have spent weeks now trying to get a HMI with RS485 and modbus RTU get to work with a Cummins Genset with RS485 / Modbus RTU. I am getting dizzy from trying all the different settings. I cant get it to work, very frustrating. I hope someone here can help me with a simple push in the right direction..

here it comes:

Slave: Cummins Genset with Powercommand 1.2.
station id: 100
baud rate: 9600
data bits: unknown, no setting for that
stop bits: also unknown, no setting for that
parity: even

Master: Some hardware HMI with RS485 port.
station id: not important right? (because master)
baud rate: 9600
data bits: 8
stop bits: 1
parity: even.

- I checked the wiring, A+ B- to the correct pins,
- I don't use a termination resistor, cable length is a couple of meters

I want to read register 40010 from the genset:<pre>
properties:
addr: 40010
read / write: read
units: switch position
type: unsigned integer
notes: 0=off, 1=run, 2=auto

then the settings I set for the HMI:

station no: 100
type: 4x
addr: 9
mode: DEC
value: 0 to off
1 to run
2 to auto</pre>
I don't understand what I am doing wrong... you have to subtract the 40000 from the register address right? and subtract 1 because of the starting from 0? I also tried 10, 11 40010 nothing works...
 
My recommendation is to use a generic Modbus master, like Win-Tech's Modscan32 in order to be able to see reads from registers before and after the target register, to be able to see response messages that can tell you there's no connection or a time-out error, be able to make on-the-fly changes quickly.

Once you get a connection and read the value with a PC master, then start mucking around with your HMI because you know it works.

There's a slew of things that can go wrong with serial Modbus

1) RS-485 connection
Your designation A+, B- probably means you're working with 2 wire RS-485. There is no standard for which is (+) and which is (-), even when they're labeled. I've had 2 wire RS-485 from two different divisions of the same parent company label the lines the opposite of one another.

Hooking the lines up backwards doesn't damage the drivers, but communications won't work. Try reversing the connection at one end.

I typically skip the terminating resistor on the bench, too.

2) addressing:
The leading 4 in a 4xxxx register just means that the data is in a holding register which is addressed by the 03 function code (command). The leading 4 is NOT part of the address in a Modbus message, only the value following the leading 4.

Some Modbus masters want a leading 4 when addresses are entered, others do not. Modscan32 does not want the leading 4, it only wants the remaining address as decimal characters.

Some masters do decimal addressing, others hexadecimal.

3) Protocol
Modscan32 can connect as either using Modbus RTU or Modbus ASCII protocol. If the genset documentation does not say it's Modbus, it might not be. Lots of protocols run on RS-485 that are not Modbus. 7 bit is ASCII, but I'm guessing that 97% of industrial devices are RTU at 8 bit data words.

4) Type?
You mention "type" being 4x. I don't know what a type is. Could it be a function code, like 03 for read holding registers?

5) serial
The serial line is RS-485. If you use a PC to test, you'll need a USB-RS-485 converter. Converters install on virtual COM ports, shown in Device Manager under ports.

6) All those PC Modbus masters have to accomplish the same tasks:
- connection on a given COM port
- baud rate, etc.
- what is the slave node number or Device ID: in your case station ID is 100
- Which command (Modbus Point Type): 03 Holding Register
- Address: I'd start at 0001 and read 14 registers as integers and see what shows up.
 
Company called MONICO makes a Cummins "data communications gateway" Check their website. If this gateway is similar to their CDL gateway for Cat Engine bus data then your job can be made a lot easier. The gateway gathers, scales, formats and tags all available data points off the bus and presents it as Modbus registers for either serial or Ethernet comms.

We have had great success using the Cat CDL gateway. For the cost of the box you can save more due to less time to implement. Their tech support is also excellent.
 
Ok,

1. I did try this

2. I will experiment further with the function codes and the leading 4. There is a option to select wether it has to do decimal or hexadecimal..So I can chose... most of the time I did decimal...

3. The brief documentation there is says: Modbus RTU

4. yes, the 4x being function code 03, exactly, I figured out that part, although being confusing.

5. Because of the short time I have left completing this system I cannot order this and wait for it, but thanks for the advice. Should have been better when I had this testing gear first.

6. Node number of the slave is: 100

So... the very last sentence of your reply... does that mean I have to put in: 0001 instead of 1? So I have to enter the leading zeroes also?

thanks
E
 
Hello,

Try use Modbus Scanner from www.modbus.pl.

You can set different com settings, addresses, ranges and check how the slave is configured.

Regards,
Andrzej
 
Top