4 Preparing a MapleSim Model to Run as a New B&R Project on an X-20 System - MapleSim Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : MapleSim Toolboxes : MapleSim B&R Connector : Getting Started Guide : MapleSimBRConnectorGSG/Chapter04

Contents     Previous     Next     Index

4 Preparing a MapleSim Model to Run as a New B&R Project on an X-20 System

This chapter describes how to run a model on an X-20 System and how to run your C code using the MSD model that you generated in Generating C Code for the Nonlinear Spring Damper Model

Note: For a complete detailed description of the MapleSim Connector for B&R Automation Studio see the Automation Studio B&R Help Explorer.

4.1 Preparing a MapleSim Model to Run as a New B&R Project

The preparation procedure consists of the following steps:

1. 

Establishing a Connection with the X20

2. 

Creating a New Project

3. 

Adding the Program Object to the CPU

4. 

Configuring the MSD Program Object on the Active CPU

5. 

Adding Library Objects to the Project

6. 

Building the Configuration and Transferring the Project to the Target

7. 

Adding a Watch

8. 

Adding a Trace

9. 

Simulating the Project

10. 

Viewing the Simulation Results

4.2 Establishing a Connection with the X20

In order to run a real-time target machine using the generated C code you must first establish a connection as follows:

1. 

Configure the ethernet settings on the X20

2. 

Configure the PC's Ethernet interface

3. 

Configure the online connection

Note: Ensure that the online connection is configured properly so that B&R Automation Studio can verify the target system hardware configuration.  Check the connection between the computer and controller, and ensure that an operating system is installed on the target system.

To configure the ethernet settings on the X20

1. 

From the Physical View right-click on the X20 device name. A list appears.

2. 

Click IF2 Ethernet Configuration.  The IF2 Ethernet Configuration window appears.

3. 

 Change the Mode Value to Enter IP address manually so the IP address can be entered manually.

Note: By default the X20 CPU IP address is 10.0.0.2 and the subnet mask is 255.255.255.0.

To configure the PC's Ethernet interface

1. 

Click Start > Settings > Network Connections.  The Local Area Connection Properties window appears.

2. 

Double-click the desired LAN connection.  The Internet Protocol (TCP/IP) Properties window opens showing the connection status.

3. 

Enter the IP address and Subnet mask.

4. 

Click OK.

To configure the online connection

1. 

From the Main Menu select Online > Settings....  The Online Settings window appears.

2. 

Double-click MSD Destination IP address and enter the X20 IP address.  In this example it is 192.168.0.100.

4.3 Creating a New Project

A project contains the application source data (programs, libraries and data objects) and configurations (hardware description, software and I/O mapping data, libraries, and data objects).  You must first create a project in order to enter a controller application.

To create a new Automation Studio project file

1. 

Open B&R Automation Studio.  The Main Window appears.

2. 

From the File menu, select New Project.  The wizard for creating a new project is started.

3. 

Provide the following basic project data definitions:

Parameter

Description

Project name

Project name

Path for the project

Specify the target directory for the generated files. Use the Browse button to select a specific directory

Copy Automation Runtime support files into project

Select this option to copy all of the Automation Runtime files to the current project. You can continue to work even if this option is not selected.  This setting is used for the next project and must be cleared if the project uses specific target hardware

Use PC Based Simulation Runtime ARsim

Do not select this option

Description of the project

 Provide a brief description of the project

4. 

Click Next.  The wizard for defining the new configuration is started.

5. 

Provide the following basic configuration parameters:

Parameter

Description

Name of the configuration

Project a name of the configuration

Name of the PLC

Project a name of the PLC

Define a new hardware configuration

Select this option to provide a new hardware configuration files to the current project. This setting is used for the next project and must be cleared if the project uses specific target hardware

Identify control system online

Do not select this option

Reference an existing hardware configuration

Do not select this option

Description of the project

 Provide a brief description of the configuration

6. 

Click Next.  The wizard for selecting a CPU is started.

7. 

Select the appropriate X20 board.  Click Next.  The entered configurations appear.

8. 

Click Finish.  The project files are added to the project directory and the Configuration View window appears.

9. 

To see the Online settings, from the main Tool Bar select Online > Settings... . The Online Settings window appears displaying the target directory description, ethernet connections and the active online connection.

4.4 Adding the Program Object to the CPU

In order to utilize the MapleSim model, the CPU requires the generated C code to be added as a B&R program object.

To add objects to the CPU

1. 

Switch to the Logical View and from the Main Tool bar, select Insert > Add Object... (alternatively select the Logical View, right-click and select Add Objects). The Add Object window appears.

2. 

Select the Program, Existing Program folder and click Next.  The Existing Program window appears showing the program list.

3. 

Select MSD and click Next. The Existing Program window appears showing the object assignment selection.

4. 

Select Yes, to active CPU and click Finish.  The Project window appears displaying added objects to the CPU; implementation code (MSD.c), local variables (MSD.var) and MapleSim model implementation (cMsimModel.h).

4.5 Configuring the MSD Program Object on the Active CPU

The CPU requires the object program duration to run at the same rate as the baserate specified in the B&R Template (see Baserate).

To configure the MSD program object on the active CPU

1. 

 Switch to the Configuration View and expand PLC1.

2. 

 Double-click CPU.SW. The CPU.SW window appears.

 

3. 

 Right-click on the Cyclic #4 object program.  The System Software Properties window appears.

4. 

Set the Cyclic #4 object program Duration to 10 ms.

Note: By default the B&R Cyclic #4 object is 100 ms.  Ensure that the Cyclic #4 object program duration matches the baserate specified in the B&R Template (see Baserate).  For this example the cyclic duration is 10ms.  To change the default duration value for the B&R Cyclic #4 object, right-click on Cyclic #4 > Properties and change Duration to 10ms and Tolerance to 10ms.  For addition information click Help.

5. 

Click OK.  The Cyclic #4 object program duration value changes to 10 ms and the project is automatically saved.

4.6 Adding Library Objects to the Project

A library is a collection of project specific reusable functions grouped into functional categories.

To add a library object to a project

1. 

Switch to the Logical View and select MSD.

2. 

From the Main Toolbar, select Insert > Add Object... (alternatively select the Logical View, right-click and select Add Objects). The Add Object window appears.

3. 

Select Library > Existing Library.  Click Next.  The Existing Library window appears.

4. 

Select the following files:

• 

asstring

• 

brsystem

• 

syslib

5. 

Click Next. The Existing Library window appears showing the object assignment selection.

6. 

Select Yes, to active CPU and click Finish.  The libraries are successfully added to the Project and assigned to the CPU.

4.7 Building the Configuration and Transferring the Project to the Target

This procedure builds and transfers the project files to the target device.

To build the configuration and transfer the project to the target

1. 

Switch to the Configuration View and expand PLC1.

2. 

From the Main Tool bar, select the Project > Build Configuration (alternatively press F7).  When the project is built and the Project Build window appears.

3. 

Click Transfer.  The project files are transferred to the device and the Transfer Project window appears.

4. 

Click OK.

4.8 Adding a Watch

Adding a Watch lets you monitor the program variables during the simulation or on the PLC.

To add a watch

1. 

Switch to the Logical View and right-click on MSD program object.  A drop-down menu appears.

2. 

Select Open > Watch.  The MSD::pvm (Watch) window appears.

3. 

Right-click inside the window and select Insert Variable....  The Insert Variable... window appears.

4. 

Select the four variables and click Add.  The four variables are loaded into the MSD::pvm (Watch) window.

Note:  msim_x0 is the input and requires a nonzero value in order to trace the simulation (see Simulating the Project).

4.9 Adding a Trace

The Trace tool records and plots program values.

To add a Trace

1. 

Switch to the Logical View and right-click on MSD program object.  A drop-down menu appears.

2. 

Select Open > Trace.  The MSD.tr (Trace) window appears.

3. 

Right-click anywhere in the top frame of the Trace window.  A drop-down menu appears.

4. 

Select Insert New Trace. The Trace window appears with the TARGET_CONFIGURATION.

5. 

Right-click on TARGET_CONFIGURATION.  A drop-down menu appears.

6. 

Select Insert New Variable. The Select Trace Variable window appears.

7. 

Select all the variables and click Select.  The Trace window appears with the TARGET_CONFIGURATION variables.

8. 

Right-click on TARGET_CONFIGURATION > Install.  The Trace is correctly installed on the Target.

4.10 Simulating the Project

At this point the project is ready for simulation.

To simulate the project

1. 

Switch to the MSD::pvm (Watch) window and double click on the msim_x0 Value cell.  Enter an input value of 100.

Note: In order for the simulation results to correspond with the MapleSim model use the same input signal values.

2. 

From the Toolbar click Start ( ). (Alternatively, right-click inside the Watch window and select Start.) The simulation starts and the computed values appear.

3. 

Run the simulation until the values reach a steady state for approximately 30 seconds.

4. 

To stop the simulation click Stop ( ).  The Stop the Software Object window appears.

5. 

Click OK.

4.11 Viewing the Simulation Results

After simulation the results can be viewed.

To view the project

1. 

Switch to the MSD.tc (Trace) window and right-click on TARGET_CONFIGURATION.  A drop-down menu appears.

2. 

Click Stop to stop the trace.

3. 

Right-click on TARGET_CONFIGURATION. A drop-down menu appears.

4. 

Select Show Target Data.  The real-time results for each of the target configuration variables appear.

 

Contents     Previous     Next     Index


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam