Compiling MapleSim C-Code in Visual C Express

Similar documents
CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2005

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2003

Visual C++ Tutorial. For Introduction to Programming with C++ By Y. Daniel Liang

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010

TREX Set-Up Guide: Creating a TREX Executable File for Windows

ECE 103 In-Class Exercise L1 Guide

CS 210 November 3, 2016 Notes on Separately Compile Programs

Opening Microsoft Visual Studio. On Microsoft Windows Vista and XP to open the visual studio do the following:

EDEM Dynamics Coupling Quick Start Guide

Check the Desktop development with C++ in the install options. You may want to take 15 minutes to try the Hello World C++ tutorial:

MS Visual Studio.Net 2008 Tutorial

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

C++ - OpenGL - Setting up Visual Studio

Configuring Visual Studio 2017 with SFML Game Engine

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

Tutorial - Exporting Models to Simulink

Lab 1: First Steps in C++ - Eclipse

EECE.2160: ECE Application Programming Spring 2018 Programming Assignment #1: A Simple C Program Due Monday, 1/29/18, 11:59:59 PM

Tutorial : creating a Max/MSP external project for Windows using Visual Studio

ECE 480 Application Note. By: Jacob Hersha 4/3/15. Creating a Sequence of Media with Visual Studio

Scientific Visualization A Programming Guide using Fltk and Visual Studio

Qlikview and TFS integration

I Wish I Knew How To. Program Plugins With Xojo on Windows. By Eugene Dakin. May 2015 Edition (2.1) For Visual Studio 2013 Community Edition

IMSL C Numerical Library

User Guide. Introduction. Requirements. Installing and Configuring. C Interface for NI myrio

Getting Started with the MapleSim FMI Connector

Hello World. Lesson 1. Create your first Android. Android Developer Fundamentals. Android Developer Fundamentals

Getting Started with Eclipse/Java

WRITING CONSOLE APPLICATIONS IN C

Engr 123 Spring 2018 Notes on Visual Studio

MC2-ICE Integration with Prime Bid

Application Note 112

5. Optionally configure the generator options. Read the section below for a description of options. 6. Click Generate to generate code.

AN 834: Developing for the Intel HLS Compiler with an IDE

PRINCIPLES OF OPERATING SYSTEMS

Creating Mixed Language Projects with Microsoft Developer Studio 2005, Intel Fortran, MS C++ and Canaima Legacy Software

Setting up a Project and Debugging with Visual Studio

clicking on the on the New

Using OpenGL & GLUT in Visual Studio.NET 2003

MAIL MERGE DIRECTORY USE THE MAIL MERGE WIZARD

Getting Started with Visual Studio

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

Tutorial for VC++ UDF Studio 18.2 SP1 Chinese Version

Application Note: AN00151 xscope - Custom Host Endpoint

Appendix M: Introduction to Microsoft Visual C Express Edition

APPENDIX A. CODE COMPOSER STUDIO (CCS) v5: A BRIEF TUTORIAL FOR THE DSK6713

Anonymous Group Manager GUI Tool

Writing a Client Application for Genesis II Contributors: Chris Sosa Last Modified: 06/05/2007

C++ Support Classes (Data and Variables)

DEVELOPING OOSIML SIMULATION MODELS. Using Codeblocks

How to debug Wcem.dll with.net Studio

RTX MiniTutorial DEBUGGING APPLICATIONS USING VISUAL STUDIO

12- User-Defined Material Model

Application Note: AN00152 xscope - Bi-Directional Endpoint

GUI and API Application Note

OnBase Guide Creating Document Packet Template

Activating AspxCodeGen 4.0

SQL Server 2016 installation/setup instructions

Using Code Composer Studio IDE with MSP432

Registering for Microsoft ELMS for Imagine Software ( )

Code::Blocks Student Manual

Spartan-6 LX9 MicroBoard Embedded Tutorial. Tutorial 1 Creating an AXI-based Embedded System

Code Composer Studio Operation Manual

More Skills 11 Export Queries to Other File Formats

Installing and getting started with Visual Studio for C programming in Windows.

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

Introduction to IBM Data Studio, Part 1: Get started with IBM Data Studio, Version and Eclipse

CST272 Getting Started Page 1

MSP430 Interface to LMP91000 Code Library

Quick Start for User Defined Models

Extracting and Storing PDF Form Data Into a Repository

QTD and Supporting Files Installation Instructions

Exchange Address Book Order

Quick Guide for the ServoWorks.NET API 2010/7/13

How to build Simbody 2.2 from source on Windows

Basic Microcontroller Integration Using Sigma Studio

Manually Configuring IIS

TI mmwave Labs. Vital Signs Measurement

Code Composer Studio. MSP Project Setup

IMPLEMENTING SCL PROGRAMS. Using Codeblocks

RVDS 4.0 Introductory Tutorial

Using the GeoX Framework

Using NIOS 2 Embedded Design Suite 10

Moving a File (Event-Based)

SMT107 User Manual User Manual (QCF42); Version 3.0, 8/11/00; Sundance Multiprocessor Technology Ltd. 1999

Introduction to MS Visual C/C++

Enterprise Architect. User Guide Series. Hybrid Scripting. Author: Sparx Systems. Date: 26/07/2018. Version: 1.0 CREATED WITH

As CCS starts up, a splash screen similar to one shown below will appear.

Quick Start Guide ZedboardOLED Display Controller IP v1.0

Using Eclipse for C, MPI, and Suzaku

QSPI Flash Memory Bootloading In Standard SPI Mode with KC705 Platform

PART 1: Getting Started

MSP430 Interface to LMP91000 Code Library

CS520 Setting Up the Programming Environment for Windows Suresh Kalathur. For Windows users, download the Java8 SDK as shown below.

User manual. Deploying the Toolbox WebServices engine 7/8/2017

QNX Software Development Platform 6.6. Quickstart Guide

Quick Start Training Guide

MPLAB X IDE PROJECTS Microchip Technology Incorporated. All Rights Reserved DEV Slide 68

USING CODEBLOCKS. Implementing Computational Models

Transcription:

Compiling MapleSim C-Code in Visual C++ 2010 Express Introduction This tutorial will guide you through the steps involved in generating C code from a MapleSim 5 model, and then compiling the code in Visual C++ 2010 Express. Specifically, we will generate an executable which writes simulation results to a data file. The same principles can be applied to using the code generated by MapleSim in other development projects. Notes on the C code The code generated by MapleSim includes a solver, and only needs a main() function written by the user. The main() function will call ParamDriverC() in the generated code, which runs the simulation given the inputs given by inpfn(). Prerequisites You will need MapleSim 5 Visual C++ 2010 Express (available free from microsoft.com) 1 Prepare the MapleSim model Create this MapleSim model (or any other similar MapleSim model). It contains a subsystem (for which we will generate C code) with one real-valued inputs and two real-valued outputs

Note that the results exported from the C code will simply be the two outputs from the subsystem, and not the probe results. 2 Attach the Code Generation template 1. Go to View > Create Attachment 2. Select Code Generation from the list of templates 3. Click Create Attachment 3 The Code Generation template You should now be in the Code Generation Template.

Select the RLC subsystem You should now see the RLC subsystem in the MapleSim component Click Load Selected Subsystem 4 Pick the solver Make sure the Euler Solver is selected (although the following steps should work with any solver).

5 Generate and save the C Code Choose where you want the code to be saved (make the location already exists), and the name of the file. The file will automatically be given a c prefix and a c extension (e.g. the c file specified above will be called crlc.c) Click Generate C Code The C Code will be displayed at the bottom of the template.

The C code will also be saved in your specified location NOTES. The simulation inputs are given by inpfn() in the code. By default, inpfn() has the following form static void inpfn(double T, double *U) { U[0] = sin(t); } The default input is a sinusoid, but can be changed as required). If the MapleSim model has two or more inputs, they would be specified by U[0], U[1] U[n] in the code

6 Create a new project in Visual C++ 2010 Express In Visual C++ 2010 Express, go to File>New>Project, and select a Win32 Console Application. Give your project a name and save location, and then click OK > Next In the Application Settings window, check Empty project, and ensure Precompiled header is not checked Click Finish.

7 Add the C Code generated by MapleSim to the project In the Solution Explorer, right-click Source Files, and select Add>Existing Item Browse and select the C code file that MapleSim generated (from the location specified in Step 5). You should have the C code in Visual Studio 8 Specify the Include files and the compiler settings Go to Project>Properties Select VC++ Directories, and on the right-hand pane, click Include Directories

Add C:\Program Files\Maple 15\extern\include to the path. Your Include Directories path should now look like this Go to Configuration Properties > C/C++ > Advanced. On the right-hand pane, change the Compile As setting to Compile As C Code (/TC). Click OK

9 Add a main() function to the code Now return to the source code in Visual Studio. Add a main() function Add the following main() function to the code (i.e. the crlc.c file)

int main (void) { FILE *fd; double *ic, *p, *out; char errbuf[100]; long i, j, outd; long internal = 0; double t0 = 0.0; double dt = 0.1; double tf = 20.0; long npts = (long) ceil((tf+1e-10-t0)/dt)+1; out = (double *)malloc(((npts)*(nout+1)+nout+1)*sizeof(double)); fd = fopen("output.dat", "w"); outd = ParamDriverC(t0, dt, npts, NULL, NULL, out, &errbuf, internal); for(i=0;i<npts;i++) { fprintf(fd,"%lf ",out[i*(nout+1)]); for(j=0;j<nout;j++) { fprintf(fd,"%lf ",out[i*(nout+1)+j+1]); } fprintf(fd, "\n"); } fclose(fd); } return 0; The simulation start time, time step and end time are given by t0, dt and tf. The call to ParamDriverC() integrates the state variables, given the inputs specified by inpfn(). The simulation output will be written to a file called output.dat. 10 Compile the code Click Debug > Build Solution. Check the Output window at the bottom of Visual Studio. It will indicate if the Build process has succeeded.

11 Run the executable Now check the Debug folder of the Project directory. You should now find you have an executable. Double-click the executable to run it. You should now see an extra file called output.dat Output.dat contains the results of the simulation. The first column is simulation time, while the second two columns are the two outputs from the MapleSim subsystem for which we generated C code.