Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Raspberry Pi U12 sporadic LIBUSB_ERROR_NO_DEVICE


  • Please log in to reply
13 replies to this topic

#1 alexetch

alexetch
  • Members
  • 5 posts

Posted 28 February 2013 - 08:09 AM

Hello I'm playing with a Pi and 2 labjack U12s I have a very simple loop reading the analog signals about once a second. randomly I will lose a labjack with the error LIBUSB_ERROR_NO_DEVICE sometimes restarting the program will get it back, sometimes I need to reboot the Pi. I have also seen this when running only one U12 I have tried using rawAISample() and eAnalogIn() I have not experienced these issues when running similar programs under ubuntu on a regular PC so I fear it may be down to the Pi which would be a real shame as I had plans..... thoughts and/or suggestions welcome Alex

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 28 February 2013 - 02:06 PM

It could be power related. Have you tried using a powered USB hub and see if that helps? Also make sure your Raspberry Pi's power adapter is good quality and can provide at least 700mA at 5V. That is what Raspberry Pi documentation recommends, and using less can cause erratic behavior.

#3 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 28 February 2013 - 03:57 PM

Also, does your test program usually run for a certain amount of time before the "LIBUSB_ERROR_NO_DEVICE" errors occur? Do you have this problem when there is nothing connected to your U12?

#4 alexetch

alexetch
  • Members
  • 5 posts

Posted 01 March 2013 - 01:09 AM

Using a hub (actually a Dell monitor) which also powers the Pi. Problem can occur within 20 seconds U12 is currently measuring nothing or its own 5v output. I will hunt down an alternate hub and see if that helps and then post again thank you for suggestions Alex

#5 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 01 March 2013 - 05:40 PM

To clarify, when I mentioned trying with a USB hub I meant for powering the U12s and that the USB hub had its own power supply. I believe a hub can power a Raspberry Pi but it will need its own power supply and not all of them will work. I did some quick tests with a couple of U12s. I used a USB hub and would occasionally get communication errors (no LIBUSB_ERROR_NO_DEVICE errors), though disconnecting the keyboard and only having the U12s running seemed to help. Keyboards and U12s are HIDs, and the issues I was experiencing may stem from buggy HID support on the Raspberry Pi. I also did the same tests with U3s and ran into no problems. Note that U3s are not HIDs (bulk endpoint communications) and use more power. I am running a Raspberry Pi with the the Raspbian image. It has the latest software from yesterday and kernel 3.6.11+.

#6 alexetch

alexetch
  • Members
  • 5 posts

Posted 05 March 2013 - 01:26 AM

The dell monitor in question includes a powered hub which I was using to power the U12s and Pi and a keyboard. I carried out a series of experiments: different powered hub - worse separate power to the pi - slight improvement only one U12 - noticeable improvement. In conclusion it would seem that the issues are power related but not easily solvable. This would appear to be borne out by your tests also. However, thank you for the possible solution in the form of the U3 you say that: "Note that U3s are not HIDs (bulk endpoint communications) and use more power." do you have figures for the U12 vs U3 power requuirement? -or could you point me towards this info? many thanks Alex

#7 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 05 March 2013 - 05:43 PM

The power requirements are 20 mA for the U12 and 50 mA for the U3. This information can be found in Appendix A of the User Guides (supply current):

http://labjack.com/s...uide/appendix-a
http://labjack.com/s...uide/appendix-a

If you are unsure about the your Raspberry Pi's power supply, consider the ones from the Raspberry Pi order pages. They will provide the proper current needed.

http://www.rs-compon...com/raspberrypi

As for the problems I was experiencing, I am not sure how much I can attribute to power issues as opposed to HID issues considering my more power hungry setup of two U3s and a keyboard ran fine.

#8 alexetch

alexetch
  • Members
  • 5 posts

Posted 06 March 2013 - 01:05 AM

Indeed as you say: the problem may be related to the number of HID devices connected Thank you for help and pointer towards the U3

#9 Jez

Jez
  • Members
  • 3 posts

Posted 31 March 2014 - 09:16 AM

I am experiencing the same problem.

I can confirm that it is indeed not related to the PSU quality as the problem occurs even with a rock solid lab PSU and the current isn't actually that lumpy anyway. I have also tried the U12 directly in the Pi and in a powered Hub, no difference, still more flaky than a croissant in a wind tunnel.

I have tried to implement some try/except code in python to catch the problems but it doesn't work well at all, it's retrying continuously once it encounters a problem. Maybe it needs to close and re-open the connection? Not sure, you guys are the experts and I'm asking for some expert advice.

Can you suggest a simple Python try/except example that would solve it, I don't even mind if it caused occasional delays but the thing needs to run gracefully (which it doesn't at all currently).

By the way, I've noticed that it looks like the U12 itself is crashing. My other HID devices work flawlessly before, during and after the U12 crash. The U12 LED flashes its little head off when the crash happens so it appears as the microcontroller in the U12 is re-starting (possibly as a result of the alleged Raspi HID bug but possibly due to something else within the U12??).

Anyway, if you could come up with a teeny python try/except example that works well then I will buy more of these babies. Failing that, can you send me a U3 for free for my troubles? 

Cheers,
Jez



#10 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 31 March 2014 - 03:20 PM

Here's a quick, simple example that displays analog input readings in a loop and performs reading retries if any exception happens during the read. Use Ctrl-C to exit the loop:

import u12
#import time

d=u12.U12()

i = 0
while 1:
    #time.sleep(0.5)
    retries = 0
    while 1:
        try:
            res = d.eAnalogIn(0)
            print res, ", retries:", retries
            break #Got our reading
        except Exception as e:
            retries+=1
            if retries > 5:
                #Might be something other than a couple missing
                #communications, such as a U12 disconnect.
                #Displaying error and exiting in this example.
                print e
                exit(1)

I didn't run into issues with the U12 resetting, crashing or needing reopening, though I only did quick tests. If a reading retry was necessary, typically it took me 1-2 retries. Let us know if implementing a try/except scheme similar to above doesn't help, and provide your code here or by email so we can try to reproduce the problem as the U12 crashing is unexpected. Also, make sure you are using the latest LabJackPython on github.

 

If you plan on getting more LabJacks to use with the Raspberry Pi, I would recommend the U3-LV/HV over the U12 for USB communication stability reasons.



#11 Jez

Jez
  • Members
  • 3 posts

Posted 02 April 2014 - 08:53 AM

Hi Admin (sorry I don't know your name),

 

Thank you very much for the suggested code.

 

Sadly this has the same problem as my try/except code and attempts to retry over and over (until it hits 6 retries) as soon as a problem is encountered.

 

I've noticed that the problem is much worse if I try and set the output voltage in my loop rather than just reading the ADCs.

 

Here's my code (based on your example but with the added DAC command):

 

import u12, time

 
d=u12.U12()
 
i = 0
while 1:
    #time.sleep(0.5)
    retries = 0
    while 1:
        try:
            d.eAnalogOut(analogOut0=1.23, analogOut1=2.46)
            time.sleep(0.25)
            res = d.eAnalogIn(0)['voltage']
            
            print (res,", retries:", retries)
            break #Got our reading
        except Exception as e:
            retries+=1
            if retries > 5:
                #Might be something other than a couple missing
                #communications, such as a U12 disconnect.
                #Displaying error and exiting in this example.
                print e
                exit(1)
 
As soon as a problem is encountered (at a random time), the number of retries hits 6 (with no intervening number of retries displayed) and a prompt appears "The program is still running! Do you want to kill it?". The displayed exception is "Could only write 0 of 8 bytes."
 
Can you reproduce this error?
 
Thank you for your help again, it is appreciated. Any chance of a free U3?


#12 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 April 2014 - 03:09 PM

The current LabJack Support person handling your issue is David.

 

I ran your code and when connected directly to the Raspberry Pi it does look like it causes a reset on the U12 eventually. My guess is a communication problem causes this but I am unsure of why the reset is occurring.

 

On the other hand, when the U12 is connected to a USB hub, a communication error does not cause the U12 to reset and retry calls can be performed. I ran your code for more than 30 minutes with the hub before I stopped it. I do my tests on a hub, so I didn't see the resets in my original tests.

 

Try running your code with your U12 connected to a USB hub (it sounds like you have one), and see if the retries work. Also, the 6 tries my code performs is not a well tested number, so you can bump it up if you need to.



#13 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 April 2014 - 03:14 PM

Contact [email protected] if you want to discuss a donated U3 for some cause.



#14 Jez

Jez
  • Members
  • 3 posts

Posted 03 April 2014 - 01:56 AM

Hi David, thank you for your replies and assistance.

 

Yes, your code does run great when the U12 is connected through the hub. I've ran it for around an hour so far and no problems. No U12 crashes or LED flashing.

 

It's a shame it won't run happily without a hub as we planned to run these Raspberry Pis "headless" and only connected to power and the U12 for our array of test kit, keeping things to the bare minimum is a real attraction (no PCs, no keyboards, no monitors just the Raspi and U12). I suppose the addition of a powered hub isn't a problem, just not quite as nice!

 

I think we will go for U3's for our further requirements, I'll get in touch.

 

Thanks again for your support David.

 

All the best,

Jez




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users