is the pragma bitaccess no more available in CODESYS3 ?
It was for me very usefull in V2, but i didn't find it ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-01-07
Originally created by: scott_cunningham
You can bit access variables by default:
PROGRAMPLC_PRGVAR
  Test  : BYTE;END_VARIFTest.0THEN
  Test.1 :=NOT(Test.1);END_IFTest.0 :=NOT(Test.0);
There is also the BIT data type replaces it. It's not allowed in arrays, references or pointers, but allowed for structures. It should work for you. The help warns that BIT data access is slower than BOOL access, so only use it when you really want to (as opposed to C programmers that love to bit-code variables...).
From the Help:
Zitat:
Bit access in structures
The datatype BIT is a special datatype which can only be defined in structures. It consumes memory space of one bit and allows to address single bits of a structure by name.
TYPE<structurename>:STRUCT  <bitnamebit1>:BIT;  <bitnamebit2>:BIT;  <bitnamebit3>:BIT;  ...  <bitnamebitn>:BIT;END_STRUCTEND_TYPE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i now that.
But with the pragma bitaccess it was much more convinent.
Example :
without the pragma :
Controlword.0
Controlword.1
with pragma
Controlword.enableConverter
Controlword.driveEnable
both methods access the same bit, but for me it makes sense (because it is much better to understand),
to use the method with the pragme bitacces.
... and i have some function blocs from CoDeSys2.x, which i'd like to use in CODESYS3.
Anyway, thank you for your answer, the People in Kempten didn't.
Winner find's a way, looser find's a reason.
So, it seems, we are now able to have OOP for PLC, but we lost some nice features.
Walk unafraid.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-01-08
Originally created by: scott_cunningham
Ah, yes, I know these control words (I have products that use them) and never liked using the bit #s - because it's nice to see "enable" or "reset" like you are looking for.
What you could do is create a FB with properties called enableConverter, driveEnable, etc. Have the FB have an output called BitCode. And then instead of defining a variable called ControlWord : INT, you would use ControlWord : FbControlWord. Then map "ControlWord.BitCode" to your drive... (this is how I do it because then I can have a drive object contain a control word object...)
Then your existing code still works:
Controlword.enableConverter := TRUE;
Controlword.driveEnable := FALSE;
It is a couple more steps for you, but at least you can reuse all of your code without much editing (only the VAR declaration and a mapping).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
is the pragma bitaccess no more available in CODESYS3 ?
It was for me very usefull in V2, but i didn't find it ?
Originally created by: scott_cunningham
You can bit access variables by default:
There is also the BIT data type replaces it. It's not allowed in arrays, references or pointers, but allowed for structures. It should work for you. The help warns that BIT data access is slower than BOOL access, so only use it when you really want to (as opposed to C programmers that love to bit-code variables...).
From the Help:
Thank's Scott,
i now that.
But with the pragma bitaccess it was much more convinent.
Example :
without the pragma :
Controlword.0
Controlword.1
with pragma
Controlword.enableConverter
Controlword.driveEnable
both methods access the same bit, but for me it makes sense (because it is much better to understand),
to use the method with the pragme bitacces.
... and i have some function blocs from CoDeSys2.x, which i'd like to use in CODESYS3.
Anyway, thank you for your answer, the People in Kempten didn't.
Winner find's a way, looser find's a reason.
So, it seems, we are now able to have OOP for PLC, but we lost some nice features.
Walk unafraid.
Originally created by: scott_cunningham
Ah, yes, I know these control words (I have products that use them) and never liked using the bit #s - because it's nice to see "enable" or "reset" like you are looking for.
What you could do is create a FB with properties called enableConverter, driveEnable, etc. Have the FB have an output called BitCode. And then instead of defining a variable called ControlWord : INT, you would use ControlWord : FbControlWord. Then map "ControlWord.BitCode" to your drive... (this is how I do it because then I can have a drive object contain a control word object...)
Then your existing code still works:
Controlword.enableConverter := TRUE;
Controlword.driveEnable := FALSE;
It is a couple more steps for you, but at least you can reuse all of your code without much editing (only the VAR declaration and a mapping).