VernierST / godirect-examples

Official examples for Vernier Go Direct® Sensors in both Python and JavaScript
BSD 3-Clause "New" or "Revised" License
23 stars 26 forks source link

Can't read measurements from Sensor using USB - Go Direct Respiration Belt #32

Closed allananbu closed 3 years ago

allananbu commented 3 years ago

Device - Go Direct Respiration Belt Device ID - 0K202254 Order Code - GDX - RB

While running the godirect example [gdx_getting_started_usb] ]using Python, the following occurs,

1) USB devices found - 1 2) Select sensors - 1 3) Start - 1000 4) Read - Error - Pop values empty list.

Does this mean the sensor is not transmitting any measurements since there are no values in the buffer?

Also, the device is not detected sometimes while using USB.

Kindly help to resolve this error.

dvernier commented 3 years ago

Hello,

I just tried the same thing here and I get: number of usb devices found = 1 attempting to open 1 device(s)... open device 0 = True select sensors for GDX-GP 08100032 USB 1: Pressure (kPa) Enter sensor number. To select multiple sensors, separate with commas (no spaces): 1 select period (ms): 500 sample rate = 2.0 samples/second start device 0 [99.17939758300781] [99.17939758300781] [99.11627197265625] [99.17939758300781] [99.17939758300781] stop device 0 close device 0 quit godirect

Which is what I would expect. Have you tried the same sensor using our free Graphical Analysis app? Do you have any other Go-Direct sensors to try?

Dave

allananbu commented 3 years ago

Hello Dave,

I'm able to get the desired output now. I don't know how it seems to work now. However, after running 'gdx_getting_started_usb' once, if I try to execute it again, I get the error mentioned above [See screenshot]. I had to restart the kernel to get the measurements from the GDX Belt. Also, I'm able to get the measurements using the Graphical Analysis app and I don't have any other Go-Direct sensors. image

sswartley commented 3 years ago

@allananbu I am unsure why you are seeing that error. Perhaps it is from your sampling rate? I would test the program with a very limited rate - something like 1000ms period.

The other thing I would suggest would be to run the example that does not use the gdx functions, instead talks directly to the godirect module. This would be a good troubleshooting step to make sure the issue is not a bug in the gdx functions. The example can be found here: https://github.com/VernierST/godirect-examples/blob/master/python/godirect-module-examples/godirect-sensor-readout.py

All the best,

Sam

allananbu commented 3 years ago

@sswartley I've set a sample rate of 500ms. I didn't check this example before. It works fine. I don't have to restart the kernel every time I run the code in this example. I wonder what the error in the gdx function meant.

Thanks a lot.

sswartley commented 3 years ago

@allananbu Thanks for the update and I'm glad you have something that works. Do you have any more insight into the issue? I'm also wondering what your setup is that is causing this problem (what version of Python, what OS, are you on a computer or Raspberry Pi, etc..). Any info that could help others. Thanks!

allananbu commented 3 years ago

@sswartley I'm not sure about why this issue persists. I'm currently using 'gdx_getting_started_usb.py' and have to restart the kernel after running once. I'm using the belt as ground truth for my other project. So I'm fine with getting measurements this way. I'm using Python 3.7 with Spyder IDE and Windows 10 OS.