xan_black
Providing Real-Time Simulation and Test Systems for over 20 Years

> [Home]  > [Support]  > [NL-SIM Start]  > [Part 7]

Part 7 - The Control Panel

Need Help?
E-Mail Tech Support your Questions:
support@xanalog.com

If you haven’t already, you can get your own free copy of NL-SIM and MML.

Now that you’ve tested the model, you can build a control panel for it. With a control panel, anyone can operate the model without knowing how to build it. Useful, for example, for training.

In this section, you will learn how to:

  • Place control objects in a control panel
  • Change the size and location of the control objects
  • Enter MML expressions that controls can execute
  • Attach control objects to signals in a model

From the Display menu select Edit Control Panel. Enter the name vehicle_panel and click OK. A blank control panel window opens that looks like the one below. Maximize this window.
fig25

Click on the digital icon and drag it onto the control panel. Click again to create a digital display object. In the digital control window which opens, set the annotation to Speed and the identifier to Vx as shown below. Drag a second digital display onto the panel and set its annotation to Distance and its (unique) identifier to x.
fig26
To move a control panel object once you’ve placed it, hold down the shift key and click and drag the object with the left mouse button. When you release the left mouse button the object sets in place. Locate the digital displays as shown below:
fig27
Before proceeding, save your control panel by selecting Save from the File menu or by pressing ctrl-s.

Add a pushbutton just below the Distance digital Control object on the Control Panel. Set its annotation to GO. In the Matrix Statements box, type model_run(); and press enter. On the next line, type model_message(“Running....”); The Pushbutton Control Window should be shown as below. Click on OK.
fig28
Add the STOP button. Enter model_stop(); in the Matrix Statements box. On the next line, type model_message(“Stopped”); and then click on OK.

Add the LOAD MODEL button. Enter model_load(“motor_vehicle”); in the Matrix Statements box.

Hint: You will need to click and drag on the side of the Load Model button to increase its size so that Load Model is entirely visible.

Ad the RESET Button. Enter model_restore(“vehicle.svs”); in the Matrix Statements Box.

Now add a slider control. Choose the vertical orientation; annotate it ACCELERATOR. Name the identifier pedel (identifier names must be unique for each control object); set the lower bound to 0 and the upper bound to 500. Enlarge the slider box so the entire annotation is visible.

Add a text box. In the box, type
Click in Accelerator slider box to change.

You will need to click on the side of the text box and drag to make all of the text visible.

You now have all the control panel objects you need. If necessary, move the objects on the panel so your panel looks like the one below. Save the panel now.
fig29

Connecting the Panel to A Model

With the panel complete, it’s time to attach the panel to the model.

To perform the attachment, load the model, motor_vehicle, by selecting Load from the Model menu or Press F4. The trace tree window, identified by the purple leaf icon, will appear.
fig30

Click on the import trace and the two export traces. Blue ! marks will appear next to the selected traces (signals) as shown above. Use the horizontal scroll bar or maximize the trace tree window to view the complete information on the traces if needed.

If you prefer to see the traces which have been selected in the block model diagram, click on the leaf icon with the right mouse button. To return to the trace tree window, select Open Model Traces in the Model menu.

After selecting the traces, minimize the Trace Tree window and the Block Diagram window.

Now attach the selected traces to their appropriate objects on the panel.

Select the Force slider by holding down the Ctrl key and clicking on the Force Slider Object. The object’s border will darken, indicating it has been selected. Then select Setup, then Attach Model Traces from the Menu (or press F2) The Trace/Control Attach window opens.

Select motor_vehicle/force from the selected traces list. Click on the 00 in the control box. Note that the box around the 00 turns gray as shown below:
attach
Click on the Attach button and motor_vehicle/force will be copied into the list of attachments.

Repeat the procedure by attaching the trace “Vx_out” to the Speed digital display object and “X_out” trace to the Distance digital display object. You must return to the control Panel first to select the appropriate Control Object for each of these traces.

Hint: if the No Object Selected warning appears, you forgot to select the Speed object by holding the Ctrl key and clicking on the Speed digital display object.

When you’ve attached all three traces to their appropriate blocks, save the control panel.

You may recall that when you set up the force import block, you set it to hold a constant value. That choice allowed you to test the model before building the panel. Now, however, you’d like to run the model with an adjustable acceleration force, using the slider you put on your panel. To import the slider’s value into the model, you must change the force import block settings.

Perform the following steps:

  • Select Open Model Traces from the Model menu. Double click on the force import line. The Import Setup dialog window will appear.
  • Click on the Null icon (the icon with the red X in the) This will delete the step input which was driving the import and allow you instead to vary its value with the slider. Click on OK to close the Import Setup dialog window. Close the Trace window too.

Before running the model, you need to set the initial conditions. That’s what the LOAD MODEL button will do.

First, select Run/Display Times from the Setup menu and make sure that Run Indefinitely is checked Display Update Interval is set to 1.

Then from the menu, select Save Setup File from the Setup menu. Save the setup as vehicle.svs so the text (within the “ “ marks) specified by the LOAD MODEL Button will call the correct setup file.

To run the model, you must change the panel’s mode from edit to load. Do so by selecting Edit/Load Toggle from the Display Menu. The template toolbar will disappear.

Click on LOAD MODEL, then on RESET, then on GO. The model is now running, waiting for you to step on the accelerator. Do so by clicking in the accelerator slider. A blue line, indicating the amount of force, will appear and the vehicle’s speed and distance traveled will increase. Your model is now simulating the vehicle’s motion.

cp

Click on the STOP button to stop the model and then click on Reset to initialize everything to zero. Click on GO again...

When you are finished with STOPing and GOing, unload the model by selecting Model Drop/Unload from the Model menu.

 

Congratulations on completing “Getting Started with NL-SIM” See the NL-SIM Modeling User Guide” for a more detailed discussion of the use of this software tool.

See also the companion piece “Getting started with MML” as well as the “MML User Guide” and the “MML User Reference Manual” for the use (and usefulness) of XANALOG’s Matrix Math Language which is part of this XANALOG software suite.

You are now ready to use NL-SIM for modeling, simulation, and controller design.

Good modeling!

 


[Home] [About] [Contact Us] [Products] [Support] [Free Software] [FAQ]

Copyright 1992-2007 XANALOG Corporation
Questions about the Site?
E-mail the Webmaster