02-20-2007 05:25 PM
02-21-2007 02:07 AM
02-22-2007 05:01 PM
/Magnus,
That was the right sub-VI that I needed. I actually should have been able to identify the problem without it, but I didn't come to that realization until after I tested it with it. The issue you're facing is one of dataflow. In your code that doesn't include a custom sub-VI, your Setpoint control and Stop control are both located within the While loop. What this means is that after all initialization is done, then the While loop begins executing and Setpoint is read every time the loop iterates. The subsequent PID code can then be called on each iteration and the motor can be changed.
In the second version (using a custom sub-VI), you have left Setpoint and Stop outside the sub-VI, and thus outside the While loop. The code is actually doing exactly what was asked of it. That is, the initialization routine is happening, then the Setpoint and Stop controls are being read once, then the sub-VI takes "dataflow" control of the program. The controls are never again looked at. This is also why the Stop button is not working. Once it's been read, it is never looked at again, so the sub-VI doesn't stop execution and kick the dataflow back up to the parent VI when the button is pressed.
You are thus left with a few different ways of accomplishing this. Either the controls can be down at the sub-VI level, meaning you'd need front panel access to that sub-VI, or you need to keep an iterating while loop up at the parent level. Keep in mind, then, that anytime a While loop is within a sub-VI and you don't have a way of stopping it, the execution of the program will stay forever at the sub-VI level. Another thing you can explore is the option of using local variables which effectively port information from a control in one part of a program to a different part of the program where that data is also needed.
Regarding the UpdateFlags variable, you are right in your assessment of the situation. I've spoken with the developers of the NXT Toolkit code, and they are aware of this difference in available function options between the NXT and the direct commands. I must say that I'm impressed at your PID implementation, however, which allows you to accomplish the same task!
Pete
02-23-2007 12:44 PM
02-23-2007 07:22 PM
05-11-2007 07:45 AM
05-11-2007 08:44 AM
06-14-2007 01:42 PM
06-21-2007 04:38 AM
Hy evry body,
I am a little bit lost in this amout of information, I just want to know if i can create Blocks for LEGO MINDSTORMS NXT without using Labview, for example I want to use C++ or C# to do this.
Sorry if my reply is in the wrong place
06-21-2007 09:58 AM