Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Set a particular bit in a int16/ Circle dynamic
PostPosted: Tue Apr 07, 2015 9:03 am 

Joined: Wed Mar 04, 2015 3:35 am
Posts: 1

Offline
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.


 Profile  
 
 Post subject: Re: Set a particular bit in a int16/ Circle dynamic
PostPosted: Mon Apr 13, 2015 3:47 pm 

Joined: Mon Jun 11, 2012 2:10 pm
Posts: 89

Offline
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);

_________________
Adam M.
Controls Engineer
FlexEnergy


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: