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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2018-05-28
Originally created by: ph0010421
Include a STRUCT in your union with the names you need. It sounds like this can replace the BITs
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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.
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?