I'm a n00b to Codesys programming, so sorry in advance if my question is a bit stupid
This is probably not a dedicated V3-question, but since I'm working in V3.5 SP8 Patch 1 I guess I should post my question here anyway?!
I have searched the forum and on the internets without finding the correct information to let me continue with my program.
I'm reading a number (1-50) from a tag and now I want to take the binary version of that number and output it to 8 outputs (%QX1.0 to 1.7).
One of the problems is I don't know how to get the boolean values of each bit in the byte to transfer to the output module?
Any ideas?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Kallamamran hat geschrieben:
Hello,
I'm a n00b to Codesys programming, so sorry in advance if my question is a bit stupid
This is probably not a dedicated V3-question, but since I'm working in V3.5 SP8 Patch 1 I guess I should post my question here anyway?!
I have searched the forum and on the internets without finding the correct information to let me continue with my program.
I'm reading a number (1-50) from a tag and now I want to take the binary version of that number and output it to 8 outputs (%QX1.0 to 1.7).
One of the problems is I don't know how to get the boolean values of each bit in the byte to transfer to the output module?
Any ideas?
You can also declare individual variables for da bit
var1 at %ix1.1 :bool;
In this way you refer to individually bit
good luck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Declare a variable for each position (given we are speaking of inputs/outputs that you can address).
Create a pointer to an array of bools with the same bit length for that variable and point it to the variable itself.
** This last option can be improved if you put that inside a function, you declare the array without limits and pass the address and sizeof of the variable to be examined.
Hope this helps!
Happy new year...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've found another way to do this: you can add the library Util and it's EXTRACT function which allows you to use a variable to specify the position you want from a DWORD, WORD...
Good luck!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm a n00b to Codesys programming, so sorry in advance if my question is a bit stupid
This is probably not a dedicated V3-question, but since I'm working in V3.5 SP8 Patch 1 I guess I should post my question here anyway?!
I have searched the forum and on the internets without finding the correct information to let me continue with my program.
I'm reading a number (1-50) from a tag and now I want to take the binary version of that number and output it to 8 outputs (%QX1.0 to 1.7).
One of the problems is I don't know how to get the boolean values of each bit in the byte to transfer to the output module?
Any ideas?
It sounds like what you are looking for is on your outputs you would access the tag variable then add .<bitindex> after that variable.</bitindex>
QX1.0 := Tag.0;
......
QX1.7 := Tag.7;
Look under help "Programming Reference > Operands > Variables > Addressing bits in variables" to get maybe a better understanding.
You can also declare individual variables for da bit
var1 at %ix1.1 :bool;
In this way you refer to individually bit
good luck
Never a question is stupid.
You can do what is suggested before:
** This last option can be improved if you put that inside a function, you declare the array without limits and pass the address and sizeof of the variable to be examined.
Hope this helps!
Happy new year...
I've found another way to do this: you can add the library Util and it's EXTRACT function which allows you to use a variable to specify the position you want from a DWORD, WORD...
Good luck!