Mervis and RS485
I've managed to create a python script to interact with a power meter using RS485. I can't seem to find how to configure the protocol used in the RS485 communication in Mervis. Can someone point me to some resources where i can learn how to do this?
Thanks in advance
I found this on Google:
"To connect your computer to the RS485 bus, a serial port is required. There are direct USB-to-RS485 converters, but I use a USB-to-RS232 converter together with an industrial RS232-to-RS485 converter (Westermo MDW-45). This has the advantage that the latter is galvanically isolated using opto-couplers, and has transient supression." here: https://pypi.python.org/pypi/MinimalModbus/0.6
Hope this help!
Giamba, Unipi Mervis user
Thanks for the reply. While reading your reply i've noticed i forgot to mention that i'm using a Unipi Neuron L203 which has a RS-485 built in sorry about that :s
If i understood correctly o should present the device i'm reading data from (using my python script) to the modbus server? So that mervis then can read from it?
I don't have a neuron but an unipi, but what I'm doing to read values from TCP is the same
I think your power metter will be the server, and your PLC the client. So you have to create a channel with the modbus protocol, set the good port number. Then add a device to your new channel and start to map variables from the modbus communication.
When you are in debugging mode, you can watch what's happening in the communication of your new channel in "port monitor" and then paste the received hex value in http://modbus.rapidscada.net/ (thanks to @tomas_hora) to view how to match variables. (values are interger).
By dblClicking on your new device, you can add a read or write group and then set variables to map.
Hope this help.
tomas_hora administrators last edited by
@Giamba is partially right. There is one issue with the serial interface right now which causes that users are unable to set parity and data bits using the channel/device properties. You have to set it there too, but also in UART_config, everything described in the step by step guide https://files.unipi.technology/s/public?path=%2FSoftware%2FMervis%2FDocumentation#pdfviewer
Hi @Giamba and @tomas_hora,
Thank you both.
With both of your inputs i can now understand how to do it. I've overlooked that document, didn't noticed the part of the RS485/Modbus.
With a little bit of trial and error and some reading i finally manage to fully understand what both of you were saying, thanks again :)
In order to help people in the future I'll leave the required steps in order to read data in Mervis from a IME Conto D2 using the RS-485 on a Unipi:
- Set the IME meter communication parameters to 19200 baud rate, 8N1
- Read 2.8.3 from https://files.unipi.technology/s/public/download?path=%2FSoftware%2FMervis%2FDocumentation&files=Mervis Step-by-Step Manual.pdf as mentioned by @tomas_hora
- Set the UART_config initial value to 14 (Check the Mervis step by step manual in order to understand why)
- Create a Modbus channel and set:
- Link Protocol to Serial
- Integration mode to True
- Max. Telegram Duration 125ms
- Max. Telegram Duration (Commissioning) 500ms
- Port Number Modbus.Neuron.XXXX:RS485
- Baud rate 19200
- Data Bits 8
- Parity None
- Stop Bits One
- Create a Device in the newly created channel
- Set the Device Address in the Modbus device parameters (this should be set to the same address as the one set in the meter, in my case address 1)
- Create a new group in the newly created device
- Set the following parameters in the Modbus Group Parameters
- Starting Element to 8193 (should be 8192 which is 0x2000 in hex but Mervis some how sends 0x1FFFF maybe some bug?)
- Function to F03 Read Holding Register
- Number of elements to 16
- After this you have to map the variables according to http://www.imeitaly.com/protocolli/PR121.pdf, as example i'll leave how to do it for the voltage
- Add I/O
- For the new IO set:
- Group to the group you've created earlier
- Comm. Value Mapped Type - Builtin
- ST Type - dword
- Transform - Linear
- Parameter K - 0.001
- Data Offset - 0
- MultiByte length - 4
- MultiByte Order - 1234
- For the other parameters just check the previous document and change the Data Offset and MultiByte length accordingly.
If you run into trouble check the @Giamba last post, use Port Monitor in debug mode to check whats wrong.