Good morning, sir. I would like to use python to tell me if the DIO.0 input is high or low. I am sending a 3V signal to the DIO.0 input. With the waveform program it works perfectly. I can read the value of the input correctly depending on what I input as a signal. But with python it is impossible to read this value. I have taken scripts on the forum to try to understand but nothing works, the input read remains at zero. Can you help me ? I just want python to print value high state when there is 3V low state when there is 0V. Thank you in advance
# import constants
path.append(constants_path)
import dwfconstants as constants
hdwf = c_int()
hzDI = c_double()
#sts = c_byte()
cSamples = 1000
dwf.FDwfDigitalInInternalClockInfo(hdwf, hzDI)
dwf.FDwfDigitalInTriggerSourceSet(hdwf, constants.trigsrcDetectorDigitalIn)
#dwf.FDwfDigitalInTriggerSet(hdwf, 0, 0, 0, '&HFFFF')
dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, 10)
dwf.FDwfDigitalInDividerSet(hdwf, c_int(1000))
dwf.FDwfDigitalInSampleFormatSet(hdwf, 8)
dwf.FDwfDigitalInBufferSizeSet(hdwf, cSamples)
dwf.FDwfDigitalInTriggerPositionSet(hdwf, cSamples - 10)
# begin acquisition
dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
print ("waiting to finish")
i = 0
while i < 10:
sts = ctypes.c_byte()
dwf.FDwfDigitalInStatus(hdwf, c_int(0), byref(sts))
print ("STS VAL: " + str(sts.value))
if (sts.value == stsDone.value):
break
time.sleep(1)
i=i+1
print ("Acquisition finished")
time.sleep(1)
dwf.FDwfDigitalOutReset(hdwf)
dwf.FDwfDeviceCloseAll()
rgpy=[0.0]*len(rgwSamples)
for i in range(0,len(rgpy)):
rgpy[i]=rgwSamples[i]
plt.plot(rgpy)
plt.show()