Defining Constants


Recommended Posts

I am using DAQFactory with a LabJack to log the temperature. 

 

The temperature signal feeds into the LabJack via a voltage divider also to calculate the temperature from the resistance I have to perform a quadratic equation.

 

I have got all this to work but I am trying to make it simpler for others to use so I set up a page with popup's so the can define the voltage divider settings (R1 and R2) as well as the coefficients of the quadratic equation but I when I define R1 = 10 for example, anyhting that refers to it just updates the value at the time R1 was defined.

 

Is there anyway/anywhere I can define my constants which can be changed when the user decides? I've tried using 'test' devices with D to A outputs and I've tried creating V Channels but these only seem to work when the value is being updated periodically in time. I Just want to put R1 = 0 and leave it and change it later if I need.

 

Thanks

Link to comment
Share on other sites

A Test D/A is probably the way to go.  Set the Persist to 1 so it keeps the value after restart, and make sure the Timing is 0 (it should force that with D/A).  Set the History to 1 too so you don't get any history.  You can then do:

 

R1 = 3

 

and it will put that value in the channel.  And you can access it simply with:

 

R1

Link to comment
Share on other sites

Hi,

 

Thanks for your help but my problem still persists. Essentially what have done is set a conversion on the channel I am measuring the equation is just numbers and value i.e.

 

VoltageToResis = equation*value 

 

This conversion is applied to the channel TemperatureResistance so this displays the resistance of the probe. I then on the event tab of the TemperatureResistance channel did

 

Temperature.AddValue(equation*R0)

 

and in the Temperature channel it does update to the correct temperature but the issue I'm having is once I define this, the timestamp for the recorded data uses the time assigned to R0.

 

I have tried both R0 and R0[0].

 

Thanks again for your help

Link to comment
Share on other sites

TechGuy,

 

What do you mean by 'between restarts'.

 

I've tried making a new file with one input channel with LabJackUD as its device and then I added two test channels, one called output which would display the modifed data and the other channel called constant.

 

In the event tab of the input channel I wrote 

 

output.AddValue(input[0]*constant[0])

 

but I still have the problem where the timestamp for output is stuck on the timestamp for my constant

 

 

Steve, how do I define and redefine global variables?  

Link to comment
Share on other sites

I mean between when you quit DAQFactory and you start it up again.  Global variables will reinitialize to their defaults (if any).

 

You can fix the timestamp issue by using insertTime():

 

output.addValue(insertTime(input[0]*constant[0], input.time[0], 0))

Link to comment
Share on other sites

I mean between when you quit DAQFactory and you start it up again.  Global variables will reinitialize to their defaults (if any).

 

You can fix the timestamp issue by using insertTime():

 

output.addValue(insertTime(input[0]*constant[0], input.time[0], 0))

 

The insertTime(): function worked.

 

Thanks for the help

Link to comment
Share on other sites

Archived

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