Skip to main content

Sensors

This category reads the analog inputs of the ADS1115 analog-to-digital converter.

The ADS1115 provides 16 input channels. In the port system they appear as the read-only Port3 (303F), see Brief. The system periodically samples all channels in the background (DefaultTask) and keeps the latest value of channel n in register R(40+n) — that is, channels 015 correspond to R40~R4F, in millivolts. The whole Port3 can also be read at once with QS 0x14.

0xAD Read AD Channel (AD)​

Copy the cached value of one ADS1115 channel into a register.

caution

0xAD does not trigger a fresh conversion. It copies the latest value from the background sampling cache, which is refreshed periodically by DefaultTask — the reading is not instantaneous.

The example below reads channel 0 into R20 and compares it against a threshold of 1000, using the greater-than jump DYZ 0x04:

000  10  0021  03E8    R21 = 1000, threshold
001 AD 0000 0020 R20 = cached value of channel 0
002 04 2021 0005 if R20 > R21, jump to line 005
003 10 0030 0000 R30 = 0000, below threshold
004 0E 0000 0001 back to line 001
005 10 0030 0001 R30 = 0001, above threshold
006 0E 0000 0001 back to line 001
info
OperandsValue/RangeRemark
OP-0000Ignored
OP-0100~0FADS1115 channel number
OP-1000Ignored
OP-1100~FFTarget register number
tip

The value of every channel is always available in R40~R4F (channel 0 → R40, channel 15 → R4F). 0xAD is a convenience for moving one channel's cached value into any register you choose. The ADS1115 module must be enabled for the cache to update — see ADS1115 Switch.