LESSON

Expression Binding – Bit Functions

Description

Learn how to use various bit functions in expression bindings like getBit to return individual bits of a word.

Video recorded using: Ignition 7.7

Transcript

(open in window)

[00:00] The expression language in ignition has a lot of bit functions and opers that we can work with. The most common function people want to use is a getBit function, which basically gets a bit out of a word and displays it on a screen. So here I have a tag called WriteableInteger1 and the value right now is 5. So what I want to do is basically display the value of bit 0, the first bit of that integer. So I'm going to bring on a Multi-State indicator onto a window, which basically will show me the state, on or off. I'm actually going to bind the state property here to an expression. In the expression language, you go to effects, go down to logic, here I have my bit functions, or binary functions. I have binEnc, I have binEnun and I have getBit. The getBit here will allow me to get a bit at a particular position. So I'm going to bring that in, the first argument is the number I want to use. So I'm going to go over here to the tag and bring in my WriteableInteger1 tag, then, of course, the second is the bit position. I'm going to do bit 0 here, which is the very first bit. So I do that, it's going to bring back either 1 or 0 or true or false, soon as I press okay, I can see that, right now, it is certainly on, because the value's 5. So bit 0 is 1 . If I set this to say 4, bit 0 will no longer be active so you can see that it goes off. So it's very easy to work with bits in our expression language.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.