Help on the Embedded Software Block



Similar documents
Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

KiCad Step by Step Tutorial

Using Ad-Hoc Reporting

Creating a Project with PSoC Designer

Sales Person Commission

Simulating Power Supply Sequences for Power Manager Devices Using PAC-Designer LogiBuilder

Xilinx ISE. <Release Version: 10.1i> Tutorial. Department of Electrical and Computer Engineering State University of New York New Paltz

OPERATION MANUAL. MV-410RGB Layout Editor. Version 2.1- higher

Configuration Manager

OneSourceFax Customer Guide

TRILOGI 5.3 PLC Ladder Diagram Programmer and Simulator. A tutorial prepared for IE 575 by Dr. T.C. Chang. Use On-Line Help

Setting Up Windows Perfmon to Collect Performance Data

Jianjian Song LogicWorks 4 Tutorials (5/15/03) Page 1 of 14

It has a parameter list Account(String n, double b) in the creation of an instance of this class.

CADENCE LAYOUT TUTORIAL

Document Contents Introduction Layout Extraction with Parasitic Capacitances Timing Analysis DC Analysis

PSIM Tutorial. How to Use Solar Module Physical Model Powersim Inc.

Microcontroller Code Example Explanation and Words of Wisdom For Senior Design

NIS-Elements: Using Regions of Interest (ROIs) & ROI Statistics

Access Tutorial 3 Maintaining and Querying a Database. Microsoft Office 2013 Enhanced

AT&T UC - CPRT. Customer Provisioning Reporting Tool. April CPRT Version: 1.33

Tutorial 3 Maintaining and Querying a Database

CS 241 Data Organization Coding Standards

How to create buttons and navigation bars

Appendix K Introduction to Microsoft Visual C++ 6.0

Randy Hyde s Win32 Assembly Language Tutorials (Featuring HOWL) #4: Radio Buttons

Interface and Simulation of a LCD Text Display

Creating and Using Links and Bookmarks in PDF Documents

RS-485 Protocol Manual

MS Visual C++ Introduction. Quick Introduction. A1 Visual C++

Keil C51 Cross Compiler

FRONTPAGE FORMS

WebSphere Business Monitor V6.2 KPI history and prediction lab

C++FA 5.1 PRACTICE MID-TERM EXAM

HANDLING SUSPEND MODE ON A USB MOUSE

Mentor Tools tutorial Bold Browser Design Manager Design Architect Library Components Quicksim Creating and Compiling the VHDL Model.

DiskPulse DISK CHANGE MONITOR

Creating a New Search

DSP Laboratory: Analog to Digital and Digital to Analog Conversion

Basics FLEETMATE. Getting Started The Main Window Filtering Data Using Your Mouse Windows and Buttons

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Analog Monitoring Tool AMT 0.3b User Manual

BusinessObjects: General Report Writing for Version 5

KiCad Step by Step Tutorial

Lesson 3 - Processing a Multi-Layer Yield History. Exercise 3-4

Product: DQ Order Manager Release Notes

Part 1 Foundations of object orientation

Section 6 Spring 2013

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

LAB #3 VHDL RECOGNITION AND GAL IC PROGRAMMING USING ALL-11 UNIVERSAL PROGRAMMER

Illustration 1: Diagram of program function and data flow

Event counters in NOVA

Frequency Response of Filters

Table of Contents. Contents. Introduction. The Main Menu...1 The Fleet Manager...3. Notification Popups...15 Service Calendar...16

AP Computer Science Java Subset

Interaction: Mouse and Keyboard DECO1012

Microsoft Access 2010 Overview of Basics

Tutorial 3. Maintaining and Querying a Database

Microsoft Office 2010

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Directions for Frequency Tables, Histograms, and Frequency Bar Charts

Document Management User Guide

J a v a Quiz (Unit 3, Test 0 Practice)

Sharing Files and Whiteboards

Lab 1: Full Adder 0.0

GFI FAXmaker 14 for Exchange/Lotus/SMTP. Fax-Client Manual. By GFI Software Ltd

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Start A New Project with Keil Microcontroller Development Kit Version 5 and Freescale FRDM-KL25Z

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

Data Structure with C

Customizing Confirmation Text and s for Donation Forms

2012 Teklynx Newco SAS, All rights reserved.

PowerShield SNMP Adaptor

Component, Model and Library Concepts. Components - the Basic Building Blocks. Modified by on 2-Jul-2014

Designing and Implementing Forms 34

How to Create a Custom TracDat Report With the Ad Hoc Reporting Tool

IBM Business Monitor V8.0 Global monitoring context lab

Novell ZENworks Asset Management 7.5

RIOS: A Lightweight Task Scheduler for Embedded Systems

Part I. Multiple Choice Questions (2 points each):

CS170 Lab 11 Abstract Data Types & Objects

Lab 1: Introduction to Xilinx ISE Tutorial

BusinessObjects Enterprise XI Release 2

GE Fanuc Automation CIMPLICITY

Table of Contents. Contents. Introduction. The Main Menu...1 The Fleet Manager...3. Step #2 - PM Schedule...8

Introduction on Contact Management Software EZY Call Manager 7. Prepare By : Joseph Har Web Site :

Using Microsoft Word. Working With Objects

The irnetbox Manager User Guide

Back Propagation Neural Networks User Manual

Logic gates. Chapter. 9.1 Logic gates. MIL symbols. Learning Summary. In this chapter you will learn about: Logic gates

How to build text and objects in the Titler

µtasker Document FTP Client

This exhibit describes how to upload project information from Estimator (PC) to Trns.port PES (server). Figure 1 summarizes this process.

An Introduction to MPLAB Integrated Development Environment

Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer

Before you can use the Duke Ambient environment to start working on your projects or

NETWORK PRINT MONITOR User Guide

Introduction to Simulink

Transcription:

Help on the Embedded Software Block Powersim Inc. 1. Introduction The Embedded Software Block is a block that allows users to model embedded devices such as microcontrollers, DSP, or other devices. It is a variation of the general DLL block. For more information on the use of the general DLL block, please refer to the document Help General DLL Block.pdf. However, unlike the general DLL block whose connection nodes are fixed and are predefined as either inputs or outputs, the node types of the Embedded Software Block can be programmed as needed. Also, additional information, such as the exact instant at which the state of a variable changes, can be calculated and passed to PSIM. This information can be used to minimize errors introduced by fixed time step simulation. 2. How to Use the Embedded Software Block We will use a comparator example to illustrate how to use the Embedded Software Block. For more details and the complete source code, one should refer to the example (schematic file: comparator_esb.sch ; source code: comparator.cpp ) The circuit on the left shows a buck converter with the gating signal generated by a comparator. The circuit on the right shows the same circuit, except that the function of the comparator is implemented using an Embedded Software Block. Embedded Software Block In this example, the Embedded Software Block has 16 ports. Ports P0 through P7 are inputs, and Ports P8 through P15 are outputs. The properties of the block, including the number of ports, port input/output types, port names, input parameters, are defined in the custom C++ code. The code includes the following data structure and functions: Page 1

struct Internal_DLL_Block_SimulationData: Variables used internally by DLL are defined here. void REQUESTUSERDATA: Function that defines port number, names, and parameters. void OPENSIMUSER: Function that reads parameters from the interface and performs initialization. void STARTSIMUSER: Function that defines the port type (input or output). void RUNSIMUSER2: Function that reads inputs from PSIM, performs calculation, and sends results back to PSIM. Defining Port Number and Parameters: The first step to define the Embedded Software Block is to define the number of ports and parameters. They are defined in the function REQUESTUSERDATA, as shown in the code below, highlighted in red: void REQUESTUSERDATA(int nrequestreason, int nrequestcode, int nrequestparam, void ** ptruserdata, int * pnparam1, int * pnparam2, char * szparam1, char * szparam2) switch( nrequestreason ) case ACTION_DLL_SELECTED: switch(nrequestcode) case REQUEST_IN_OUT_NODES: *pnparam1 = 16; //Define 16 ports *pnparam2 = 0; case REQUEST_INPUT_NODE_INFO: //Define port names nnode = nrequestparam; switch(nnode) case 0: strcpy(szparam1, "VDD/P0"); case 1: strcpy(szparam1, "P1"); case REQUEST_PARAM_COUNT: *pnparam1 = 1; //Define 1 parameter *pnparam2 = 0; strcpy(szparam1, "All Files *.* "); //File Open Dialog Filter for InputFile. case REQUEST_PARAM_INFO: switch(nrequestparam) case 0: //Define parameter name strcpy(szparam1, "Flag for Exact Switching"); strcpy(szparam2, "1"); //Set default parameter value as 1 *pnparam1 = 1; //Show Display check box Page 2

Reading Parameters from the Interface: The next step is to read parameters from the interface. In this case, one parameter, Flag for exact switching, is defined. This parameter will appear in the dialog window of the Embedded Software Block. To read the parameter value into the DLL, first define an internal variable called flag_exact_switching in the DLL structure Internal_DLL_Block_SimulationData. Then read the parameter value into DLL as shown in the code below. void OPENSIMUSER(const char *szid, const char * sznetlist, void ** ptruserdata, int *pnerror, LPSTR szerrormsg, void * ppsimparams) EXT_FUNC_PSIM_INFO * ppsiminfo = (EXT_FUNC_PSIM_INFO *)ppsimparams; assert(*ptruserdata == NULL); *ptruserdata = new Internal_DLL_Block_SimulationData; memset(pdata, 0, sizeof(internal_dll_block_simulationdata) ); pdata->m_ninputnodes = atoi(netlist[2]); pdata->m_noutputnodes = atoi(netlist[3]); int nparamstartindex = 5 + pdata->m_ninputnodes + pdata->m_noutputnodes; // Read the value of Parameter 1 from the interface pdata->flag_exact_switching = atoi( netlist[nparamstartindex] ); //Initialize internal DLL data pdata->vgat0 = 0.; In the code, pdata is the pointer to the internal DLL data structure, and both flag_exact_switching and Vgat0 are variables defined in the structure. Also, any initialization of the internal variables, such as the initialization of the variable Vgat0, is performed here. Defining the Port Type: The port types of an Embedded Software Block need to be defined in the code. A port can be defined as either input or output. In this example, Ports P0 through P7 are the inputs, and Ports P8 through P15 are the outputs. They are defined as shown in the code below. void STARTSIMUSER(int *porttypes, void ** ptruserdata, int *pnerror, LPSTR szerrormsg) if( pdata == NULL) for (int i=0; i<8; i++) porttypes[i] = TYPE_PORT_INPUT; for (i=8; i<16; i++) porttypes[i] = TYPE_PORT_INPUT; //Define P0 through P7 as inputs //Define P8 through P15 as outputs Page 3

Implementing the Function of a Comparator: The function of the comparator is implemented in the routine RUNSIMUSER2 which is called at every time step. Two arrays, ports and ports2, are used to transfer data between PSIM and the DLL. The array ports stores the voltages at each port. For example, in this example, ports[1] and ports[2] store the non-inverting input (Port P1) and the inverting input (Port P2) of the comparator, and ports[12] stores the output of the comparator (Port P12). The implementation in the code is shown below. void RUNSIMUSER2 (double t, double delt, double *ports, double *ports2, int *porttypes, void ** ptruserdata, int *pnerror, LPSTR szerrormsg) if( pdata == NULL) double Vm, Vcarr, Vm0, Vcarr0, Vdd; int iflag; Vdd = ports[0]; Vm = ports[1]; Vcarr = ports[2]; iflag = 0; if (Vm >= Vcarr) else ports[12] = 1.; if (pdata->vgat0 < 0.5) iflag = 1; ports[12] = 0.; if (pdata->vgat0 > 0.5) iflag = 1; //Inputs //If iflag=1, output has changed the state. //Implement the function of a comparator if (iflag && pdata->flag_exact_switching) //Calculate the exact switching instant Vm0 = pdata->vm0; Vcarr0 = pdata->vcarr0; ports2[12] = delt*(vm-vcarr)/(vm-vm0-vcarr+vcarr0); pdata->vm0 = ports[1]; pdata->vcarr0 = ports[2]; pdata->vgat0 = ports[12]; // Store the value for use in the next step The other array, ports2, is used to store the information of the exact instant of the change of a state. Since PSIM uses fixed time step simulation, a variable may change the state (for example, the output of a comparator or a logic gate changes from 0 to 1) between the two discrete points. For the sake of discussion, the time interval between the exact instant of state change and the current time is referred as time error. The array ports2, therefore, is used to store the time errors for each port. If the port is an input, the time error is passed from PSIM to DLL, and if the port is an output, the time error is passed from DLL to PSIM. If the time error is not taken into account, a small error will be introduced into the simulation, especially if the time step is large. However, PSIM can eliminate the simulation error by taking the time error into account in the calculation. Page 4

In this example, when the comparator output changes the state, the code calculates the time error using the present and historic values of the non-inverting and inverting inputs. This value is then stored in the array ports2 and passed to PSIM. To see the effect of the error correction, one can set the parameter flag for switching instant to 0, and run the simulation. The part of the circuit that uses the comparator will have the time error correction, and the circuit that uses the Embedded Software Block will have no time error correction. One would notice a small difference between these two inductor currents. Customizing the Image of the Embedded Software Block: Once the code is compiled and the DLL file for the Embedded Software Block is created, the block can be used in a circuit schematic, and the image of the block can be customized. Follow the procedure below to load the block and customize the image: In PSIM, go to Elements -> Control -> Other Function Blocks. Select Embedded Software Block, and place it on the schematic. Double click on the block, and click on the browser button at the end of the input field DLL File, and select the DLL file. In this example, the file comparator_esb.dll will be selected. Once the DLL file is selected, the block image will be changed to a rectangle, with all the nodes arranged on the left, and node sequence listed from the top to the bottom. To change the size of block, double click on the block, and click on the Edit Image button to enter into the image editor. Delete the pre-drawn rectangle and the arrow lines on the left. Then go to File -> Set Image Size to set the width and height of the block. In this example, both the width and height are set to 7. To rearrange the location of the ports, first clear all the ports by going to File -> Reset Outputs. Then left click on the diamonds to define the port location. In this example, for instance, click on the 2 nd diamond from the top on the left for the location of Port P0, and a number 1 will appear inside the diamond which represent the first port. Redraw the block image using the drawing utility. Page 5