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 (3015 correspond to 3F), 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 0R40~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.
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:
- Instruction Form
- Mnemonic Form
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
000 FZ 0021 03E8 R21 = 1000, threshold
001 AD 0000 0020 R20 = cached value of channel 0
002 DYZ 2021 0005 if R20 > R21, jump to line 005
003 FZ 0030 0000 R30 = 0000, below threshold
004 ZY 0000 0001 back to line 001
005 FZ 0030 0001 R30 = 0001, above threshold
006 ZY 0000 0001 back to line 001
| Operands | Value/Range | Remark |
|---|---|---|
| OP-00 | 00 | Ignored |
| OP-01 | 00~0F | ADS1115 channel number |
| OP-10 | 00 | Ignored |
| OP-11 | 00~FF | Target register number |
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.