I have a Modbus TCP slave device where I need to do sequential writes to the same register.
The register I'm writing to is kind of like a command line, each packet is a command word encoded in Hexadecimal.
I am having difficulty implementing this system in CoDeSys 3.5 SP19. I feel like the structure of the program should be something along the lines of (Pseudocode):
Where "wMot1OPCode" is the IO map for writing to the command register, and "xMot1SendOP" is the rising edge trigger for that modbus channel.
However, this doesn't work. The device never responds to the modbus commands. It seems like the trigger variable is switched too quickly for modbus to send the packet.
I know the modbus register is working, because I can set the channel to cyclic and the device will respond. However, I can't use this reliably because I need each command to be sent once, in order. Cyclic keeps re-sending the commands and seems like it could miss a command as well if one was sent in-between cycle time.
Hello
You'll need to write a proper sequence to send, then wait for confirmation, and then move on to the next step.
Use the CASE statement in ST. It's perfect for creating a sequence.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a Modbus TCP slave device where I need to do sequential writes to the same register.
The register I'm writing to is kind of like a command line, each packet is a command word encoded in Hexadecimal.
I am having difficulty implementing this system in CoDeSys 3.5 SP19. I feel like the structure of the program should be something along the lines of (Pseudocode):
I have tried to implement this with a rising edge trigger
Where "wMot1OPCode" is the IO map for writing to the command register, and "xMot1SendOP" is the rising edge trigger for that modbus channel.
However, this doesn't work. The device never responds to the modbus commands. It seems like the trigger variable is switched too quickly for modbus to send the packet.
I know the modbus register is working, because I can set the channel to cyclic and the device will respond. However, I can't use this reliably because I need each command to be sent once, in order. Cyclic keeps re-sending the commands and seems like it could miss a command as well if one was sent in-between cycle time.
I have also trying using the Application trigger as described by https://faq.codesys.com/pages/viewpage.action?pageId=24510480, but this is also not working for me. See attached picture for my FBD code.
This seems like a simple function, I can't tell what I'm doing wrong here. Thanks for the help.
Hello
You'll need to write a proper sequence to send, then wait for confirmation, and then move on to the next step.
Use the CASE statement in ST. It's perfect for creating a sequence.