11-16-2013 01:21 PM
OK so here is the problem i am making this pid controller the output range is 0-100 in this program i am just trying to get it to work so i did a compair function whereby when the controller output is 0 and the constant is 0 i start a case loop which will turn the output on for one second and off for one second . when i enter the case structure the rest of my program slows down
i have no idea why , i have tried to make a while loop and a case structure outside my main loop but i cannot get my signal from my compair statement to enter the second loop where i get my output to cycle in 1second intervals
below is the VI please help
i am still learning how to use labview by the way
thank you
gary
Solved! Go to Solution.
11-16-2013 04:00 PM
gary,
The next thing you need to learn about LabVIEW is dataflow. This is the fundamental paradigm of LV and will explain your slow down issues.
The basic dataflow concept is that any node (node = function, subVI, structure) can begin to execute when data is present on all its inputs and that no data will be present at its outputs until the node comopletes execution.
How does this affect your VI? The true case has a 1000 ms Wait (actually two, one in each case of the inner case structure = redundant code). The case structure will not complete execution until the wait completes. And, the while loop does not complete its iteration until the case structure completes. The result: When the PID.vi output = 0, the loop will run at 1 second per iteration.
What is the fix? Continue running the loop at 100 ms intervals. Keep a count in the case structure (true case) and another shift register of how many 100 ms intervals have passed. When the count reaches ten, toggle the output line. Do not use the 1000 ms Wait.
All the code in your inner case structure is unnecessary. Wire the Remainder output directly to the Arduino Digital Write VI.
Be careful with the comparison to zero with floating point data. If the calculation which produces the data has round off errors you might get a value like 0.573E-15, but that is not equal to zero. It is better to compare to a small range of values above and below zero.
Right to left wiring is much easier to follow when trying to understand what a program does. Using the Clean Up tool occasionally will help (although it will eventually frustrate you also).
Lynn
11-16-2013 05:39 PM
Thank you for the help i dont understand fully what u have done but i think u are using counters to cange the on and off state for the arduino output
this is fine but the problem is i dont want the on an off intervals to be the same my goal is to get the output on for 5 and off for 2 and keep varying the on an off intervals depending on the controllers output .
I will lookin in to trying to achieve this any help would be grately appriciated
thank you
11-16-2013 08:41 PM
You need to change the count value depending on whether the output is on or off. A Select function can do this. The on and off times are the numbers selected multiplied by the value connected to the Wait function. So the values shown in this image give 500 ms On and 200 ms Off.
Lynn