I'm having some trouble declaring the variables in my project.
I want to be able to set/reset the bits in a word and be able to reset the whole word at once.
So far i got it working fine at %MW0, but when I try the same at any other adress it wont work.
Can somebody help me a bit?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Josep M. Rams hat geschrieben:
Try:
MyMW:pointer to dword;
MyMW:=adr(mx0);
MyMW[0] is mx0
MyMW[1] is mx1
.
.
.
Setting full
MyMW[1]:=16#B1
For example
Sent from my Moto G (5S) Plus using Tapatalk
ph0010421 hat geschrieben:
I think a Union of 16 BITs (not BOOL) and a WORD is a better way to achieve this.
Thank you for the suggestions guys! A union seems to work quite well.
How do I add a comment to a bit in a union?
For example: bit 1 in union 1 should be called "valve 5". And bit 1 in union 2 should be named different.
ph0010421 hat geschrieben:
Include a STRUCT in your union with the names you need. It sounds like this can replace the BITs
When I re-use a union by declaring the same union under different name. Then the bits will have the same name, right?
Maybe my intentions aren't clear:
For my program i need my bits in groups of 16, like a word. I want to set/reset these bits individually or all at once.
I need a whole bunch of these groups. I'd like to add a comment to every individual bit in a group. (With different comments in different groups)
A fixxed adress is not necessary.
I need a fast/simple method of creating these groups
This is what I've done so far:
TYPESTR_BITS:STRUCTÂ Â x00:BIT;Â Â x01:BIT;Â Â x02:BIT;Â Â x03:BIT;Â Â x04:BIT;Â Â x05:BIT;Â Â x06:BIT;Â Â x07:BIT;Â Â x08:BIT;Â Â x09:BIT;Â Â x10:BIT;Â Â x11:BIT;Â Â x12:BIT;Â Â x13:BIT;Â Â x14:BIT;Â Â x15:BIT;END_STRUCTEND_TYPE
TYPEUNION_BITS_WORD:UNIONÂ Â strBits:STR_BITS;Â Â wWord:WORD;END_UNIONEND_TYPE
VARÂ Â union1:UNION_BITS_WORD;Â Â Â Â union2:UNION_BITS_WORD;Â Â END_VAR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey guys,
I'm having some trouble declaring the variables in my project.
I want to be able to set/reset the bits in a word and be able to reset the whole word at once.
So far i got it working fine at %MW0, but when I try the same at any other adress it wont work.
Can somebody help me a bit?
Try:
MyMW:pointer to dword;
MyMW:=adr(mx0);
MyMW[0] is mx0
MyMW[1] is mx1
.
.
.
Setting full
MyMW[1]:=16#B1
For example
Sent from my Moto G (5S) Plus using Tapatalk
Related
Talk.ru: 1
Originally created by: ph0010421
I think a Union of 16 BITs (not BOOL) and a WORD is a better way to achieve this.
Thank you for the suggestions guys! A union seems to work quite well.
How do I add a comment to a bit in a union?
For example: bit 1 in union 1 should be called "valve 5". And bit 1 in union 2 should be named different.
Related
Talk.ru: 1
Originally created by: ph0010421
Include a STRUCT in your union with the names you need. It sounds like this can replace the BITs
When I re-use a union by declaring the same union under different name. Then the bits will have the same name, right?
Maybe my intentions aren't clear:
For my program i need my bits in groups of 16, like a word. I want to set/reset these bits individually or all at once.
I need a whole bunch of these groups. I'd like to add a comment to every individual bit in a group. (With different comments in different groups)
A fixxed adress is not necessary.
I need a fast/simple method of creating these groups
This is what I've done so far:
I like the way how its working now with the struct and the union.
Can somebody explain how I add a comment to one specific bit in one specific word?
Something along the lines of this?