BitStateWrite not changing state of FIO | LabJack
 

BitStateWrite not changing state of FIO

3 posts / 0 new
Last post
pabern
pabern's picture
BitStateWrite not changing state of FIO

Running this code (python) :

import u6

d = u6.U6()

d.configIO(NumberTimersEnabled=4)
d.debug = True

# Set FIO 2 to digital output
d.getFeedback(u6.BitDirWrite(2, 0))
# set FIO 2 to output low
d.getFeedback(u6.BitStateWrite(2, 1))

# Invert state (to 1)
state = d.getFeedback(u6.BitStateRead(2))
new_state = 0 if state[0] else 1
d.getFeedback(u6.BitStateWrite(2, new_state))
state_end = d.getFeedback(u6.BitStateRead(2))
print(f'{state}, {state_end}')

Yields the following output:

Sent: [0xa, 0xf8, 0x2, 0x0, 0xf, 0x0, 0x0, 0xd, 0x2, 0x0]
Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
Sent: [0x88, 0xf8, 0x2, 0x0, 0x8d, 0x0, 0x0, 0xb, 0x82, 0x0]
Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
Sent: [0x7, 0xf8, 0x2, 0x0, 0xc, 0x0, 0x0, 0xa, 0x2, 0x0]
Response: [0xfb, 0xf8, 0x2, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1]
Sent: [0x8, 0xf8, 0x2, 0x0, 0xd, 0x0, 0x0, 0xb, 0x2, 0x0]
Response: [0xfa, 0xf8, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
Sent: [0x7, 0xf8, 0x2, 0x0, 0xc, 0x0, 0x0, 0xa, 0x2, 0x0]
Response: [0xfb, 0xf8, 0x2, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1]
[1], [1]

It seems like the BitStateWrite is not working for the FIO. What am I missing ?

pabern
pabern's picture
I tried this as well... Same

I tried this as well... Same results.

import u6

c = u6.U6()
c.debug = True
c.setDIOState(2, 0)
print(c.getDIOState(2))

Sent: [0x0, 0x0, 0xcd, 0x81, 0x0, 0x0, 0x0, 0x6, 0x0, 0x6, 0x17, 0x72, 0x0, 0x0]
Response: [0xcd, 0x81, 0x0, 0x0, 0x0, 0x6, 0x0, 0x6, 0x17, 0x72, 0x0, 0x0]
Sent: [0x7, 0xf8, 0x2, 0x0, 0xc, 0x0, 0x0, 0xa, 0x2, 0x0]
Response: [0xfb, 0xf8, 0x2, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1]
1

LabJack Support
LabJack Support's picture
The state for FIO2 cannot be

The state for FIO2 cannot be set since it is configured as a timer. This:

d.configIO(NumberTimersEnabled=4)

Configures FIO0-FIO3 as timers. If you disable timers (NumberTimersEnabled=0), or use the digital I/O after FIO3, you can configure the output state of the digital line and read back the expected state.

Also, note that the timer settings will be in effect until disabled by code or the device is power cycled, which is why you still see the issue in your second post.