deniz Posted October 23, 2009 Report Share Posted October 23, 2009 Hello everyone, I have a code that can control the thermostat of an environmental chamber by sending 1 or 0 to a digital IO board, acquiring temperature data from a thermocouple continuously and collecting data from an optical spectrum analyzer when the temperature value (acquired temperature data) meets a certain criteria. I have combined all these into a state machine. I want to define a stabilization criteria for the temperature. I want to compare a thermocouple reading with the previous one and to see whether the temperature is stable or not. I wrote this to NI forum and somebody suggested me to use an action engine. How can I do that? http://forums.ni.com/ni/board/message?board.id=170&thread.id=448688 The flow of the program should go like that. Collect data at ambient temperature when the program is first run(as a reference). Heat the oven up. Check temperature stability. If it is stable, collect six sets of data and move on to the next temperature by heating the oven up again; and so on. I am attaching the code that I have. Any comments or suggestions about the code will be greatly appreciated. P.S: Please consider that I am a beginner at LabVIEW Thank you StandardStateMachine 1.vi automation.llb Quote Link to comment
Daryl Posted October 23, 2009 Report Share Posted October 23, 2009 Hello everyone, I have a code that can control the thermostat of an environmental chamber by sending 1 or 0 to a digital IO board, acquiring temperature data from a thermocouple continuously and collecting data from an optical spectrum analyzer when the temperature value (acquired temperature data) meets a certain criteria. I have combined all these into a state machine. I want to define a stabilization criteria for the temperature. I want to compare a thermocouple reading with the previous one and to see whether the temperature is stable or not. I wrote this to NI forum and somebody suggested me to use an action engine. How can I do that? http://forums.ni.com...hread.id=448688 The flow of the program should go like that. Collect data at ambient temperature when the program is first run(as a reference). Heat the oven up. Check temperature stability. If it is stable, collect six sets of data and move on to the next temperature by heating the oven up again; and so on. I am attaching the code that I have. Any comments or suggestions about the code will be greatly appreciated. P.S: Please consider that I am a beginner at LabVIEW Thank you Please search Labview examples for "State Machine Test Sequencer.vi" and try to get your code organized into a similar structure. Try to seperate your code into the different functions, and put each "function" into it's own "state" of the case structure. We can help you if you have any questions but first you have to get that code organized into separate "functions" Quote Link to comment
ShaunR Posted October 23, 2009 Report Share Posted October 23, 2009 Whilst a "State Machine" (action engine) has many advantageous features. A state machine is used to "break" the dataflow feature of LV so that so that a program can "branch" dependent on dynamic conditions. Your requirement has a sequential nature and doesn't really require one ("Do this" THEN "Do That" THEN "Do It All Again"). What you will end up with in your situation is either sections of code waiting in a particular state until something happens (which deteats the object), or lots of code to check state information to enable a decision to be made on which state to execute next (messy). I would put each "action" into a sub and vi use labviews dataflow to sequence the operations so the top level vi would be farily simple and look something like.... Initialise.vi Heat Up.vi Stabilise.vi Aquire.vi Shutdown.vi But I like simple things Quote Link to comment
deniz Posted October 23, 2009 Author Report Share Posted October 23, 2009 Thank you for your replies, I rewrote the code. Could you tell me how to do the state transitions? (and whether my code looks right or not?) The program gives an error when it completes the for loop. I want it to go to "1" (heat up) when it is done with the for loop. And when heating up is completed, that's thermostat is set to be on for a certain amount of time, it should go to state "2". After state "2" is done, that's stability is checked and temperature is stable, it should go to state "0" and collect data again. (but with a different file name) state_machine.vi Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.