5.4 - Counter/AO/DIO [U12 Datasheet]
This command controls all 20 digital I/O, and the 2 analog outputs (AO0 & AO1). The response provides the state of all I/O and the current counter value. If Reset Counter = 1, the counter is reset after reading.
Table 5.4-1.
Command |
|
Byte # | Description |
0 | D15 though D8 Direction ( 0 = Output, 1 = Input ) |
1 | Bits for D7 though D0 Direction ( 0 = Output, 1 = Input ) |
2 | Bits for D15 though D8 State ( 0 = Low, 1 = High ) |
3 | Bits for D7 though D0 State ( 0 = Low, 1 = High ) |
4 | Bits 7-4 = Bits for IO3 through IO0 Direction |
| Bits 3-0 = Bits for IO3 through IO0 State |
5 | Bits 7-6 = 00 (Counter/AO/DIO) |
| Bit 5 = Reset Counter |
| Bit 4 = Update Digital |
| Bits 3-2 = Least Significant Bits of AO0 duty cycle |
| Bits 1-0 = Least Significant Bits of AO1 duty cycle |
6 | Most Significant bits of AO0 duty cycle (0 = 0 V, 0×3ff = 5.0 V) |
7 | Most Significant bits of AO1 duty cycle (0 = 0 V, 0×3ff = 5.0 V) |
|
|
|
|
Response |
|
Byte # | Description |
0 | 00XXXXXX (Counter/PWM response) |
1 | Bits for D15 though D8 State ( 0 = Low, 1 = High ) |
2 | Bits for D7 though D0 State ( 0 = Low, 1 = High ) |
3 | Bits 7-4 = Bits for IO3 through IO0 State |
| Bits 3-0 = XXXX |
4 | Most Significant Byte of Counter |
5 | Bits 23-16 of Counter |
6 | Bits 15-8 of Counter |
7 | Least Significant Byte of Counter |
LabJackPython Example
>>> import u12
>>> d = u12.U12(debug=True)
open called
Writing: [0x0, 0x0, 0x0, 0x0, 0x0, 0x57, 0x0, 0x0]
Received: [0x57, 0x0, 0x0, 0x0, 0xff, 0xff, 0x0, 0x0]
>>> d.rawCounterPWMDIO()
Writing: [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
Received: [0x0, 0x0, 0x0, 0x0, 0xbb, 0x10, 0x0, 0xef]
{
'IO3toIO0States':
<BitField object: [ IO3 = Low (0), IO2 = Low (0),
IO1 = Low (0), IO0 = Low (0) ] >,
'Counter': 3138388207,
'D7toD0States':
<BitField object: [ D7 = Low (0), D6 = Low (0),
D5 = Low (0), D4 = Low (0),
D3 = Low (0), D2 = Low (0),
D1 = Low (0), D0 = Low (0) ] >,
'D15toD8States':
<BitField object: [ D15 = Low (0), D14 = Low (0),
D13 = Low (0), D12 = Low (0),
D11 = Low (0), D10 = Low (0),
D9 = Low (0), D8 = Low (0) ] >
}