09-04-2014 03:45 PM
Hi,
I have a program that is reading very low flourescent light levels every 5 to 15 minutes (user sets that time) in a While Loop. I also want to control temperature in a seperate While Loop. The temperature can be read every 100ms, then PID calculations change the duty cycle of the heaters. Both While Loops work great seperately, but I'm having problems running them in parallel. I basically want the temperature loop to run continuously, and the sensor loop to take measurments every 15 minutes. I have tried parallel while loops but wasn't getting much luck of jumping out of the temperature loop without an actual stop button.
I have attached my VI for your reference.
Let me know of any ideas.
Thanks,
John
09-04-2014 05:07 PM
You can't use LIFA (assuming one Arduino) in two parallel loops because LIFA and Arduino run serially. I.e. All of the LIFA VIs must be in-line (the Arduino resource wire must go from one LIFA VI to the next; the resource wire cannot be branched).
Another thing is that if you are using an Arduino Mega, you must set the baudrate to 9600 because that is the baudrate that is used on the board (as dictated by the firmware).
09-04-2014 05:18 PM
I suggest you put the PID loop inside the measurement loop.
Example code.
For I = 1 to infinity
{
For k = 1 to 1000
{
Execute PID loop
}
Measure fluorescent
}
I arbitrarily pick 1000 for the number of times the PID loop runs for leach time the measurement loop runs. You will need to change this value to a value that meets your requirements.
hrh1818