Part 32 — Analog to Digital
The Analog to Digital module in Crestron’s SIMPL programming works by taking a single 16-bit analog input value and breaking it down into 16 individual binary (digital) outputs. Each output represents one bit in the binary representation of the analog input.
Analog Input (<ain>
):
This is the 16-bit integer value that you input into the Analog to Digital symbol. The value can range from 0 to 65535 (the range of a 16-bit unsigned integer).
Binary Conversion:
The module converts the 16-bit analog value into its binary (base-2) representation. For example, if <ain>
has a value of 12345
, its binary representation is 0011000000111001
.
Digital Outputs (<bit1>
to <bit16>
):
Each of the 16 digital outputs represents a single bit in the binary representation of the analog input. <bit1>
is the least significant bit (LSB), and <bit16>
is the most significant bit (MSB).
If a bit in the binary representation is 1
, the corresponding digital output will be set high (1). If the bit is 0
, the digital output will be set low (0).
Output Representation:
The outputs are arranged as individual bits, with <bit16>
as the highest (most significant) bit and <bit1>
as the lowest (least significant) bit.
For the example input of 12345
, the outputs would look like this:
<bit16>
= 0<bit15>
= 0<bit14>
= 1<bit13>
= 1<bit12>
= 0<bit11>
= 0<bit10>
= 0<bit9>
= 0<bit8>
= 0<bit7>
= 1<bit6>
= 1<bit5>
= 1<bit4>
= 0<bit3>
= 0<bit2>
= 1<bit1>
= 1