Integrated Development
Environment (IDE) Documentation:

Built-In Registers

The IDE compiler supports a variety of built-in registers that can be treated in the same way as variables:

ADC

The ADC ports are read-only ports that return a digital representation of an analog input level.

Use a zero-based index to indicate which ADC port you wish to read. For example, reading from ADC[0] will read from the first ADC port, AI1.

The ADC ports typically return a value in the range of 0-4095; however it is possible for the ports to operate beyond their intended range. If the port is reading a value below its calibration limits, ADC may return a value of -1. Likewise, if it is reading a value above its calibration limits, ADC may return a value of 4096.

ADC_A, ADC_B, ADC_C, ADC_D, and ADC_raw

The alternative ADC ports read the same data as the ADC ports, but scaled in different ways. These alternative ports can be handy if the data range better suits your application's needs.

The alternative ADC ports map as follows:

Port Range Error limits
ADC_A 0mA - 0
20mA - 4095
low = -1
high = 4096
ADC_B 4mA - 0
20mA - 32767
low = -1
high = -32768
ADC_C 0mA - 0
20mA - 32767
low = -1
high = -32768
ADC_D 4mA - 0
20mA - 4095
low = -1
high = 4096
ADC_raw 0mA - 0
20mA - 4095
n/a

ADC_A is just another name for ADC, but the B through D variants are slightly different depending on the current range and scale range you want to use.

For the B and C variants, you may notice the unexpected high limit code. The IDE compiler represents all numbers as 16-bit integers with a limit of -32768 to 32767, so a value of 32768 is represented by -32768.

The ADC_raw ports read the analog to digital converters without any calibration values taken into consideration. It is unlikely that you will ever need to use these.

Count

The Count ports give your program access to the RIO device's internal counters.

Use a zero-based index to indicate which Count register you wish to access. For example, reading from Count[0] will read from the first counter, DI1Count.

Keep in mind that the IDE compiler uses only 16 bit values to represent type int, so you will not be able to access the additional bits in registers such as DI1LongCount.

DAC

The DAC ports allow your program to control the analog output levels by setting digital representations.

Use a zero-based index to indicate which DAC port you wish to access. For example, writing to DAC[0] will set the first DAC port, AO1.

The DAC ports can be set to any value in the range of 0-4095; however, due to calibration adjustments, it is possible that the value read from a DAC port will not exactly match the value written to that port. Please be very cautious before making any assumptions in this regard.

DAC_A, DAC_C, and DAC_raw

The alternative DAC ports control the same outputs as the DAC ports do, but scaled in different ways. These alternative ports can be handy if the data range better suits your application's needs.

The alternative DAC ports map as follows:

Port Range
DAC_A 0mA - 0
20mA - 4095
DAC_C 0mA - 0
20mA - 32767
DAC_raw 0mA - 0
20mA - 4095

DAC_A is just another name for DAC, but the C variant has a slightly different scale.

The DAC_raw ports write to the digital to analog converters without any calibration values taken into consideration. It is unlikely that you will ever need to use these.

DI

The DI ports are read-only ports that return the state of the corresponding inputs.

Use a zero-based index to indicate which DI port you wish to read. For example, reading from DI[0] will read from the first DI port, DI1.

The DI ports return a value of 0 or 1, only.

DO

The DO ports control the state of the corresponding outputs.

Use a zero-based index to indicate which DO port you wish to access. For example, writing to DO[0] will set the first DO port, DO1.

The DO ports are boolean. Writing any non-zero value to a DO port will turn it on and writing a 0 will turn it off. Reading from a DO port will return a value of 0 or 1, only.

ModbusAddr

The ModbusAddr port is a read-only port that returns the device's Modbus address.

Valid Modbus addresses range from 1 to 247.

Pulse

The Pulse ports control the device's internal pulse counters.

Use a zero-based index to indicate which pulse counter you wish to access. For example, writing to Pulse[0] will set the first pulse counter, which controls DO1.

Reading a Pulse ports returns how many milliseconds remain in the current pulse. Writing a non-zero value to a Pulse port will pulse the digital output for the given number of milliseconds.

Note that writing a new value to a Pulse port during an output pulse will be silently ignored.

Xfer

The Xfer ports are memory registers which can be accessed by both the user program and a Modbus server. These are useful in transferring data into and out of your program.

Use a zero-based index to indicate which Xfer register you wish to access.