LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate total time for state machine cycle time

Thanks a lot.

I am sending you my basic temperature controller VI which basically takes the voltage difference from NI USB-DAQ6009 across the thermistor placed on the heater and than using a formula mode converts it  into temperature,The PID placed there checks it with set point alreday provided and incase if the temp is below setpoint than sends signals to analog out of usb daq which sets the relay on and sends more power to heater,so basically using output from daq,the relay is turned on and off and in this way controls temp on heater.

After seing my VI u will get the idea.,I will try to put it in state machine and will send u again the VI to look at it.I hope we will be able to do it.

First and foremost, thanks a lot for helping me in coming up with thermal cycling VI.

take care

bye

Ahsan

0 Kudos
Message 11 of 16
(1,425 Views)
Hi Ahsan,

I looked at your VI, and I think with the complexity of the control that you are wanting to achieve you will need something a little more robust.  As previously suggested, a state machine architecture would be a good fit for this application, and you can get started with this in LabVIEW by creating a VI from the state machine template (File>>New>>VI>>From Template>>Frameworks>>Design Patterns>>Standard State Machine).

I would also recommend that you use the lower-level DAQmx function calls versus using the DAQ Assistant.  Given that you will be using loops and case structures, the DAQ Assistant isn't necessarily the most efficient method for programming your data acquisition.  For help in getting started with using the lower-level VIs I would recommend looking at the shipping examples in LabVIEW (Help>>Find Examples>>Hardware Input and Output>>DAQmx).  In addition, here is a good resource on our website for getting started with DAQmx programming:
Getting Started with NI-DAQmx: Main Page
I have attached a modified version of one of the analog input shipping examples to serve as an example of how you would read a single voltage sample on each iteration of a while loop.  In general, you will want to configure and start all analog input and analog output channels outside of the while loop and only perform reads and writes within the while loop.

For the purposes of your application, I would create at least 5 different states.  The states would be as follows:
1.  "Initialize" state - do a single voltage read and convert to temperature.  Compare this temperature to 95C and as soon as it reaches this temperature, transition to the 95C state.  Otherwise, transition into the initialize state again.
2.  "95C" state - provide software timing to remain in this state for your desired amount of time.  If you need to do analog output in this state to maintain the temperature level, do this using the shipping example "Gen Mult Volt Updates-SW Timed.vi" as a starting point.  After the desired amount of time has elapsed, transition to the 55C state.  Otherwise, transition into the 95C state again.
3.  "55C" state - same as 95C state (with comparison to 55C).  After the amount of time has elapsed, transitition to the 75C state.  Otherwise, transition into the 55C state again.
4.  "75C" state - same as 95C and 55C states (with comparison to 75C).  After the amount of time has elapsed, transition to 95C state or stop state (if you want the program to finish).  Otherwise, transition into the 75C state again.
5.  "stop" state - this will perform any necessary final operations that need to be done, and will ensure that the main while loop finishes by passing the appropriate boolean value.

This is just one way that you could go about doing this application, but I think it would be a pretty solid method.  Keep in mind that everything done in this is software timed, so you will not be able to get precise deterministic behavior.

Regards,
Andrew W
National Instruments


Message 12 of 16
(1,388 Views)

Hi,

Wishing You Happy New Year...

This is regarding the development of state machine architecture in order to bring out PCR thermal cycling.I have gone through the state machine architecture and came up with the attached VI.Basically What i am doing here is instead of using real NI-USB DAQ I am basically simulating a heater model to which i am supply currect and which needs to be controlled and than thermal cycled.My top portion of VI contains simulation loop where I am using PID to control one temperature at a time ,This is I am doing within state machine which has six states.First state is just Initialisation next is init denaturation where I need to heat the heater till 95 deg c and than once the 95deg c is reached I wish to transit it to denaturation state where it should be maintained at suppose 2 secs than,once the time of denaturation elapses it should transit to 55 deg c where it should be maintained for 55 deg c for say 2 secs and than transit to another state and so on.

In the attached Vi what i am finding is that the transition is not taking place and the temperature remains and maintains at 95deg c without going to another temperature level.I will really appreciate if you can help me correcting this VI and bring out thermal cycling on a heater with this simulation model.Please let me know if you have problem in opening.

Thanking you....

Ahsan

0 Kudos
Message 13 of 16
(1,292 Views)
Do you have a version where the code is not streched over the size of about 40 screens? It is virtually impossible to navigate your diagram.
0 Kudos
Message 14 of 16
(1,287 Views)

Sorry About that...but I don't know whenever I am saving my VI's everyhting get extended in block diagram...Here Is better version I hope may it might be readable.Thanks a lot for your help and guidance.

 

0 Kudos
Message 15 of 16
(1,282 Views)
Hello microbes,

Your code is still fairly complicated.  I recommend you begin troubleshooting by first breaking the code into smaller modules and then testing each module using Highlight Execution, Single Stepping, and the Probe tool.  By incorporating modularity into your design, you will narrow down the possible cause of the problem.

Also, I noticed that your Enum has 10 items; whereas, your Case Structure only has 6 cases.  You should match these two so that you have a one-to-one relationship between items in your Enum and cases in your Case Structure.

Best Regards,
T. McCarty
Applications Engineering  
0 Kudos
Message 16 of 16
(1,249 Views)