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

USB LabJack and Raspberry Pi


  • Please log in to reply
24 replies to this topic

#1 Blis

Blis
  • Members
  • 1 posts

Posted 29 April 2012 - 08:29 AM

It is possible to connect LJ DAQ (eg. U3) to Raspberry Pi and get it working? Raspberry uses Debian on ARM processor. I would like to control LJ U3 by Python application.

#2 ctodd

ctodd
  • Members
  • 23 posts

Posted 30 April 2012 - 02:26 PM

I was just thinking the same thing last week. RaspberryPi uses a USB phone charger for power, but I fear that's not going to supply enough juice for the LabJack, depending of course what you are trying to do. I haven't gotten my hands on one yet... If you can use a large enough power supply, and the RaspBerryPi can provide enough current to the built-in USB port, then great. I'm thinking an external supply such as a powered USB hub could sit between the RaspberryPi and the LabJack, and that may give added protection to the RaspBerryPi if you tried to source too much current. Hope this helps... Chris

#3 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 01 May 2012 - 03:56 PM

We ordered a Raspberry Pi last week, but the lead-time is 5 months so it will probably be a while before we can toy around with one.

Hardware-wise, powered over USB the U3 and U6 draw about 100 mA or less, and the UE9 is a little over 100 mA. They will probably work fine powered directly by Rasberry Pi's USB host, but to be safe and to use multiple USB devices you should consider using an externally powered USB hub as Chris mentioned or in the UE9's case you also have the option to connect a power supply directly to it.

Software-wise, we provide an open source Linux driver (Exodriver) and Python library (LabJackPython). Our driver requires libusb 1.0, so first you will want to get that compiled and running on Raspberry Pi if it is not already installed. Next, compile and install the Exodriver and LabJackPython. If you run into problems you can post back here and we can help troubleshoot.

#4 SteveOll

SteveOll
  • Members
  • 14 posts

Posted 07 May 2012 - 07:30 AM

I have a Raspberry Pi on order for delivery early June 2012, I have been waiting to test it out. I have a mobile phone type charger for the Raspberry Pi (Micro USB Type B) that will supply up to 1Amp so hopefully that will be enough to power both devices. My initial fear was that they were to include Python 3 with the Linux OS images for the PI, but as they have a Debian OS it should be Python 2.6 so everything should be okay using Labjack Python. I will let you know how things progress... Good job the Raspberry PI has not arrived yet, I have 2nd year exams at Uni starting tomorrow!

#5 fhartojo

fhartojo
  • Members
  • 1 posts

Posted 07 May 2012 - 03:11 PM

Not a RasPi, but I managed to connect a U3 to a Pandaboard ES using the standard process for Linux. The Pandaboard is running Linaro 12.04 with the latest updates. The power supply is 5V 2.1A. FWIW.

#6 SteveOll

SteveOll
  • Members
  • 14 posts

Posted 28 May 2012 - 09:24 AM

I received my Raspberry Pi today and after the setup of the Debian GNU Linux image on the SD card I followed the Exodriver installation instructions which all worked flawlessly. Here's photos of the Raspberry Pi and U3-HV setup and a screenshot of the Python script just to demonstrate it working: SANY0076.JPG SANY0074.JPG Now I just need to get a decent USB Hub to save all the cable swapping on the USB ports... -Steve

#7 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 29 May 2012 - 02:46 PM

Thanks for posting this. We have yet to get our Raspberry Pi, but I am glad to hear that it is working with the standard Exodriver installation. We are going to make a blog post about this on our main site:

http://labjack.com/blog

#8 SteveOll

SteveOll
  • Members
  • 14 posts

Posted 29 May 2012 - 04:10 PM

Here's a photo of my 2nd year Mechatronics project which uses a U3-HV to control some electronics (apologies for the poor quality photo) SANY0083.JPG I did not have the Raspberry Pi when I originally finished the project, but I ran the Python script using Debian GNU Linux on a netbook. If this is of interest for your blog, I'd be happy to share the details and provide better photographs. -Steve

#9 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 30 May 2012 - 09:51 AM

Sure! Send an email to [email protected] with the information, and some photos.

#10 amitchell

amitchell
  • Members
  • 11 posts

Posted 29 June 2012 - 12:24 PM

I've also got a U3 working with my Raspberry Pi using their Debian distro. I'm using a Macally Mini 4-Port powered USB 2.0 Hub (available on Amazon), which I also use to power the Raspberry Pi through a USB A-to-Micro cable. I'd love to see you sell a U3 packaged with a Raspberry Pi and powered USB hub. Having a couple empty USB ports would allow connection of second U3, keyboard, mouse, etc. I spend too much time figuring out how to mount all those devices in my projects.

#11 raul.suarez.marin

raul.suarez.marin
  • Members
  • 4 posts

Posted 03 September 2012 - 02:55 AM

Hello. Since I've been trying to use Arduino for acquisiting data and it didn't work, what lead me to a Raspberry topic saying that USB has loss of packets... I don't trust some USB devices. I would like to know which is the maximum sampling rate that people get with LabJack U3 HV and Raspberry Pi. Regards, Raúl Suárez

#12 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 04 September 2012 - 05:12 PM

Doing some quick tests today with our Raspberry Pi, command/response times are comparable to the documented "USB high-high" times in the U3 User's Guide without the need of a USB hub:

http://labjack.com/s...users-guide/3.1

With 0 AIN speeds are about 1.07 ms instead of 0.6 ms, though with more AINs I noticed that many times were better than the ones in the table by hundreds of microseconds.

For the highest input data rates look at stream mode:

http://labjack.com/s...users-guide/3.2

The maximum stream rate is 50000 samples/second.

Tests were done with a U3, keyboard and monitor connected to the Raspberry Pi running the Raspbian image provided on the Raspberry Pi website. Timing tests were done with our C examples. So far I haven't ran into USB packet loss and I've tested with a couple million USB send/receive calls.

#13 raul.suarez.marin

raul.suarez.marin
  • Members
  • 4 posts

Posted 07 September 2012 - 04:18 AM

My university is going to buy one of these. We will give a try. Thanks, Raúl Suárez

#14 Tim P.

Tim P.
  • Members
  • 2 posts

Posted 05 February 2013 - 03:25 PM

So I've been having a difficult time trying to get my labjack python script running on my RasPi. I built a Debian virtual machine in my Windows machine to make sure I understood everything before I got the Pi. On the Deb VM I installed the binary dev package of libusb 1.0 with [codebox]sudo apt-get libusb-1.0-0-dev [/codebox] and it appeared to be ok, so I continued with the exodriver and labjackpython, which when I tried to ping my U3 I got a LIBUSB_ERROR_ACCESS error. Eventually I got it working by downloading the source code for libusb-1.0.9, building it and installing, and reinstalling the exodriver and labjackpython. However that same course of action with the RasPi gave the same error as before. I built and installed libusb 1.0.9, then the exodriver and labjack python. when I script [codebox]>>> d= u3.U3()[/codebox] I get a LIBUSB_ERROR_ACCESS Tried changing the libusb.h include precompiler directive to point right at the file, but that doesn't seem to help. I suspect its a problem with the libusb installation. I'm still investigating but I wanted to make sure that folks who have made this work didn't do anything special on the RasPi that I'm missing. Or if anyone has seen issues with libusb 1.0 on the pi. Things checked: no brownout on power up, USB hub provides enough power for devices, dmesg command shows labjack u3 in the list of connected devices, so everything should be ok. I'm a little befuddled right now.

#15 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 05 February 2013 - 06:43 PM

Usually LIBUSB_ERROR_ACCESS indicates a permissions issue. First make sure during installation you ran these commands: $ sudo cp 10-labjack.rules /etc/udev/rules.d/. $ sudo udevadm control --reload-rules Also, make sure the current user you are logged as is part of the "adm" group. For more details refer to the INSTALL.Linux documentation in the Exodriver download as there is a section on this. After you have made sure the above is ok, power cycle your LabJack so that the new device permissions are applied.

#16 Tim P.

Tim P.
  • Members
  • 2 posts

Posted 06 February 2013 - 12:12 PM

Usually LIBUSB_ERROR_ACCESS indicates a permissions issue. First make sure during installation you ran these commands:

$ sudo cp 10-labjack.rules /etc/udev/rules.d/.
$ sudo udevadm control --reload-rules

Also, make sure the current user you are logged as is part of the "adm" group. For more details refer to the INSTALL.Linux documentation in the Exodriver download as there is a section on this.

After you have made sure the above is ok, power cycle your LabJack so that the new device permissions are applied.


Yep, you are correct. I reinstalled per your instructions and everything is good now. Thanks a lot!

#17 bdog

bdog
  • Members
  • 27 posts

Posted 08 April 2013 - 07:57 AM

I've embedded Labjacks into one of our test instruments for quite a while. Our instruments are used in very nasty industrial environments, and using the Raspberry PI it would be possible to add a touchscreen to an enclosure that embeds a Labjack and our instrument, and remove the laptop from the test loop. Anyone experimented with the Raspberry PI real-time graphics display and a Labjack?

#18 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 08 April 2013 - 11:19 AM

We've only experimented with LabJacks and a normal monitor, but it sounds what you want should be possible. For touchscreen discussions you will want to head over to the Raspberry Pi forum. On the LabJack side any device but the U12 will work fine. At this time there seems to be HID issues with the Raspberry Pi and the U12 is a HID:

https://forums.labja...?showtopic=6075

#19 Meilhaus Guy

Meilhaus Guy
  • Members
  • 2 posts

Posted 17 September 2013 - 08:14 AM

As a complete dope as far as Linux is concerned, I was hoping to learn a bit more with the Raspberry and a LabJack. Unfortunately I'm not getting anywhere. Could someone please write up a step-by-step description of what I had to do, to at least be able to blink the LED or some other basic task, that I can go on programming from there? I've already got the book "Raspberry PI for Dummies", but there isn't a whole lot of information there on the implementation of any other hardware. Thanks in advance for your help!



#20 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 18 September 2013 - 10:26 AM

Take a look at the "In-depth Linux build instructions" section on the Exodriver page. It has Ubuntu instructions on getting the Exodriver and LabJackPython installed, and then getting the configuration settings from a LabJack U3. These instructions will generally work on Debian based distributions such as Raspbian which is commonly installed on a Raspberry Pi. From there take a look at the LabJackPython page for using a LabJack in Python or look in the Examples directory of the Exodriver download for C language examples.

 

If you need further help let us know what LabJack you are using and where you are running into problems.



#21 hmm

hmm
  • Members
  • 4 posts

Posted 01 October 2013 - 09:49 AM

I have a U3-HV connected to a Raspberry Pi, installation was very simple, I followed the excellent linux install instructions (pointed to in the post above) and I'm running Python to interact with it and reading the Analog inputs is fine.

I seem to be running into some issues when streaming though: I'm trying to run streamTest.py supplied in the examples.
Running any scan frequency over 2,000Hz results in errors

d.streamConfig( NumChannels = 1, PChannels = [ 0 ], NChannels = [ 31 ], Resolution = 0, ScanFrequency = 2000 )

I get a mix of error code 47(? can't find a reference for this error code ) & 48 (STREAM_IS_ACTIVE).

 

With a resolution = 3 and ScanFrequency = 8000 I get error code 40 (SHT1x_COMM_TIME_OUT).

 

Can anyone shed any light on what I'm doing wrong or am I hitting the limit of the RaspPi hardware (it has a hypothetical USB bus speed of 60 MB/s) ?

 

The U3 is the only thing plugged in, the RaspPi is headless and I'm accessing it over SSH, so no keyboard / mouse.

 

thanks in advance for any ideas,



#22 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 01 October 2013 - 03:54 PM

'errors' is actually the number of errors detected per streamData call. So 40, 47 and 48 are error counts and are not error codes. Most likely you are seeing 'missed' readings indicating a stream buffer overflow and auto-recovery. Doing some tests, the default Python installed looks like the bottleneck. Turning stream data conversion off (streamData(False)) you can get closer to a sample rate of 10,000 Hz, but still not close to the U3's limit of 50,000 Hz.

 

Programs in C/C++ look like they handle up to 50,000 Hz sample rates as expected, so I would recommend using C for streaming over 2000 Hz. The Exodriver download contains a low-level streaming example.



#23 Meilhaus Guy

Meilhaus Guy
  • Members
  • 2 posts

Posted 02 October 2013 - 01:53 AM

I ran into a problem with the install. I read the http://labjack.com/s...ac-os-x-drivers and it all seemed to work fine until I got to

>>> d = u3.U3()

I get a message back from the system stating: Couldn't open device. Please check that....

 

I have a U3LV connected and the LED is on. Is there a function example that would flash the LED, just to show that the U3 has been found?



#24 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 02 October 2013 - 10:41 AM

After your first installation you may need to power cycle your U3, and if you were newly added to the 'adm' group you will need to log off the user and log back in. Try these and see if it helps.

 

Also, if d = u3.U3() doesn't raise an exception then your U3 was found. To toggle the U3's LED you can use the toggleLED method or use the getFeedback method with the LED IOType after connecting to your U3. For example:

 

>>> d.toggleLED() #Turn off LED

>>> d.toggleLED() #Turn on LED



#25 hmm

hmm
  • Members
  • 4 posts

Posted 03 October 2013 - 05:41 AM

Programs in C/C++ look like they handle up to 50,000 Hz sample rates as expected, so I would recommend using C for streaming over 2000 Hz. The Exodriver download contains a low-level streaming example.

 

Running a few streaming tests in C it all looks good on the RaspPi. It benchmarked ever so slightly higher than a Proliant MicroServer (2.2Ghz dual core) running an identical test file.

On a short 1000 sample streaming test the RaspPi started erroring at 54,360Hz, the Proliant at 54,176Hz.

 

On longer sustained sampling it maxed out at closer to the stated 50,000Hz at 50,526Hz.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users