RealTime suite‎ > ‎

Your first target

In this last part of the tutorial I’ll show the steps needed to compile a simple target and remotely interact with it.

The objective is to display a sine wave and control its amplitude.


Step 1 - Build the model using Scicos


The first thing to do is to use Scicoslab modeling GUI - Scicos - to create the model. Keep in mind the following figure when placing blocks.


  1. Create a subfolder in your home folder named test
  2. Open Scicoslab.
  3. In upper bar, toolboxes -> RTAI. Check for “Scicos-RTAI Ready” output.
  4. Type scicos in command window to open modeling GUI.
  5. In the new window, Palette -> Pal Tree to open the list of available blocks.
  6. Expand Sources and grab the red clock. Place it in the upper part of your model.
  7. Double-click the clock. From here you can set operating frequency. Type 1/1000 as Period (1KHz)
  8. In Palettes  windows, expand Linear and drag gain block to the model, directly below the clock.
  9. Right-click on the gain block you just placed and select Block Properties -> Identification. Type gain.
  10. In Palettes windows, expand RTAI-Lib and place a Sine block and a Scope block respectively to the left and right of gain block.
  11. Double-click the Sine block and set Frequency to 50.
  12. Now connect blocks as shown in figure. (TIP: to branch a line, just right-click it and select Link).


Step 2 - Compile the real-time executable


  1. In scicos window, drag a selection that covers all the model except for the clock.
  2. In upper bar, Diagram -> Region to Super Block. It’s mandatory that all your model is contained in a single Super Block with only Clock as input.
  3. Highlight the Super Block and, in upper bar, RTAI -> Set Target. Confirm with OK.
  4. The super block will automatically expand in a new window. Go back to the main scicos windows, highlight again the Super Block and, in upper bar, RTAI -> RTAI CodeGen.
  5. Under New block’s name you can chose the target name. For this example, name it testsine
  6. Under Created files Path, enter /home/yourusername/test
  7. Confirm with OK and check Scicoslab window for compiling results. If you see the output “### Created executable: testsine ###” then your target is ready to run.


Step 3 - Test the target with QRTAILab
  • In terminal, type
  1. qrtailab &
  2. /home/yourusername/testsine
  1. Check is “TARGET STARTS.” is prompted as output in terminal.
  2. Switch to QRTAILab window.
  3. In upper bar, Target -> Connect. You should see in the lower left-hand corner of the window the message “Target: testsine”.
  4. In upper bar, View -> Scope. Check “Show/Hide” option and adjust “sec/div” to get a nicer visualization (i.e. 0.05). Then close manager.
  5. Now we try to control wave amplitude on-the-fly. In upper bar, View -> Parameter.
  6. Double click on gain, then select Block Parameters tab. Try different values and see changes in the scope
  7. Now go back to QRTAILab main window. In upper bar, Target -> Stop. Then close QRTAILab.


Step 4 - Remotely control your target with jRTAI-Lab
  • The first things to do are to properly configure server machine. In terminal:
  1. cd /usr/realtime/rtaixml/scripts
  2. sudo cp TEST STEST
  3. sudo gedit STEST
  1. This is the configuration script for rtaixml. You have to configure a copy of it for each target you want to remotely control. NOTE: the file name shouldn’t exceed six characters long.
  2. Under “#Name of the target executable”, you need target=testsine.
  3. Under “#Absolute path”, dir=/home/yourusername
  4. Set “Final Time” to 1000
  5. Remove the “#” before “wait=true” and set it to false.
  6. RTAI-XML server is ready. Move on the client machine.
  7. Start jRTAI-Lab (see the end of Part 2 of this document) and click on the button that pops up.
  8. In upper bar, File -> Connect
  9. Edit IP of server machine, leave “Server Port” to default and in “Target ID” insert the script name you created for the target (in this example, STEST).
  10. In upper bar, View -> Signal. Click on SCOPE then check Plot.
  11. In upper bar, View -> Parameters. Here you can live adjust model parameters as you did in QRTAILab (NOTE: remember to press ENTER in the parameter value, “Set” button alone isn’t enough).