How to check modbus comunication

Topics about the Hardware of Revolution Pi
francescoizzi
Posts: 18
Joined: 17 Feb 2018, 12:10

How to check modbus comunication

Post by francescoizzi »

Hi all,

i'm starting with revolution pi trining to connect the RevolutionPI3 with USB-RS485 to BTICINO F3N3000 Energy Meter (that have ModBus RS_485).

I configured in PiCtory all things... but i have alway 0 into the process image for all my variable.

I saw into the logs this:

[73564.385133] piControl: piIoComm_sendRS485Tel(GetDeviceInfo) failed 2
[73564.505129] piControl: piIoComm_sendRS485Tel(GetDeviceInfo) failed 2
[73564.625143] piControl: piIoComm_sendRS485Tel(GetDeviceInfo) failed 2
[73564.745134] piControl: piIoComm_sendRS485Tel(GetDeviceInfo) failed 2

But I not found a way to check if ModBus connection is enstabilished.

I attach my connection images.

Thanks in advance.
Attachments
WhatsApp Image 2018-02-17 at 11.42.49.jpeg
WhatsApp Image 2018-02-17 at 11.42.49.jpeg (191.53 KiB) Viewed 11099 times
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: How to check modbus comunication

Post by volker »

PLease let me know more detials---
Who is master, who is slave?
What is the content of the Modbus status bytes in the process image (use piTest to read them)?
You could also use a freeware Modbus master / slave Windows software instead of your meter - just to be sure you have a communication partner with clear defined Modbus registers and Modbus telegramms (in case of master).
And b.t.w.: You hook up is not really the best. RS485 is a symmetric signal bus and thus you get best results when using a twisted pair as signal path. You used twisted wires but in the wrong way: one pair for A and one pair for B. You better use one wire of a pair for A and the other wire for B terminal. And please make sure you do not twist the terminals: A mus be connected to A and B must be connected to B (better: positive to positive and negative to negative terminal).
Unser RevPi Motto: Don't just claim it - make it!
francescoizzi
Posts: 18
Joined: 17 Feb 2018, 12:10

Re: How to check modbus comunication

Post by francescoizzi »

Hi Wolker

thank for fast reply.

The Master is RevolutionPICore3 with ModBus RTU Master Virtual Device Configured. The Slave is my meter BTicino F3N3000 as you can see in my preview post.

I wrote a test Class in Python that read the process image but i try it also with some piTest command.

Yes i can try with some other RS_Slave software simulation.

Do you think that the twisted cable are the problem?

My test want to stream the meter (slave) data into elasticsearch (search engine), every 10 seconds i request from Revolution Pi Core3 all the registry that i need and write is into elasticsearch.

I hope that its more clear now...

I see a bit the code at

RevPiDevice.c#L239
#ifdef DEBUG_DEVICE
pr_err("piIoComm_sendRS485Tel(GetDeviceInfo) failed %d\n", ret_l);
#endif
Attachments
WhatsApp Image 2018-02-17 at 11.42.48.jpeg
WhatsApp Image 2018-02-17 at 11.42.48.jpeg (226.73 KiB) Viewed 11094 times
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: How to check modbus comunication

Post by volker »

Okay. The twisted pair should not be the reason for a missing connection. But you must be sure that you have not mixed up the A and B wires.
With your configuration you also check the following settings to be correct:
1) Have you entered the correct serial port name in PiCtory value editor for your USB to RS485 device? Check the name under Linux by looking into the /dev folder.
2) Have you entered th correct commands in PiCtory extended data editor to set up at least one reading command to poll the meter?
3) Have you used the correct Modbus address of the slave (meter) in your extended data command line?
4) Have you experimented with the register addresses? The addresses often get mixed up (some systems are starting with 0, others with 1 - some systems are using prefixes for different modbus areas which are not part of the modbus adress and must not be entered in the PiCtory's Register address field).
Unser RevPi Motto: Don't just claim it - make it!
francescoizzi
Posts: 18
Joined: 17 Feb 2018, 12:10

Re: How to check modbus comunication

Post by francescoizzi »

Hi Volker,

regarding the connection (i dont realy unrdestand your "not mixed up the A and B wires") i think that is fine but to be more precise tomorrow i will check better the wires and the connection in general... also changing the wire with a different one.

1) i think that the parameter are correct ... i attached some image and this is my usb attached devie: "pi@RevPi4067:~ $ ls /dev/ttyUSB0"
/dev/ttyUSB0

3.png
3.png (23.3 KiB) Viewed 11079 times
2) Also for register configuration i start with the first register that i need to read. (also here i attached an image)

3) I personally configured the slave (F3N3000) address to "1"
The attachment 3.png is no longer available
4) I dont know at the moment if BTicino have a particular prefix to insert.

... Tomorrow i continue my test ...

Many thanks for support!
Attachments
2.png
2.png (17.4 KiB) Viewed 11079 times
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: How to check modbus comunication

Post by volker »

Okay, that seems to look all fine. I try to sum up:
You are running the RevPi virtual Module Modbus RTU.
It uses the USB to RS485 Converter which installs as /dev/ttyUSB0 under Debian
You have configured the virtual module's values to device path /dev/ttyUSB0 with serial parameters set to 9600/N/1/8
A wire pair goes from the USB-RS485 device to your meter's RS485 connector (BTicino F3N3000 is Modbus slave).
You have configured at least one task under extended configuration which is:
"polling slave with address 1 every second by sending a "Read Input Registers" function code to read Modbus registers 2 and 3 and write the result in the process image at offset named "Corrente _F1"
The slave device is set to address 1
We assume that:
a) you connected the A terminal of the USB-485 device to the A terminal of the slave and the B terminal of the USB-485 device to the B terminal of the slave (better: D+ to D+ and D- to D-, some manufactures name the D+ terminal A and others do name it B!!!)
b) you have set the serial parameters of the slave to 9600/N/1/8
c) BTicino F3N3000 accepts Modbus function code "Read Input Registers" for Registers 2 and 3
d) you have enabled the Modbus master service on the RevPi's web-status page (tab "services")

I now would like to know the result of
piTest -r Modbus_Master_Status
and
piTest -r Modbus_Action_Status_1
and
piTest -r Corrente_F1

The Master_Status should be 0 if the connection is established and the Action_Status should be 0 if the slave answered to the Modbus function call of the master. If there is content in the Modbus registers you should see the content as answer of the piTest -r Corrnete_F1 command (better look also into the next word because you have used 4 bytes for the read function on Modbus).

The content of the Status registers will tell us if the connection is good or not.
Unser RevPi Motto: Don't just claim it - make it!
francescoizzi
Posts: 18
Joined: 17 Feb 2018, 12:10

Re: How to check modbus comunication

Post by francescoizzi »

Schermata 2018-02-19 alle 08.33.00.png
Schermata 2018-02-19 alle 08.33.00.png (58.74 KiB) Viewed 11069 times
Ok i take i screenshot for you before going to work.

It's seam that the slave respond to "1".

I'll write after that i change cable and i re-check all ...after your indication.
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: How to check modbus comunication

Post by volker »

This output shows us that you could successfully establish a connection to the slave. But when sending the Modbus function code for "Read Input registers" to address 2 and 3 the slave responded with an error code "illegal function code". Therefore you should study the Modbus implementation of the slave. It may be that they count the registers from 0 and not from 1 and therefore you need to use register 3 instead of 2. It could also be that the slave does not support a "read Input register" function call.
Unser RevPi Motto: Don't just claim it - make it!
francescoizzi
Posts: 18
Joined: 17 Feb 2018, 12:10

Re: How to check modbus comunication

Post by francescoizzi »

From BTicino Manual i read this:
Schermata 2018-02-19 alle 10.38.59.png
Schermata 2018-02-19 alle 10.38.59.png (206.68 KiB) Viewed 11061 times
Now I'll will try to change registers.
francescoizzi
Posts: 18
Joined: 17 Feb 2018, 12:10

Re: How to check modbus comunication

Post by francescoizzi »

And here the table of registers that i need to read:
Schermata 2018-02-19 alle 10.41.16.png
Schermata 2018-02-19 alle 10.41.16.png (171.34 KiB) Viewed 11061 times
Post Reply