Most of the time, the parity can be changed for the serial port in a Gateway, but sometimes it is required to change the parity of a Modbus RTU device directly.
We will use the software "modpoll" for this purpose, available for Windows and Linux.
In this example we are changing the parity of a WTSC 485 (Wiegand To RS-485 Serial Converter - Link) on a Linux system. |
We will now have to check the manual of the W2SC to see, what kind of register structure the device has
Register | Type | Value |
---|---|---|
2000 | Slave ID | 42 |
2001 | Modbus mode | 1 = ASCI 2 = RTU |
2002 | Parity | 1 = None 2 = Odd 3 = Even (default) |
2003 | Baud rate | default 9600 Baud |
2005 | Command register | 0x42 = write configuration to EEPROM 0x24 = reset the device |
As in the documentation described, changing the parity requires the using the register 2002
First we read from the device using the following command
root@ubuntu:/# modpoll -a 42 -b 9600 -d 8 -p even -s 1 -t 4 -0 -r 2002 -c 1 /dev/ttyUSB0 modpoll 3.4 - FieldTalk(tm) Modbus(R) Master Simulator Copyright (c) 2002-2013 proconX Pty Ltd Visit http://www.modbusdriver.com for Modbus libraries and tools. Protocol configuration: Modbus RTU Slave configuration...: address = 42, start reference = 2002 (PDU), count = 1 Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table -- Polling slave... (Ctrl-C to stop) [2002]: 3 |
The device is thus correctly set in parity even, now we will change it to parity none, by adding a 1 to the command line used previously
root@ubuntu:/# modpoll -a 42 -b 9600 -d 8 -p even -s 1 -t 4 -0 -r 2002 -c 1 /dev/ttyUSB0 1 . . . Protocol configuration: Modbus RTU Slave configuration...: address = 42, start reference = 2002 (PDU), count = 1 Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table Written 1 reference. |
To write the changes to the device, we need to use the register 2005
root@ubuntu:/# modpoll -a 42 -b 9600 -d 8 -p even -s 1 -t 4 -0 -r 2005 -c 1 /dev/ttyUSB0 0x42 . . . Protocol configuration: Modbus RTU Slave configuration...: address = 42, start reference = 2002 (PDU), count = 1 Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table Written 1 reference. |
And finally we will reboot the device, for the changes to take effect
root@ubuntu:/# modpoll -a 42 -b 9600 -d 8 -p even -s 1 -t 4 -0 -r 2005 -c 1 /dev/ttyUSB0 0x24 . . . Protocol configuration: Modbus RTU Slave configuration...: address = 42, start reference = 2002 (PDU), count = 1 Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table Written 1 reference. |
Now we can check if the changes were done correctly
root@ubuntu:/# modpoll -a 42 -b 9600 -d 8 -p none -s 1 -t 4 -0 -r 2002 -c 1 /dev/ttyUSB0 . . . Protocol configuration: Modbus RTU Slave configuration...: address = 42, start reference = 2002 (PDU), count = 1 Communication.........: /dev/ttyUSB0, 9600, 8, 1, even, t/o 1.00 s, poll rate 1000 ms Data type.............: 16-bit register, output (holding) register table -- Polling slave... (Ctrl-C to stop) [2002]: 1 |
Use the modpoll help for more information regarding the commands available. Here in this example we've used the following -a : slave address; -b : baud rate; -d : databits; -p : parity; -s : stopbits; -t : register data type; -0 : PDU addressing; -r : reference; -c : number of values to read
|
Downloadlink for Modpoll |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|