10-22-2014 12:49 PM
LV 2014 Base with Application Builder
USB cDAQ with 9211 (4 Ch thermocouple)
USB-6211 (used for analog in and digital out)
This state machine vi is for long term (1yr+) monitoring of thermoelectric modules. My main question is whether I’ve used the state machine appropriately to make this system scalable. Am I on the right track? Can a state machine reasonably have 10, 20, or 30 states or is there an upper limit where another design pattern makes more sense? I can imagine up to 20 or so states for this system.
Eventually, four test stations will operate side by side, running from a single vi. Data collection will be once per day or as an operator queries with a button. Over time, more functions will be added: temp controller, load cell, etc. Additional DAQ hardware will be required.
Currently, this vi performs the following bare bones functionality:
Initialize state:
Digital out high to energize load relay (steady state condition)
Wait for event state
Press state 1 button:
Read four thermocouples
Read voltage over load
Digital out low to deenergize load relay
Delay of 1 second (for thermal stability)
Read voltage over load (but with relay deenergized it is an open circuit voltage)
Digital out high to energize load relay (this is back to steady state condition)
Wait for event state
Press Exit button to exit state:
Digital out low to deenergize load relay
One screwball thing is that V load and V open circuit are taken from the same input (Dev1/ai0), but they are several orders of magnitude different. Loaded voltage = 5.46, Open Ckt voltage = 487844. Can you suggest a cause for this faux dangerously high voltage? The voltage comes from +5 V, pin 10 on the USB-6210. (attached picture)
The major omission in this vi is writing the collected data to file.
The functions available to me are in the LV 2014 Base File I/O pallete.
My dream file is a tab delimited text or excel file. Headers would be a plus.
Each row would be time stamped in column one. Additional columns in the same row would be the data collected in state 1: temp and voltages. Calculated data for current and power would be in the last two columns.
One issue I’ve had is getting a single time stamp for all the data. The data collected is from two different DAQ devices, includes a one second delay between voltage readings, and includes two calculated results. My thought is that separating collection and writing-to-file into separate states will force a single time stamp. OK, I guess I can just try this and see what happens. Here’s what I’ll try:
State 1 = data collection, calculations, write to file
State 1 = data collection, calculations
State 2 = data write to file
State 1 = data collection
State 2 = calculations
State 3 = data write to file
I’ll use local variables to pass data from one state to another.
Thank you for reading.
10-22-2014 12:56 PM
Right off the top of my head I would:
10-22-2014 01:39 PM
Can you load the code in 2013? My company is slow about upgrading to 2014.
10-22-2014 03:21 PM - edited 10-22-2014 03:32 PM
Hi JoeWork,
2013 version attached. First time I tried to save as another version.
10-22-2014 03:30 PM - edited 10-22-2014 03:31 PM
Hi RTSLVU,
If you had a state machine with 60+ states, would that be a problem?
Maybe because the tutorial example and the vi example have a handful of states, I get the idea that you want the number of states to remain small.
I guess you would also write data to file in its own state?
"A state for everything, and everything in its state."
Is this a rule of thumb?
10-22-2014 03:33 PM
You don't need to do all these steps each time you are trying to do a read.
Initialize your DAQ tasks in their own state, called once.
It appears that you are only reading one data point per read. So your start task VIs can be in a seperate state, called once.
So now when you need to read your data you just have to call the read data Vis.
If your energize and de-energize relay is on the same digital channel you don't need to create seperate tasks. You can just send true when energize and false when de-energize.
You don't need to stop and erase tasks until you are don't running the program. That can be a seperate state, called once.