2 channel division with voltage feedback and taring function


Marcus_tribscan

Recommended Posts

Hello,

I'm new to DaqFactory (using a LabJack U3 with a LJTick-Inamp) and this is what I want to do:

1. Read input from two different load cells (full bridges) and present the force values in a graph.

No problem.

2. Have a taring button (which reads the offset values at the start of a measurement for both load cells and and "anti-offsets" these offset values to the value 0 (so that zero force is registered at the beginning of a meaurement)).

Don't know how to do this.

3. Introduce a third graph where the quotient (load cell A/ load cell B) is presented.

Don't know how to do this.

If someone could point me in the right direction I would be grateful!

Regards

Marcus

Link to comment
Share on other sites

2)

a) declare two global variables in a sequence marked auto-Start. Something like:

global loadCellATare = 0

global loadCellBTare = 0

B) create two Conversions and apply them to the appropriate loadCell channels. Their expressions would be:

Value - loadCellATare

and

Value - loadCellBTare

c) create a button to do the tare. Quick Sequence Action:

loadCellATare = 0

loadCellBTare = 0

read(loadCellA)

read(loadCellB)

loadCellATare = loadCellA[0]

loadCellBTare = loadCellB[0]

Note that I have to reset the tare to 0, read values with 0 tare, then reassign. This assumes you named your channels loadCellA and loadCellB

3) just put loadCellA / loadCellB in the Y expression of the graph.

Link to comment
Share on other sites

Great answer! A couple of follow up questions:

What type of priority should be set to the autostart sequence, logging?

Also, with logging chosen for the sequence (and with the LoadcellATare variable directly subtracted from the already existing conversion for LoadcellA) it seems like pressing the new tare button twice returns the old un-tared values, would this be correct?

Also, for the tare button, would it be possible to sample a few values from LoadcellA with the read function and use the mean value from those samples instead of just one single value, my original signal is kinda semi-stable?

loadCellATare = 0

read(loadCellA)

loadCellATare = loadCellA[0] : For me it would be better to use say 5 readings, something like

loadCellATare = loadCellA[mean(0:5)]

Best wishes

Marcus

Link to comment
Share on other sites

Priority: doesn't matter, leave it at 5. You don't have a loop so the sequence will run quickly and stop

Double tare: possibly. You'd have to investigate the order of operations. Its why its sometimes better not to use conversions, but instead to create a V channel with the tared value, and leave the raw value in the regular channel alone. Then you don't have to set the tare variables to 0, then read, then set the tare values. If you are going to do mean, then this is probably the best choice. Then you can just let the channel read on its own, and you can do loadCellATare = mean(loadCellA[0,4])

Link to comment
Share on other sites

Using the V channels worked fine! My program now looks like:

Sequence:

loadCellATare = 0

loadCellBTare = 0

The 2 V channels:

Direct copies of my 2 channels (no other operation in their definition)

The tare button now uses the V-channel values:

loadCellATare = v.vertical_force[0]

loadCellBTare = v.horizontal_force[0]

I then calculate the tared force according to

v.vertical_force[0]-loadCellATare[0]

I use the same approach for the graph expressions and it works just like it should which is good!

Now my problem is how to log the V-channels with the aritmetic expressions, especially as my main interest lies in the quotient between the two V-channels (horizontal_force / vertical_force) with the included tare-values for each V-channel...?

Regards

Marcus

Link to comment
Share on other sites

The easy way to log V channels is to not use V channels in first place. Use a regular channel instead, Test / D to A with a unique channel number. Or use a Test / A to D / Timing = 0, and use myChan.addValue() to put the value into that channel.

You could also use an export set to log V channel data

Link to comment
Share on other sites

  • 1 year later...

Hello!

It's been a while since this thread was started but I think it's time for a follow up on the last post :)

I'm looking at switching to high speed streaming from my LabJack U3 and I thought that as a first step I would get rid of the export sets and the virtual channels, switching to logging instead.

I created a short auto-start sequence to put the tared values in the 2 new test channels (Test / A to D / Timing = 0), instead of having them in the virtual channels and that works fine...

Here's the sequence:

while(1)

myChan_1.addValue(vertical_force-loadCellATare)

myChan_2.addValue(horizontal_force-loadCellBTare)

endwhile

However, it seems that having the while loop in the sequence really slows down the overall performance in the program(graphs not updating as frequently as before), is there some way around this phenomenon?

Regards

Marcus

Link to comment
Share on other sites

It slows down the performance because you have no delay() in your while loop. This loop will run as fast as possible, using as much CPU as it can get, causing the rest of the app to run slowly. If you put it at Idle thread priority (0), it won't affect much of the program but will stall graphs. You really need a delay(), probably with a value equal to the Timing of your two channels. So delay(1) if you are reading vertical_force and horizontal_force once a second.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.