Need Help With Sequence


Recommended Posts

I am new to DAQfactory, and am not familiar with the coding.


What i would like to do seems simple, but I'm not sure where to start. 


I would like to start a sequence by clicking a button, the sequence would then start a timer.  When i click stop i would like to obtain a reading as below. 


I would like to take an initial reading from a channel and subtract it from a final reading from the channel and divide by the elapsed time.


For example - (10 inches-0inches)/(5 seconds) = 2inches per second


I'm trying to learn, but i need some tips.  I figured out how to scale all the channels, and all that so i have all the data, I'm just not sure how to relate the deflection to time.


Thanks for the help!



Link to comment
Share on other sites

You actually don't need a sequence for this because timers are best implemented by simply recording a start time and subtracting that from the current time.  


There are two ways to do what you want depending on whether you are going to constantly read the input, or just when you click the button.  Actually, I suppose the method doesn't have to be different.  All you need is a global variable.  So, in the quick sequence Action for the button, put something like:

read(myChannel) // force a reading right now
global startReading = mychannel[0]

Then, for the stop button, create a similar quick sequence:

read(myChannel) // again, take a reading immediately
global endReading = myChannel[0]

Now you have two variables with both the value and time, so you can just create a variable value component with this expression to get the rate:

(endReading - startReading) / (endReading.time - startReading.time)
Link to comment
Share on other sites


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