Hello everyone,
I'm new on Twincat and expert on Omron.
I'm trying to do on twincat some things that were easily possible to do on Omron, but on Twincat I don't know if I can do the same by a similar way.
On the examples, you don't need to be an expert on Omron because I explain the meaning of each code.
Let's go to the examples:
Example 1:
Please see this code on Omron:
[attachmentid=7329]
On this code, "condition" is of type BOOL.
When "condition" is TRUE, the MOV instruction moves the value 0 to the variable with name "variable".
"variable" is of type WORD, by the way it has 16 bits.
On Omron systems, each variable of type word have not only a name, but also a number. On this case, the variable with name "variable" is of WORD type an has the number 20.
Since the variable with the number 20 is of WORD type, and have 16 bits, I can consider the following bits:
20.00
20.01
20.02
20.03
...
...
20.14
20.15
If I need on my program 16 variables type bool, and if I want to reset all of them, I only need to move the value 0 to the correspondent word.
On Twincat, the only one way that I know to do the same is the following one:
[attachmentid=7330]
On this case, When the "condition" is TRUE, I make reset to all of the 16 bits (Bit_0; Bit_1; Bit_3 ... to Bit_15 are variables of type BOOL). But, to do that, I have to write the same code 16 times (Each time for each bit), because the Reset instruction resets only one bit.
My question is:
Is there a diferent way on Twincat to reset all the bits at the same time? I think it could mabe be possible, using the MOV instruction, to move the value 0 to a specified variable of WORD type. But, How can I use each bit of that variable as a type BOOL variable?
Example 2:
Please see this code on Twincat:
[attachmentid=7332]
On this code, all the variables are of WORD type.
I move the value on "variavel_20" to "variavel_50", the value on "variavel_21" to "variavel_51", the value on "variavel_22" to "variael_52" and the value on "variavel_23" to "variavel_53".
To do that, I need to use 4 MOVE instructions.
The following code on Omron makes the same, with only one instruction:
[attachmentid=7333]
On Omron, since each variable have not only a name, but also a number, I can use this instruction to move
4 consecutive words, while the first source WORD is the word number 20 (with the name "variable_20"), and the first destination word is the word number 50 (with the name "variable_50").
Since in Omron I use not the variable names, but its number, I can use unstructions like this.
My question is:
If I need to move 100 words (100 variables of WORD type) on Twincat, Will I need to write the same instruction 100 times? Or, Is there a different way to do this? Since on Twincat the variables have only a name to identify them, I think it could be possible if it was possible to define a buffer with some consecutive variables. But How can I do that?
Example 3:
Please see the following Twincat code:
[attachmentid=7336]
All the variables are of WORD type.
On this code, I move the value on the variable "variavel_10" to all the variables with the names from "variavel_20" to "variavel_50".
On Omron, I use only one instruction to do the same:
[attachmentid=7337]