First of all I'm new in codesys. My problem is converting values (which I will type on touchscreen) on array of bytes. I have Array of 6 bytes which include 3 parametrs. How can I convert values (word) into bytes? Unfortunately there is no FB for this converting. Please help. I use this for acyclic data in Profinet (wrrec FB).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
First of all I'm new in codesys. My problem is converting values (which I will type on touchscreen) on array of bytes. I have Array of 6 bytes which include 3 parametrs. How can I convert values (word) into bytes? Unfortunately there is no FB for this converting. Please help. I use this for acyclic data in Profinet (wrrec FB).
Easiest way to do this is to create a type like this :
Then in your program you can declare your variables like this :
Then it will automatically fill the array
my_var.abValue
with the corresponding bytes ! You can access those bytes the same way :Beware of the endianess of the value though, I don't remember if it's little endian or big endian...
By the way to create a new type you have to do : right-click on application --> Add Object --> DUT...
Hope this helps !
Related
Talk.ru: 1