Processing language | LabJack
 

Processing language

9 posts / 0 new
Last post
johnson
Processing language

Hello,

I'm just wondering if anyone has played with the processing language to interact with Labjack devices.

https://processing.org/

It is commonly used with Arduino projects. Not my specialty by a long shot but I thought it might be another good match for some real time data plotting from a T7-pro. If there are examples out there I would love to see them!

Thanks,

- Jason

LabJack Support
labjack support's picture
Over email we've helped a

Over email we've helped a customer with Processing, but we don't have examples available on our site.

You can use our devices with Processing in a similar way you would in Java. We provide Java wrapper and examples to help get you started:

https://labjack.com/support/software/examples/ljm/java

First you will need to install the LJM Library:

https://labjack.com/support/software/installers/ljm

Then on the Processing side, I believe you copy the ljm.jar and jna.jar from our Java download (or a newer jna.jar from their website as it is third party) to the "code" folder of the sketch. In the Processing code use Java syntax like in our examples.

johnson
So I started thinking about

So I started thinking about this a year ago and then forgot about it until I was so frustrated with LabVIEW this week that I came back to have another look.

In case others are interested here's what I had to do to get some results with a T7-pro via Processing 3.1.2:

1.) Create a Processing sketch, then use the "Sketch" drop down menu to "Add File". Add LJM.java and LJMException.java from the Java wrapper provided at the link noted above

2.) Start hacking away at the provided examples (also from the LJM Java wrapper since I don't really know Java...) copying and pasting into the processing sketch

3.) Save sketch once satisfactory. Then (Coolest part!) deploy finished application by using "File" drop down to "Export Application"

4.) Run the main Labjack installer on the target machine to get drivers. Also copy over the exported application folder.

5.) Plug in T7 and wait until its recognized, then double click the deployed application. Now sit back and enjoy your standalone program...

The coolest thing about this (in my opinion) is that Processing is easy to use, free, open source and well documented. It also has a huge online community and a variety of addon packages. They make deployment easier than anything else I've ever used (though I only program out of necessity).

I hope this is useful to someone. I've attached a simple program that reads back a serial number and 4 AIN values along with some screenshots.

Regards,

- Jason

johnson
Oops, step 1 should have read

Oops, step 1 should have read:

1.) Create a Processing sketch, then use the "Sketch" drop down menu to "Add File". Add LJM.javaLJMException.javaljm.jar and jna.jar from the Java wrapper provided at the link noted above

- Jason

LabJack Support
labjack support's picture
Jason,  thanks for looking

Jason,  thanks for looking into the processing language and posting an example that others can use.  We verified the compiled .exe that is in the .zip file that runs the program on a Windows 10 64-bit computer.  We also quickly installed the 64-bit version of processing (version 3.2.1), created a new sketch by opening the included .pde file and saying yes to the dialog box about it needing to be in a sketch folder.  Then also added the two .java files.  The example was then able to compile and run.

LabJack Support
labjack support's picture
If user's don't want to

If user's don't want to download and execute pre-compiled code or if they want to run the code on a different operating system, attached is a .zip file of the simple sketch that Jason made.  It doesn't look like any warnings/errors are thrown when running the code from processing.  Users should be able to do the following:

  1. Download and install the LabJack driver
  2. Download and install Processing
  3. Download and extract the .zip file
  4. Start Processing
  5. Use the file->open dialog to navigate to the extracted .zip file and open the included .pde file.
  6. Connect a LabJack T7.
  7. Press the play button.

We were able to quickly get this going on a Mac OS X and Linux 32-bit virtual machine.  Ubuntu version 14.04.02.

File Attachment: 
LabJack Support
labjack support's picture
Got this processing example

Got this processing example (only slightly modified) posted onto our LJM Example Code/Wrappers page.  Modified your example to show AIN0-AIN3 which are available on the device's screw terminals instead of AIN1-AIN4.

Jason, thanks again for your help.  Feel free to upload and share any other processing examples you come up with.

johnson
Here is a slightly more

Here is a slightly more interesting one. Wire DAC1 to AIN0, then run as above. I added comments to the code this time as well :-)

It would not take much effort to add axis labels and whatnot. Processing is super easy to learn; the real Java content is a bit trickier IMHO. FYI there are Python and Android modes available that I haven't used. I'm willing to bet one could get the Python LJM wrapper to play nice in the Processing IDE just as easily as the Java one. Also maybe somebody can leverage the Android tools in Processing for mobile App development...

I am very glad that this seems helpful; I really would love to see other people run with this and improve on it! 

File Attachment: 
Blaise
Blaise Mibeck's picture
I am really thankful for this

I am really thankful for this Johnson!

I am not a fan of LabView.