Greetings!
I'm currently trying to make a script for setting a particual bit in an integer. The point is:
I have 16 circles(dynamics) on a row. If I "mouse enter" circle no.6 I want it to set bit number 5 in a int16. Im currently using a memory bit for each circle which is the easy set up, but may slow down the proccess (PLC <-> panel).
Its a total of 15x55 (YxX) circles/pixels for a drawing page and because of that trying to get each line of 15 circles/bits into one integer 16 memory.
Using iX T7B panel and Mitsubishi FX3U PLC.
Thanks in advance!
Henrik.
Set a particular bit in a int16/ Circle dynamic
-
- Posts: 137
- Joined: Mon Jun 11, 2012 2:10 pm
Re: Set a particular bit in a int16/ Circle dynamic
I'm assuming your integer is a tag that for this example I will call Variable.
to set a bit, use the code
Globals.Tags.Variable.Value |= 1 << numBits;
where numBits is the position of the bit (first bit = 0).
to unset a bit, use the code
Globals.Tags.Variable.Value &= ~(1 << numBits);
to set a bit, use the code
Globals.Tags.Variable.Value |= 1 << numBits;
where numBits is the position of the bit (first bit = 0).
to unset a bit, use the code
Globals.Tags.Variable.Value &= ~(1 << numBits);
Adam M.
Controls Engineer
FlexEnergy
Controls Engineer
FlexEnergy