relay control

Supporting 2.7 and 3.2+
Post Reply
buzz
Fresh meat
Posts: 1
Joined: Tue Feb 28, 2023 8:08 am
Contact:

relay control

Post by buzz »

Hello. I'm trying to understand why channel getState() always reports FALSE even if I know (and can verify) that I've ordered a relay port to be closed. I'm using a four port relay board. PhidgetInterfaceKit 0/0/4, 1014_2

Python:

Code: Select all

for i in range(count):
    ch = DigitalOutput()
    ch.setDeviceSerialNumber(576878)
    ch.setChannel(i)
    ch.openWaitForAttachment(1000)
    state = ch.getState()
    dutyCycle = ch.getDutyCycle()
    ch.close()
    print("port ", i, " State: " + str(state), " Duty cycle ", str(dutyCycle))
close one of the relays using the command line tools:

Code: Select all

/usr/local/bin/phidutil2 -p 1 1
Output is always false, no matter what if any of the relay ports are set open or closed via phidutil2:

Code: Select all

port  0  State: False  Duty cycle  0.0
port  1  State: False  Duty cycle  0.0
port  2  State: False  Duty cycle  0.0
port  3  State: False  Duty cycle  0.0
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: relay control

Post by mparadis »

It looks like you're printing the state of the relay immediately after opening it. The state of a digital output object is always false when it is first opened, regardless of what state it was in when it was last closed. In fact, all Phidget channels will have all of their properties at their default value when you first open them.

This means that if you want to keep the relay state "true", the program needs to keep running.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest