LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Using LabVIEW with Arduino HX711 Load Cell with VISA only

I found a new solution to getting Labview to import data from a HX711 ADC. The confugration is an Arduino Uno connected to computer with USB and HX711 ADC connected to a load cell. Instead of using Labview to sample the HX711 board, I created a method to have Labview sample the Arduino's serial monitor and use the Arduino's HX711 libraries with the Uno to sample the load cell.

 

I wrote an Arduino code that is loaded before running the Labview (you cannot have both on at same time) waits to sample the load cell until a serial write is performed from LabVIEW ("ON"), then the Arduino code start sampling the load cell and printing the measured values into the serial monitor. After the Labview writes the "ON" string, it then reads the serial monitor using a VISA read to obtain the load cell values. This method was difficult to create but easy to implement if you have the code, which I will attach.

 

1. Just upload the Arduino code first (with Labview not open) to the board with the standard HX711 configuration w/ load cell or what ever sensor that uses a strain gauge (I used it for torque). Make sure to edit the calibration constant and zero offset for the load cell in the Arduino code (or set to "1" and "0" respectively it to pull raw data in).

2. Then close the Arduino IDE and open the Labview VI (attached) and run the LabVIEW VI, which will write the "ON" string to start the Uno's sampling, verify data is being written into the Uno's serial monitor, and begin reading the load cell data from the serial monitor.

3.Once you are finished make sure to toggle the STOP button, which writes an "OFF" string, to stop the Uno's sampling and the Labview's Visa read when you are done.

3a.The one thing I found was, you want to make sure to stop the Uno's sampling otherwise the serial monitor will fill with old data, and on the next read cycle Labview will read old data until it catches up with the difference in sampling rates (Arduino = 80Hz, Labview = while loop rate).

Paul_MAE_0-1609652143878.png

 

This method seems to be the easiest because it uses the already well developed HX711 libraries developed in Arduino to sample the load cell instead of rewriting all of it in Labview.

 

Notes: Make sure to have the HX711 and QueueHX711 libraries in your Arduino Library, and make sure the Arduino IDE is closed before running the Labview VI.

Message 1 of 7
(5,471 Views)

Hi friend. I think your case is just a specific situation that is among general purposes of the VISA and its related functions under the Instrument I/O function category in LabView. We can use these to benefit for cases that LabView does not have desired controls / indicators yet for your aimed experiment.

 

In my case, I don't want to set up for a complicated block diagram to control a stepper motor so I used the VISA communication to facilitate and control it via a single input for a desired angle. This case I used the Write function while you used the Read function to get signal from loadcell / HX711, didn't you?

 

  Edited: Ah .. I have just seen your block diagram as you used both Read and Write functions .. 🙂

0 Kudos
Message 2 of 7
(5,335 Views)

Hi,

 

This code enables the use of an HX711 analog to digital converter to read a load cell.

 

I used Read and Write functions, the write functions told the Arduino to begin sampling the load cell and store the data in the serial monitor, the read function pulled the data from the serial monitor into labview, and the second write function (linked to stop button) stopped the sampling of the load cell. 

 

I posted this because I had seen several threads that offered suggestions to solving this problem (HX711) but none that actually provided a solution beyond an application that could not be edited.

 

This solution is for a loadcell and HX711 ADC, I am not sure why you would reference this to control a stepper motor. Do you have any feedback on the system? is that why?

0 Kudos
Message 3 of 7
(5,328 Views)

Hi Paul,

Dropping by the forum to view some interesting topics then I have noticed to your post which makes me excited as I used the same VISA as a communication gateway to control stepper motor. This communication way could be used for different purposes as well.

Cheers.

0 Kudos
Message 4 of 7
(5,326 Views)

Ah I see, yes the VISA can be used for any device that uses serial communication I believe.

 

0 Kudos
Message 5 of 7
(5,323 Views)

Hey Paul, I am currently trying to utilize your code and vi for the HX711 and load cell to get some sort of reading on Labview. Having previously tried to do this myself and failed miserably as I'm relatively inexperienced with Arduino code. 

When I upload your code i get this error message :

 

"no matching function for call to 'HX711::HX711(const byte&, const byte&)' "

 

Could you help me out here please? would be much appreciated, thanks.

0 Kudos
Message 6 of 7
(5,205 Views)

Hi,

I had the same problem, I change it with 

Q2HX711 hx711(hx711_data_pin, hx711_clock_pin);

and the error is gone. but it doesn't show me any data in the serial monitor. 😕 

Can anyone help me with that?

 

Best,

Samaneh

0 Kudos
Message 7 of 7
(4,678 Views)