Skip to main content
Skip table of contents

AIN: IOType = 1

U3

AIN, 3 Command Bytes: 

0

IOType = 1

1

Bits 4-0: Positive Channel

 

Bit 6: LongSettling

 

Bit 7: QuickSample

2

Negative Channel

2 Response Bytes: 

0

AIN LSB

1

AIN MSB

This IOType returns a single analog input reading.

Note: Do not use this IO type while streaming.

  • Positive Channel: 0-15 for AIN0-AIN15, 30 for temp sensor, or 31 for Vreg. Note that AIN0-AIN7 appear on FIO0-FIO7, and AIN8-AIN15 appear on EIO0-EIO7.

  • LongSettling: If this bit is set, additional settling time is added between the multiplexer configuration and the analog to digital conversion.

  • QuickSample: If this bit is set, a faster analog input conversion is done, at the expense of increased noise. If bits 6 & 7 are both set, then the entire byte is a channel number (for digital I/O, timers, and counters).

  • Negative Channel: 0-15 for AIN0-AIN15, 30 for Vref, or 31 for single-ended. Note that AIN0-AIN7 appear on FIO0-FIO7, and AIN8-AIN15 appear on EIO0-EIO7.

  • AIN LSB & MSB: Analog input reading is returned justified as a 16-bit value (always unsigned).

U6

AIN, 3 Command Bytes:  

0

IOType=1

1

PositiveChannel

2

Reserved

2 Response Bytes: 

0

AIN LSB

1

AIN MSB

This is the U3 style IOType to get a single analog input reading. It is available for compatibility, but to make full use of the U6 the new AIN24 IOType should be used.

Note: Do not call this IO type while streaming.

  • PositiveChannel: 0-143 for AIN0-AIN143. 14 is the internal temperature sensor and 15 is internal GND.

  • AIN LSB & MSB: Analog input reading is returned as a 16-bit value (always unsigned).

Example

PY
# Analog Input Feedback command
# specify the positive and negative channels to use 

import u3
d = u3.U3()
d.debug = True
d.getFeedback(u3.AIN(PositiveChannel = 0, NegativeChannel=31, LongSettling=False, QuickSample=False))
#Sent:  [0x1b, 0xf8, 0x2, 0x0, 0x20, 0x0, 0x0, 0x1, 0x0, 0x1f]
#Response:  [0xab, 0xf8, 0x3, 0x0, 0xaf, 0x0, 0x0, 0x0, 0x0, 0x20, 0x8f, 0x0]
#[36640]
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.