How to set up the start up loop
When creating moving objects on the NXT screen, the important thing is to change the objects coordinates. This is done by changing the values of the parameters, since the parameters are the objects coordinates. The way this is done is shown in the start up loop below:
It is this loop that makes the “animation” in the picture. every 1/10 of a second the picture is drawn once again after the screen has been erased. And if, in meanwhile, an objects parameters has changed, this object will “move” to the new position. This loop is of course very important to the program, but once it is finished, we can leave it alone. It will continuously update our RIC file. The create Code button will help us make this start up loop. We start by pressing the Create Code button:
When you press this button the following window will appear on the screen:
By default the parameters name is the same as the parameter number. But it is best to select more logical names as we did in the view RIC file part of this website:
We insert this for the parameters:
We press the OK button and then we’ll get a new VI or program with the start up loop inside:
When the program start the values in the front panel is passed via the build array command and further to the draw command. But by default all the values are zero. So we have to change them to our start up values:
PLEASE NOTE!!! A very common mistake for beginners of LabVIEW is that changing the values like this DOES NOT make these values the default values for the control. So, even if you save the file and open it again, the values are all zero, because zero is the default value. To make this current values the defalut, we right click the control, and select data operations/Make Current value default:
We have to do this for all the 7 controls and then we SAVE the file. The name of the file might be cannon_game.vi. But one thing is missing: the command advanced picture needs to know the name of our RIC file:
Connector 3 asks for a filename. To fix this we select the wiring tool, right-click on this connector, and select create/constant:
In the constant that pop up we enter the filename (i.e. cannon.ric):
Now the start up loop is finished! Now there is a lot of things we can do! I think we can start with moving the cannon around the screen with the NXT buttons.
Svein-Tore Narvestad
Latest posts by Svein-Tore Narvestad (see all)
- Create apps for NXT with MIT App Inventor - 3 August 2016
- RicEditor tutorial: Create a cannon game - 28 October 2013
- Create your own games with “RIC” files - 27 August 2013
- How to update the NXT firmware in LabVIEW - 19 August 2013
- Datalogging in LabVIEW: Timed datalogging - 2 June 2013