MODBUS-RTU over RS232 IDs

Started by Roy Emmerich, October 13, 2013, 07:37:41 PM

Previous topic - Next topic

Roy Emmerich

Hello Midnite folk,

I received my classic lite a week ago. My aim is to communicate with the device via MODBUS-RTU over RS232. I am using Linux and have installed the modpoll simulator (http://www.focus-sw.com/fieldtalk/modpoll.html) for initial testing purposes. MODBUS-RTU over TCP was as easy as pie with the following command:

modpoll -r 4115 -m tcp 192.168.1.223

and here are all the default settings that the tool spits out in my terminal:

Protocol configuration: MODBUS/TCP
Slave configuration...: address = 1, start reference = 4115, count = 1
Communication.........: 192.168.1.223, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

And data is returned reliably.

Upon trying to do the same thing via RS232 I'm not having much success. My first question is regarding the slave ID of the classic lite. I can't find any information about what the default ID is. After trawling through all the
manuals, youtube videos and the forum, I came across the following in the section titled "Addressing the Classics" on pages 17 and 18 of classicManual.pdf:

"The normal default address is 10"

I take it the MNGP uses MODBUS-RTU over RS232 and that the address referred to above is the MODBUS ID? If not, what ID should I use (can I change this without a MNGP)?

I have tried the following modpoll command on my Linux box to get the battery voltage (register 4115) but I keep getting timeouts:

modpoll -a 10 -r 4115 -m rtu /dev/ttyS0

As above, here are the settings being used to communicate:

Protocol configuration: Modbus RTU
Slave configuration...: address = 10, start reference = 4115, count = 1
Communication.........: /dev/ttyS0, 19200, 8, 1, even, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

I have also tried both the master/in and slave/out ports as described on last page of the manual and register map documents, just in case I got the Rx/Tx connections to my MAX232 chip mixed up but still no joy.

I would really appreciate your help at this stage! :D

Thanks
Roy
In the process of starting up an open source data logging company
www.infinitefingers.com

TomW

As far as I know the registers are simply dumped to the serial port. There is an interactive mode but mostly for downloading the logs (I think). There are several modes of serial data formats. There is a thread here someplace where this was discussed. I did a post or two on the serial data collection.

No time to search it out right now as I am in firewood tunnel vision mode here.

RossW has a TCP based application he wrote that reads and writes registers for Linux on X86, ARM and OS X. Perhaps he will post a link to the binaries. Zoneblue also is working with modbus and Linux over TCP.

Look for a thread called "Black Box Project" started by me. Lots of info in that, too.

Good luck with it.

Tom
Do NOT mistake me for any kind of "expert".

( ͡° ͜ʖ ͡°)


24 Trina 310 watt modules, SMA SunnyBoy 7.7 KW Grid Tie inverter.

I thought that they were angels, but much to my surprise, We climbed aboard their starship and headed for the skies

boB


Roy, it sounds like you have your information correct.  I have used modpol but haven't used it
over the RS-232 line, only TCP/IP over the Ethernet.  BUT it should work I would think.

Assuming you have the modpol command line correct, it should read some data and
not time out.  You can also use ID (address) 255  which is non-standard but 255
is a catch all in case the Classic's address has changed.  But 10 is the default.
Try 255 just in case though.

The MNGP remote talks to the Classic at 5 times per second.  Can't remember what
the Classic Lite's MNLP remote talks at.  You should be able to go quite a bit faster
though.

All 3 phone jacks should work except that the bottom jack, (master), is reversed
from the top 2 jacks.  I gather you found the pin-out drawing.

boB
K7IQ 🌛  He/She/Me

Roy Emmerich

Bob and Tom thanks so much for your responses so far.

As stated earlier, Modbus RTU over TCP is working fine. However I would like to get Modbus RTU over RS232 going but am not having much luck yet.

This evening I did the following:

1. Double checked the serial port on my computer is working by doing a loopback test.
2. Double and triple checked all the pinout diagrams and my connections (continuity tests) and all seem to be fine. I have attached an image showing how I connected my PC to the Classic Lite's master/in RJ11 jack.
3. Tried various modpoll command options, fiddling around with parity (odd, even, none) and address 255 as advised by Bob.

Here is my command:

modpoll -t 4 -b 19200 -d 8 -s 1 -p even -a 255 -r 4115 -m rtu /dev/ttyS0

which translates to:

-t 4 = 16-bit output (holding) register data type (is the default and works in the TCP version of this command)
-b 19200 = baud rate
-d 8 = 8 databits
-s 1 = 1 stopbit
-p even = even parity (also tried odd and none)
-a 255 = classic modbus ID (or address as they confusingly refer to it as, hence the -a)
-r 4115 = dispavgVbatt register
-m rtu = Modbus RTU protocol

Bob, any idea what the parity and number of stopbits should be for the RS232 connection?

I'm at a loss right now so would really appreciate it if somebody could glance over my diagram and see whether you can spot the (obvious?) error.

Many thanks
Roy
In the process of starting up an open source data logging company
www.infinitefingers.com

boB

Roy, no parity and 1 stop bit.


N81   as they say
K7IQ 🌛  He/She/Me

atop8918

One thing we noticed in the lab  when testing the RS-232 MODBUS was that our USB-to-RS232 converters were BUNK. The first ones we used did not properly convert the signal levels from PC to RS-232 so that the comms did not work.

If you're using a USB-232 converter, you may want to check that the signal levels leaving the converter is correct. I seem to remember that the Prolific ones we used first did not properly convert to negative levels so that either marks or spaces were at ground instead of -6/-12.

If all the hardware is correct then the next stage are the settings. The Classic uses

19200 8-n-1 (19200 baud, 8 nits, no parity, 1-stop bit)

The default address for the Classic is 10 but 255 will _definitely_ work if you are connected directly to the unit.

Just as a sanity check, and if you haven't already, I'd wire up an o-scope and make sure that you are actually seeing data on the TX pin from the PC.


mtdoc

Quote from: atop8918 on October 16, 2013, 09:38:54 AM
The Classic uses

19200 8-n-1 (19200 baud, 8 nits, no parity, 1-stop bit)


8 nits huh -  you guys really ought to do something about that. Lice can't be good for electronics.. ;D


...sorry - couldn't resist...
Array 1: Sanyo HIT225 X 8 on Wattsun tracker. Array 2: Evergreen ES-E-225 X 12 on shed roof. Midnite e-panel with Outback GVFX3648, FNDC and Classic 150 X 2. 436 AH AGMs. Honda eu2000i X 2.

boB

#7
Quote from: mtdoc on October 16, 2013, 02:08:07 PM
Quote from: atop8918 on October 16, 2013, 09:38:54 AM
The Classic uses

19200 8-n-1 (19200 baud, 8 nits, no parity, 1-stop bit)


8 nits huh -  you guys really ought to do something about that. Lice can't be good for electronics.. ;D


...sorry - couldn't resist...


We are very "Nit" picky around here !

Or is that Bit picky ?
K7IQ 🌛  He/She/Me

TomW

Quote from: mtdoc on October 16, 2013, 02:08:07 PM

8 nits huh -  you guys really ought to do something about that. Lice can't be good for electronics.. ;D


...sorry - couldn't resist...

mtdoc,

Now that is nit picking at its finest!

I couldn't resist, either. :o

Tom
Do NOT mistake me for any kind of "expert".

( ͡° ͜ʖ ͡°)


24 Trina 310 watt modules, SMA SunnyBoy 7.7 KW Grid Tie inverter.

I thought that they were angels, but much to my surprise, We climbed aboard their starship and headed for the skies

Roy Emmerich

#9
Okay! This was a good excuse to purchase an oscilloscope for home. It has taken a little while to unwrap it and figure out what goes where. This evening I did a bit of testing resulting in a few unanswered questions and some success!

Firstly I am using a 7 year old Dell Precision 390 desktop and it still has a built in serial port! I found a few weird things going on with it after prodding around with my oscilloscope so switched over to using a USB->RS232 converter.

Attached is a screenshot of what I measured on the Classic Lite master/in jack's Rx (input) line while disconnected. This is a completely unsolicited response. I'm confused as I wasn't expecting there to be any signal on this line except when responding to my request.

After much fiddling I just gave up on the master/in jack and decided to investigate the slave/out instead. I triple checked my connections and finally succeeded in retrieving register 4115 (dispavgVbatt) via RS232 using the following modpoll command:

modpoll -t 4 -b 19200 -d 8 -s 1 -p none -a 255 -r 4115 -m rtu /dev/ttyUSB0

I also managed to achieve the same thing via TCP using this command:

modpoll -r 4115 -m tcp 192.168.1.223

So despite what Bob said, it seems all three phone jacks were not created equal  :D
I'll be sticking to the slave/out for now while doing my Arduino development.

Regards
Roy
In the process of starting up an open source data logging company
www.infinitefingers.com