ConfigIO (U3 and U6 )
Writes and reads the current IO configuration. Note: the format of this function varies between the U3 and U6.
U3
Command: |
|
|
Byte |
|
|
0 | Checksum8 |
|
1 | 0xF8 |
|
2 | 0×03 |
|
3 | 0×0B |
|
4 | Checksum16 (LSB) |
|
5 | Checksum16 (MSB) |
|
6 | WriteMask |
|
|
| Bit 5: Write UART Related settings |
|
| Bit 4: Reserved, Pass 0 |
|
| Bit 3: EIOAnalog |
|
| Bit 2: FIOAnalog |
|
| Bit 1: DAC1Enable |
|
| Bit 0 : TimerCounterConfig |
7 | Reserved |
|
8 | TimerCounterConfig |
|
|
| Bits 4-7: TimerCounterPinOffset |
|
| Bit 3: Enable Counter1 |
|
| Bit 2: Enable Counter0 |
|
| Bits 0-1: Number of timers enabled |
9 | DAC1Enable (ignored on hardware rev 1.30+) | |
|
| Bit 2: Assign UART Pins (HW 1.30 only) |
|
| Bit 1: Reserved, Pass 0 |
|
| Bit 0: Enable DAC1 |
10 | FIOAnalog |
|
11 | EIOAnalog |
|
|
|
|
|
|
|
Response: |
|
|
Byte |
|
|
0 | Checksum8 |
|
1 | 0xF8 |
|
2 | 0×03 |
|
3 | 0×0B |
|
4 | Checksum16 (LSB) |
|
5 | Checksum16 (MSB) |
|
6 | Errorcode |
|
7 | Reserved |
|
8 | TimerCounterConfig |
|
9 | DAC1Enable |
|
10 | FIOAnalog |
|
11 | EIOAnalog |
|
WriteMask: Has bits that determine which, if any, of the parameters will be written.
TimerCounterConfig: Used to enable/disable timers and counters. Timers/counters will be assigned to IO pins starting with FIO0 plus TimerCounterPinOffset (4-8 only starting with hardware revision 1.30). Timer0 takes the first IO pin, then Timer1, Counter0, and Counter1. Whenever this function is called and timers are enabled, the timers are initialized to mode 10, so the desired timer mode must always be specified after every call to this function. Note that Counter0 is not available when using a timer clock base that supports a timer clock divisor (TimerClockBase = 3-6).
Assign UART Pins: On hardware 1.30 setting this bit will assign IO lines to the UART module. This setting will be ignored unless the UART write bit is set in the WriteMask byte.
DAC1Enable: On hardware revisions 1.20/1.21 only, bit 0 enables DAC1. When DAC1 is disabled, it outputs a constant voltage of 1.5 times the internal Vref (~2.44 volts). When DAC1 is enabled, the internal Vref is not available for the analog inputs and Vreg (~3.3 volts) is used as the AIN reference. Starting with hardware revision 1.30, DAC1 is always enabled.
FIOAnalog: Each bit determines whether that bit of FIO is analog input (=1) or digital I/O (=0).
EIOAnalog: Each bit determines whether that bit of EIO is analog input (=1) or digital I/O (=0).
LabJackPython Example
>>> import u3
>>> d = u3.U3()
>>> d.debug = True
'''Assign timer0 to FIO6, set FIO4, FIO5 as analog input, and set EIO1, EIO2 as analog input'''
>>> d.configIO(TimerCounterPinOffset = 6, NumberOfTimersEnabled = 1, FIOAnalog = 0x30, EIOAnalog = 0x03)
Sent: [0xa8, 0xf8, 0x3, 0xb, 0xa1, 0x0, 0xd, 0x0, 0x61, 0x0, 0x30, 0x3]
Result: [0x9b, 0xf8, 0x3, 0xb, 0x94, 0x0, 0x0, 0x0, 0x61, 0x0, 0x30, 0x3]
{'NumberOfTimersEnabled': 1, 'TimerCounterPinOffset': 6, 'DAC1Enable': 0, 'FIOAnalog': 48, 'EIOAnalog': 3, 'TimerCounterConfig': 97, 'EnableCounter1': False, 'EnableCounter0': False}
U6
Command: |
|
|
Byte |
|
|
0 | Checksum8 |
|
1 | 0xF8 |
|
2 | 0x05 |
|
3 | 0x0B |
|
4 | Checksum16 (LSB) |
|
5 | Checksum16 (MSB) |
|
6 | WriteMask |
|
|
| Bit 0: 1 = Write Settings |
|
| Bit 5: Assign pins to UART |
7 | NumberTimersEnabled |
|
8 | CounterEnable |
|
|
| Bit 1: Enable Counter1 |
|
| Bit 0: Enable Counter0 |
9 | TimerCounterPinOffset |
|
10-15 | Reserved |
|
|
|
|
Response: |
|
|
Byte |
|
|
0 | Checksum8 |
|
1 | 0xF8 |
|
2 | 0x05 |
|
3 | 0x0B |
|
4 | Checksum16 (LSB) |
|
5 | Checksum16 (MSB) |
|
6 | Errorcode |
|
7 | Reserved |
|
8 | NumberTimersEnabled |
|
9 | CounterEnable |
|
10 | TCPinOffset |
|
10-15 | Reserved |
|
WriteMask: Has a bit that determines if new timer/counter settings are written.
NumberTimersEnabled: 0-4. Used to enable/disable timers. Timers will be assigned to IO pins starting with FIO0 plus TimerCounterPinOffset. Timer0 takes the first IO pin, then Timer1, and so on. Whenever this function is called and timers are enabled, the timers are initialized to mode 10, so the desired timer mode must always be specified after every call to this function.
TimerCounterPinOffset: 0-8. Timers/counters are assigned terminals starting from here.