10-17-2011 04:11 PM
Ok I work in a lab and we're measuring subject pain using a program in Labview called a VAS that is used to help subjects visualize the rating they are giving thier pin and systematically acquire data. I'm using a variety of VAS programs depending on the parameters of each study, but I'm having a good deal of trouble with this one in particular.The program is deigned to take an average of user data every .5 seconds and then compare the averages from one second against each other to determine if pain is increasing or decreasing in that second, and to determine whether vibration will be applied to the subject in the next second (based on whether the current run will activate vibration while increasing or while decreasing).
My problem is not with determining when vibration should be applied but has been with actually applying it. The vibration is controlled by the amount of voltage the computer gives to an analog circuit I have set up to a minishaker. The program for controlling the minishaker was already written and I've only made slight modifications to it. What I need is a way to get the vibration to occur for one second if the condition for vibration is true at the end of the previous second but i need it to do this while continuing to collect data, as that will determine whether the next second also warrants vibration.
I've attached a copy of both my program collecting pain ratings and the program controlling the vibration, and any help will be greatly appreciated. Thank you.
10-18-2011 02:45 PM
The absolute simplest way to continue with what you have is to adjust your minishaker controller program to run for only 1 second then stop and call that VI from your main program. You can add terminals to your VI that connect to your Numeric value to determine intensity for that second. There are many ways to do this so I recommend doing a few searches and finding what method you like best (drag and drop, using the functions palette, etc.)
You may also want to look at shift registers, they will help to simplify your code and do the same thing as your feedback nodes.
Kyle K.
10-19-2011 01:05 PM
I appreciate the help. The difficulty I'm having is that if I place the VI in the loop and have it run for 1 second intervals then it halts data collection, and If I place it outside the loop the boolean values to turn the vi on wont work until after the data collection loop is done excecuting. Unless theres a way to get around that
10-19-2011 01:44 PM
You can place the subVI in a separate loop so that it does not halt the data collection. LabVIEW will run these loops in parallel and even utilize multiple cores of your processor automatically. Put it inside of a case structure so that it only runs then true. You can get that boolean value to the parallel loop with functional global variables, queues, or Reference variables.
Kyle K.
10-19-2011 02:02 PM
Thank you you're being incredibly helpful and I'm closer now, but For some reason the loops aren't excecuting simultanteously. Do I have to do anything to get them to exececute together?
10-19-2011 02:11 PM
I figured out why it wasnt going simultaneously. I only have one problem. The minishaker works the first time its conditions are met but in subsequent times it doesnt turn on. Do you have any idea why this could be?
10-20-2011 11:31 AM
It really depends on how you wrote the program. My suggestion is to turn on hightlight execution and watch the program run, watch the values to make sure that everything happens when you expect and with the values you expect. Probes are also helpful when watching particular values. There are many tools to help control the program flow. The most common are using wires to connect code (a function will not run until all of its inputs are available) or sequence structure. If you chose to incorporate queues, watch that the values you recieve are what you expect to see, remember that the queue functions buffer the data.
Kyle K.