Description

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

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] In this lesson, I'll demonstrate the expression language's bit functions by using an expression binding to check the value of a specific bit of a tag. I have this "Writeable Integer 1" tag that is currently set to a value of five. I'm using it as a bit field where each bit represents a different flag that I wanna visualize for operators. First, I'll drag a multi-state indicator onto my window and I'll add a binding to the state property. I'll make this an expression binding and go to the list of functions. There are a couple bit functions available here, such as the binary encoder and binary enumeration functions, but I want to use getBit. This function takes an integer value and a position and returns the value of the bit at that position. In this case, I'll use the value of my "Writeable Integer 1" tag as the number, and I wanna return the value of the first or least significant bit. So I'll pass a position of zero. I'll hit okay to close out of this window and add the binding.

[01:04] And you can see that the multi-state indicator is on letting me know that the first bit of my tag is one, or on. If I change the tag value to something like four, which will turn off the first bit, the multi-state indicator now turns off to reflect that.

You are editing this transcript.

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