Signal To Bits
Overview
Use this operator to convert a natural value (integer) into multiple channels that each represent one binary bit of the value.Some devices offer a signal channel with encoded boolean flags, all in one value. This operator is able to select the bits of the value, so that you can process their individual binary states.
Operator ports
Input S0: Floating point valuesOutput Boolean: Floating point values
Properties
Find more information about changing properties here: "Properties Viewer"How many bits
type: Integer valueSpecifies the first N number of bits of the input value that are converted to N output channels. Changing this value also changes the number of output channels.
Caption
type: Word or phraseThe name of the object in the project. This name must not contain '.', '$' nor '@' characters.
For more information about the rules and usage of the Caption property, please refer to "Caption property - background and usage".
Documentation
type: See descriptionOptional documentation of this object. If this object is an operator, the Documentation text is displayed below the operator symbol.
Details
To describe the usage of this operator, we take an example:Suppose your device outputs in a signal channel 8-bit integer values. Each binary bit in that value stands for an alarm from the device. You are interested to find out the values of each bit.
You take a Signal to Bits operator and connect the signal channel to the input. In the How many bits property you define that you want to extract the first 8 bits.
The Signal to Bits operator now gets 8 channels at its output. The first channel represents the first bit, the second channel the second bit, etc. Each bit now becomes a signal that is either 0 for a False or 1 for a True.
Limitations
- Only one signal channel must be connected to the input. If you connect a signal bus with more than one channel, a warning is displayed below the operator symbol.- The number of bits is limited to 64
- If the input value is not a natural, but a real number, then the value is truncated to an integer before the bits are analysed.
More information
Read more about pseudo-boolean states here: "Pseudo-booleans and triggers".Examples
Example: Single Bit Decoder Demo
Demonstrates the use of the Signal To Bits operator to create a Single Bit Decoder. The input of this schematic is a pulse train, where each pulse must have a length of one sample period. Every next pulse, the next output channel becomes high.The middle part of the schematic counts the input pulses and converts that count to a 2^N value, which serves as input to the Signal To Bits.
Examples\DF0600158_001_Single_Bit_Decoder_with_Signal_To_Bits_Demo.xmc