Does the device have an error when it doesn't read the device?
You should not have to set the cycle time of the task based on baud rate, the serial port and other fieldbus's execute outside the task cycle times. However if you have timing requirements for that code reader if you are for instance sending a sequence of data might require you to have quicker cycle times. A good rule of thumb would be 3x faster than what is required to ensure consistant results. At least that's what it is when on the receiving side.
When you say "How the Serial COM library knows whether some data bits are missed or not?" do you mean when you change the value of a variable does the serial com library finish transmitting the old value or does it suddenly change to transmitting the new value if it's currently transmitting that variable? Did I understand that right or am I off base? I don't know the answer.
When I've done similar things but over modbus RTU I've always transmitted the same thing until I can read that the register has changed or read something else that indicates it has been received. Looking at you Lenze with your unlock controls register that you don't allow to be read that puts the drives communication into fault and don't have any register I can read that tells me drive controls are unlocked. ΰ² _ΰ²
If all else fails you, you might need to use asynchronous communication or asynchronous tasks... which I only know about from reading about. Or pay for a service ticket to talk to Codesys Support.
π
1
Last edit: Morberis 2020-12-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am trying to implement a serial communication.
Currently I try to adapt the Serial COM with Visualization project.
It works fine except sometimes the device (Cognex hand-held wireless code reader) doesn't get the command thus I have to send it twice or more times.
Is it possible to improve the reliability of the communication?
Thanks for your help in advance.
more posts ...
How should I set up for instance the cycle time of the IEC task i.e. based on baud rate?
Is there some guide some where?
How the Serial COM library knows whether some data bits are missed or not?
Thanks in advance!
Does the device have an error when it doesn't read the device?
You should not have to set the cycle time of the task based on baud rate, the serial port and other fieldbus's execute outside the task cycle times. However if you have timing requirements for that code reader if you are for instance sending a sequence of data might require you to have quicker cycle times. A good rule of thumb would be 3x faster than what is required to ensure consistant results. At least that's what it is when on the receiving side.
When you say "How the Serial COM library knows whether some data bits are missed or not?" do you mean when you change the value of a variable does the serial com library finish transmitting the old value or does it suddenly change to transmitting the new value if it's currently transmitting that variable? Did I understand that right or am I off base? I don't know the answer.
When I've done similar things but over modbus RTU I've always transmitted the same thing until I can read that the register has changed or read something else that indicates it has been received. Looking at you Lenze with your unlock controls register that you don't allow to be read that puts the drives communication into fault and don't have any register I can read that tells me drive controls are unlocked. ΰ² _ΰ²
If all else fails you, you might need to use asynchronous communication or asynchronous tasks... which I only know about from reading about. Or pay for a service ticket to talk to Codesys Support.
Last edit: Morberis 2020-12-09
Hi Morberis,
I really appreciate your help.
Actually I have dropped handwriting the serial communication and moved to Modbus π
Glad you found a solution (οΌΎοΌΎ)ο½