Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Bit manipulation functions in Lookout 4.0

Hello,

I need to read bit values from WORD (%MW) values read from a Telemecanique
PLC (TSX Premium) trough an Applicom card (UNI-TE), but I can't see how get
separate bits from these word values. In Lookout I can't see any bit
manipulation function, and the Applicom driver for UNI-TE don't let me
adress the bits of a word value. Sure I can do a lot of calculations to get
the bits, but there is any simplest solution for this?

Any help will be appreciated
Thanks
Joaquin Villanueva
T-Systems, S.L.
0 Kudos
Message 1 of 5
(3,035 Views)
Hello (hola) Joaquin

I think the only solution is to use the following formula

mod( int(WORD) , 2) --> to get Bit 0
mod( int(WORD/2) , 2) --> to get Bit 1
mod( int(WORD/4) , 2) --> to get Bit 2
mod( int(WORD/8) , 2) --> to get Bit 3
mod( int(WORD/16) , 2) --> to get Bit 4

and so on...

I hope it will help. I don't know an easier way to acomplish that.

Joan Lluch
Suministros Electricos Industriales, S.L.




Joaquin Villanueva wrote:

> Hello,
>
> I need to read bit values from WORD (%MW) values read from a Telemecanique
> PLC (TSX Premium) trough an Applicom card (UNI-TE), but I can't see how get
> separate bits from these word values. In Lookout I can't see any bit
> manipulation function, and the Applicom driver for UNI-TE don't let me
> adress the b
its of a word value. Sure I can do a lot of calculations to get
> the bits, but there is any simplest solution for this?
>
> Any help will be appreciated
> Thanks
> Joaquin Villanueva
> T-Systems, S.L.
0 Kudos
Message 2 of 5
(3,035 Views)
Hi Joan and Joaquin

Try with the undocumented function getbit(Word, BitNum)

It should return the bit at BitNum position. I didn't fully test it yet,
but try it anyway!

Regards to all Lookout programmers,

Roman Plevnik
Virtual Technologies
SLOVENIA
Joan wrote:
>Hello (hola) Joaquin>>I think the only solution is to use the following
formula>>mod( int(WORD) , 2) --> to get Bit 0>mod( int(WORD/2) , 2)
--> to get Bit 1>mod( int(WORD/4) , 2) --> to get Bit 2>mod( int(WORD/8)
, 2) --> to get Bit 3>mod( int(WORD/16) , 2) --> to get Bit 4>>and
so on...>>I hope it will help. I don't know an easier way to acomplish that.>>Joan
Lluch>Suministros Electricos Industriales, S.L.>>>>>Joaquin Villanueva wrote:>>>
Hello,>>>> I need to read bit v
alues from WORD (%MW) values read from a Telemecanique>>
PLC (TSX Premium) trough an Applicom card (UNI-TE), but I can't see how get>>
separate bits from these word values. In Lookout I can't see any bit>> manipulation
function, and the Applicom driver for UNI-TE don't let me>> adress the bits
of a word value. Sure I can do a lot of calculations to get>> the bits, but
there is any simplest solution for this?>>>> Any help will be appreciated>>
Thanks>> Joaquin Villanueva>> T-Systems, S.L.>>>
0 Kudos
Message 3 of 5
(3,035 Views)
Are there other undocumented functions in Lookout?. How or where could I know them?. Very
interesting thing!!

Joan Lluch.
Suministros Electricos Industriales, S.L.
Spain.



Roman Plevnik wrote:

> Hi Joan and Joaquin
>
> Try with the undocumented function getbit(Word, BitNum)
>
> It should return the bit at BitNum position. I didn't fully test it yet,
> but try it anyway!
>
> Regards to all Lookout programmers,
>
> Roman Plevnik
> Virtual Technologies
> SLOVENIA
0 Kudos
Message 4 of 5
(3,035 Views)
hi Roman it works. Thanks I was looking for this function but it is not inside the Lookout help file.
0 Kudos
Message 5 of 5
(3,035 Views)