Open joaojcsq opened 4 years ago
daqflex.USB_204
gives you the class USB_204
. You want to create an instance of the class: dev = daqflex.USB_204()
.
By the way, read_scan_data
should only take 2 arguments - you were likely seeing something like "takes 3 arguments (2 given)" because you were calling it like a static method (directly from the class rather than an instance of the class). self
is the extra argument, referring to the the instance itself, which is passed implicitly for you when you call an instance method.
@ixjlyons , thanks for your explanation! I moved forward with your answer. But I still can't read the data from the analog channel, can you help me?
I tried this code but the answer is: array ('H')
import daqflex
dev = daqflex.USB_204()
R = dev.read_scan_data(3000,500000)
with open('P','w') as f:
f.write(str(R))
f.close()
I also tried to use these commands in another code:
import daqflex
dev = daqflex.USB_204()
print("####")
print(dev.send_message("AISCAN:RATE=500000"))
print(dev.send_message("AISCAN:SAMPLES=30000"))
print(dev.send_message("AISCAN:TRIG=ENABLE"))
print("####")
print(dev.send_message("?AI{0}:RANGE"))
print(dev.send_message("?AISCAN:RATE"))
print(dev.send_message("?AISCAN:SAMPLES"))
print(dev.send_message("?AISCAN:STATUS"))
print(dev.send_message("?AISCAN:TRIG"))
print("####")
dev.send_message("AISCAN:START")
print(dev.send_message("?AISCAN:STATUS"))
R = dev.send_message("?AI{0}:VALUE")
print("####")
dev.send_message("AISCAN:STOP")
print(dev.send_message("?AISCAN:STATUS"))
with open('P','w') as f:
f.write(str(R))
f.close()
and the answer to that last code was:
####
AISCAN:RATE
AISCAN:SAMPLES
AISCAN:TRIG
####
AI{0}:RANGE=BIP10V
AISCAN:RATE=500000.000
AISCAN:SAMPLES=30000
AISCAN:STATUS=IDLE
AISCAN:TRIG=ENABLE
####
AISCAN:STATUS=RUNNING
####
AISCAN:STATUS=IDLE
and the "R" file was:
AI {0}: VALUE = 0
I'm not sure I can help much more since I don't have access to any hardware at the moment. It seems like you might want to replace the R = dev.send_message...
in your second script with R = dev.read_scan_data...
to get multiple samples. "?AI{0}:VALUE" would read a single analog input channel value if I remember correctly, which it looks like it's doing.
@ixjlyons thanks for your tips. I did what you told me, but now I only get 2042 for the data. I'll keep trying, if I can, I'll come back here and leave feedback.
Hi, thanks for the library. I have USB 204 and I'm a Python beginner. I'm trying to capture signals using a rasberry pi3 and USB 204. But when I write the code:
this error appears:
Does anyone know what I can do?