Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

Fuel Consumption Meter (Gravimetric Method)

Go to solution



I am trying to make a fuel consumption meter using gravimetric method in LabView. The idea is to get the initial weight then once the valve (manually operated) is open for a certain amount of time (e.g. 10 secs) get the final weight (via button click or if it can be done without button and not affecting the value of the initial weight the better). The fuel consumption will then be computed based on these data.


As of now, my code is working fine but I am suspecting it is not the correct way or efficient way. Also, I want my code to work continuously (not stop and re-run the vi over and over again) since I need to get multiple readings from a single test.


For additional information, I am using a load cell, a Dacell strain amplifier with display, and Arduino UNO board. The load cell is connected to the strain amplifier (+EXC, -EXC, +SIG, -SIG, GND). The Arduino is also connected to the strain amplifier via RXTX connection.


This is how the back of the strain amplifier looks like (below):

DACELL Strain Amplifier Back PanelDACELL Strain Amplifier Back Panel


My setup looks something like this (below):


Lab SetupLab Setup


I attached a screenshot of my panel and block diagram .


Thank you.

0 Kudos
Message 1 of 16


If you post the vi I can make modifications and explain the correct dataflow you can use.

Anyhow I would start by building a subvi (select the three IO boxes and all the constants attached to it) and with all selected go to the menu edit/create subvi and see what happens.

You only have to do that once because the other three instances for IO can be replaced by the same subvi.


But the sequence thing you ask is easier to build from your vi than just from nothing.

greetings from the Netherlands
Message 2 of 16

Hi Albert.Geven,


I attached the vi. However, I made some modifications, what I did was make three loops that will run after the other. First loop will stop running through a button value change, the next loop will run then it will stop as well through a button value change. Lastly, the fuel consumption will be computed after running the two loops. As of now, it runs properly but it will only run once as it was coded like that. What I want to happen is that it will run continuously unless the user stops the program. The key note is that the program shall record the initial weight then record the final weight after opening the valve for 10 seconds.


Later on, I will include a write data algorithm wherein all data will be recorded in an excel file.


Thank you for your response. I will try what you suggest about building a subvi.


Again, thank you very much.



0 Kudos
Message 3 of 16
Accepted by topic author Jerson_Jose


In the diagram I have noted down the interesting changes.

see both attached files

greetings from the Netherlands
Download All
Message 4 of 16

Wow. This works perfectly fine and far more efficient than what I created. Just need to add some more functions and it will all be good (actually I am now thinking of making it more automated, time-dependent instead of button-dependent action). Anyways, what you did is really helpful. Thank you very much.

0 Kudos
Message 5 of 16

Glad to be able to teach some stuff.

If you need more, just ask.

greetings from the Netherlands
Message 6 of 16

I will keep that in mind. Again, thank you very much!

0 Kudos
Message 7 of 16

Hi Albert.Geven,


I made some changes to the vi. Instead of button action to start/stop the loop, I made it time-dependent. The first loop will stop 5 secs after running the vi. The second loop will start as soon as the first loop stops. It will run for 10 secs. The vi will only stop when the Stop Button is clicked.


Now, what I want to do is to re-initialize the two While Loops action. I inserted the two loops inside a Case Structure. The case structure is then placed inside another while loop. A Start Button will re-initialize the While Loop once clicked. The current algorithm can do just that. However, it is not working as I want it to be. What I want to happen is when the Start Button is clicked again, I want the timer (elapsed time) to reset back to its initial value and not continue where it stopped from the previous run.


In addition, I don't know what to do with these three wires (see pic below). If I create a constant of zero (0), obviously, I would not be able to compute anything. I tried making a shift register on the outside While loop and connect the three (3) to it but still I am not getting the result I want.


Screenshot (61).png


Screenshot (59).png


If you could help me these issues, I would greatly appreciate it.


Thank you very much!

0 Kudos
Message 8 of 16



I inserted the computation algorithm inside the Case Structure which fixed my issues with the three wires. However, the Reset button is still not working the way I want it to be. The Elapsed time does not reset back to zero. It's just continuously running on the background even if the two loops have stopped running.


Screenshot (63).png


Screenshot (64).png



Attached is the updated vi. 


Thank you!

0 Kudos
Message 9 of 16


The solution you use for the 3 wires is the correct one.

The elapsed time vi is not what you need.

You want the first loop to continue during 5 seconds and the second during 10 seconds.

So the best you can do is measure the actual time before the while and measure the time already passed in the while.

Because the measurement is determining the pace of the loop you will only ask a few times what time it is so no problem with a heavy extra load on the system.

I have also changed some other elements, especially I removed the refresh button, because pressing play already indicates that you want to measure again. 

A hint is to save all measurements in a while loop during the time the loop runs and than calculate the mean or even better the median of all these values.


You will see I did just that.

Also look at the warning about the Boolean comparing with True. That is probably removed by the compiler because that functio is already present in the Boolean value itself. 


Please make the labels of indicators and controls visible in the block diagram. Makes it much easier to read who is meant for what.

Alos make sure no wires are hidden by other objects. Readability is utmost in all programming languages, this are the two for LabVIEW next to make it as simple as possible but not simpler


Als try to learn by playing with median and mean why Median has some features especially when spikes are being read.


PS I did not test the vi so please keep me informed.

greetings from the Netherlands
Message 10 of 16