02-21-2012 11:05 AM
Hi.
I have been requested to implement a VI to carry out cyclic testing on a component. This involves me energising two relays on my CDAQ system at timed intervals. I have given this a go and it sort of works, whereas it is doing the cycle, but it is hanging the program in the for loop while it waits for the next time interval (or it seems to do this), but I was just wondering is there a more efficient way of implementing this timed cycle.
The cycle times and outputs can be found in the notepad file in the ZIP folder attached. I will also need to log some data points at certain intervals within the cycle which is the main reason for posting this question. The data log intervals are also noted in the notepad file.
I am using Labview 2011.
I hope this is enough information for anyone to help me.
Thanks!!
Rhys
02-24-2012 03:56 AM
Hi Rhys,
Thanks for your post. I have had a look at your code and I believe this timed cycle would be best implemented in a state machine architecture. I have taken your code and placed it into a state machine architecture template in which you can implement your logic within this code.
Basically this state machine has these states:
- Relay: you can index your relay values into your digital output here
- Wait: After Relay the Wait case you can index your waiting times
- Read Anaolg: After Wait the Read Analog state which will read your analog voltage and write values to the measurement file
This then goes back to the Relay state, You can add in iterations and stop conditions.
What was happenning with your current code is the top while loop was only executing every 14 seconds, therefore the stop button and the other case structure with the dialog is read every 14 seconds. This was probably the cause of the hang. You have used some good programming techniques in this VI and your implementation of a master slave loop is very good idea for sending the states to your relay. However for timing using this state machine architecture should get rid of the hanging you were experiencing.
Useful Links:
https://decibel.ni.com/content/groups/northeast-oh-labview-users/blog/2009/09/08/state-machines
http://zone.ni.com/devzone/cda/tut/p/id/3024
I hope this helps you out!
Best Regards,
Ben
DISCLAIMER: Any attached Code is provided As Is. It has not been tested or validated as a product, for use in a deployed application or system, or for use in hazardous environments. You assume all risks for use of the Code and use of the Code is subject to the Sample Code License Terms which can be found at: http://ni.com/samplecodelicense