russedwards Posted February 20 Report Posted February 20 Hello. I am having trouble with the MODBUS read / write. I have an empty project uploaded to the PLC, and to test communications between the PLC and my pressure controller, I have simply setup MODBUS 485 Master to communicate. I have setup the PLC to communicate with the controller and MODBUS link is successful. I am reading the pressure successfully from the controller on address 1203. The pressure is sent to the PLC without problems. I am trying to write the setpoint from the PLC back to the controller on address 1010 but this does not seem to work. I have setup a Registers Periodic operation to write to address 1010 but it does not work. Please could you advise what I am doing incorrectly? I have attached links to the Alicat documentation detailing the MODBUS settings of the controller: https://www.alicat.com/wp-content/documents/manuals/ModbusRTU_Manual.pdf\"]https://www.alicat.com/wp-content/documents/manuals/ModbusRTU_Manual.pdf https://www.alicat.com/wp-content/documents/manuals/DOC-MANUAL-MPL.pdf?_gl=1\"]https://www.alicat.com/wp-content/documents/manuals/DOC-MANUAL-MPL.pdf?_gl=1*jlekf*_gcl_au*MjAxNDI3NDk1NC4xNzA2MTE0MDQ0
ORSO2001 Posted February 20 Report Posted February 20 hi @russedwards what error code return the modbus master struct?
russedwards Posted February 21 Author Report Posted February 21 Hello I am receiving an error code 3 when I include the write tags. When I delete the write tags and read only, everything works as expected.
ORSO2001 Posted February 21 Report Posted February 21 hi @russedwards error code 3 means "illegal data value"...description from the web: A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register. so...when you read the register what you have as value ?...did you try send exactly the same value to check if it is valid?
Gabriel Franco Posted February 22 Report Posted February 22 According to the Alicat manual, "The device setpoint should be sent as a 32-bit IEEE floating point value. Setpoint values must be sent together in a Write Multiple Registers command. Any writes to only one half of the setpoint value will cause an error. Setpoint is ignored on devices without a controller". Are you fulfilling this requirement?
pascal Posted February 23 Report Posted February 23 Gabriel, when you carefully read the alicat manual, you must send 2 modbus commands to set the setpoint... you must send the first 2 bytes to adress 1010 and the second 2 bytes to adress 1011... (i think) (taking care of big or little endian) so you can not send a real, but 2 int16 variables ! so you have to split your real into 2 int16 variables
russedwards Posted February 26 Author Report Posted February 26 This is how I have my RS485 ladder setup. I have tried as suggested splitting my setpoint between 2 x INT16 value to write to 1010 and 1011 but I still get noting on the pressure controller. Pressure from the controller is being read correctly as a REAL value
MVP 2023 Ausman Posted February 26 MVP 2023 Report Posted February 26 It's time to do the send with the PC, and find what is the correct way of doing it with the innately much easier method. cheers, Aus
pascal Posted February 27 Report Posted February 27 have you tried to do it with aperiodic sending ? I don't know if the periodic sending is done on how you program your modbus thing. If you program a aperiodic, then you send your group in 1 command. but like ausman said -> maybe a good idea to send it with a pc software
MVP 2023 Ausman Posted February 28 MVP 2023 Report Posted February 28 And I also agree with Gabriel's interpretation. "together in a Write Multiple Registers command" However, I do find this manual a bit confusing, given I can't find setpoint setting in any of these commands : Commands can be issued to the Alicat device using Modbus register1000. Commands are described in the table below. Some commands require a parameter to be passed in Command Argument register 1001 using the “Write Multiple Registers” Modbus function code. But then we also get to the legacy stuff at the end, so perhaps you should be trying register 24. Look in 2.1 So with all this confusing info, I still reckon your easiest avenue at present is using the PC. I always start with a new device on the PC, and often find contrary things which take some time to figure out, along with other registers which have no reference in the manual but actually contain useful stuff. It can be a "fun" game stepping through registers as a first try at a block of 10 and see if it reads ok, or then go to one by one. cheers, Aus
HansCZ Posted February 29 Report Posted February 29 But according to your printscreen you do not send multipleregisters. In fact you are trying to send each 100 ms to one value to 1010 and to 1011. I think in fact you each 100 ms queue modbus function 0x10 for 1010 and then for 1011. If I perform function 0x10 in UniLogic I define an array. In your case it should be array of size 2 of INT16 say asetpoint[0..1]. Then asetpoint[0] is int16 value for 1010, asetpoint[1] is int16 value for 1011 In modbus section then each 100 ms 0x10 or 16dec (Write multiple registers), address 1010, tag simply asetpoint. If UniLogic offers you to select particular value like asetpoint[asetpoint_0] when typing in, just delete it. In the column address ther should be asetpoint only. This causes asetpoint[asetpoint_0] will be written into 1010 and asetpoint[asetpoint_1] to 1011 matching the requirements of pressure transmitter the setpoint values are transfered together. Hope it helps. Jan
russedwards Posted February 29 Author Report Posted February 29 Hello everyone and thanks for your help. After connecting my device to my laptop, I finally managed to write the setpoint of the controller using the legacy addresses. Periodic read and write worked fine.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now