Connecting/communicating with a Modbus device
-
Hi,
Me again; things are working out great and I'm very happy with the Unipi Neuron, so I keep on exploring more about it's functionality (and that of Codesys).
Next challenge, connect/communicate with a Modbus device. I'm trying to connect a CO2 sensor, which allows Modbus communication (I can also use analog output, but I have to connect multiple and then Modbus seems like a good solution).
Can someone point me in the right direction?
This is the datasheet/manual of the sensor: Manual
- Setting: Baudrate: 19200 // Stopbit: One // Parity: Even // Address: to be decided (5 dip-switches to set)
Modbus Map
I've already added the Modbus_COM and Modbus_Serial_Device, but no I have no idea on how to make the "link" with the Modbus Map.
Eternal thanks for all your help :)
-
Hi Oliver,
There is an example of using serial modbus in the Neuron demo application.
Please also have a look at the data sheet regarding installation and serial ports. To be able to use the serial port on a Neuron from CODESYS a one time configuration change is required. If you run the demo application it will make the required change, the data sheet includes details on functions that can be used to configure the serial port.
Please ask if you need more help with this.
-
OK, so I successfully ran the demo on the Unipi, so that means the the configuration is done? I can just leave the RS485 on "disabled? I don't need to include anything in my program for the RS485 to be "enabled", besides of course the added modbus device.
As there are 2 ports, A and B, do I need to make any specific changes when adding a "device"? Or is it enough the set the address on the slave device and Codesys?
And I found the proper way to add the registers, so I'll give it a try tomorrow.
-
Hi Oliver,
You need a modbus com device for each port you wish to use. Then under those a modbus master device, and then a modbus slave for each slave connected to that port.
The modbus com port needs to be set to com 1 for the first port, 2 for the second..,
So if your slave devices operate with the same serial port settings you could use different modbus addresses for each and connect them to the same port, or put one on each port.
-
Ok, today I finally had some time to test this.
So I connected my device (as described above) and I receive the following message: "Modbus not running (or something similar)".
Any ideas on how I can debug/fix this?
Thank you.
-
Hi Oliver,
I’m going to need more detail to be able to help?
What does your configuration look like?
What exactly is the error message and where do you see it?How is the physical device connected and configured?
Is anything sent from the port?
Are there any further device diagnostics?
Unfortunately with all serial communications, including modbus, just one configuration error or wiring error on the master or slave will mean the communications doesn’t work. The process to solve this is really to carefully check every step.
If I was debugging your system, I would first extract as much detail on the error as possible to see if that helps.
Try answering these questions.
Does the master send a modbus request?
Is it at the right baud rate, parity etc?
Does the slave see the request?
Do it’s comms settings match?Is the UID correct?
...