LOAD Load Resistance FLOAT (PNZ) NORMAL 100M
SCALE Scale Multiplier FLOAT (PNZ) HIDDEN 1.0
PRIMITIVE Primitive Type STRING HIDDEN ANALOG,RTVPROBE
The LOAD and SCALE values are passed through the netlist to the RTVPROBE primitive and determine respectively its load resistance and a factor by which it multiplies the voltages it measures. If you were making a milli-voltmeter you would default this value to 1000.
The PRIMITIVE property causes PROSPICE to represent the voltmeter directly as anRTVPROBE;
there is no model file and no DLL based electrical model is expected.
Note that if you were going to implement an electrical model, you would use the MODDLL property to specify the DLL filename, and that the PRIMITIVE property would still be required in addition since a VSM electrical model is a primitive.
Active Model Settings the VOLTMETER
Finally, the Active Model tab of the Make Device dialogue needs to be set up as follows:
The name stem matches the two sprite symbols and also acts as the name of the VSM model DLL.
Checking the Link to DLL checkbox tells ISIS that a VSM graphical model for the voltmeter should be found in READOUT.DLL.
Setting up the C++ Project
The next stage in the process is to set up a C++ project for READOUT.DLL.
Exactly what you do will depend on the compiler that you use and the complexity of the model, but typically you will need to create a header file, a C++ code file and to set up your IDDE to produce a 32 bit DLL.
You will also need to ensure that the VSM API header file - VSM.HPP is on your compilers INCLUDE path.
The Header file
For this model, the header file is fairly small and is shown below:
#include <vsm.hpp>
// Product ID value obtained from Labcenter:
#define READOUT_KEY 0xXXXXXXXX class READOUT : public IACTIVEMODEL
{ public:
// Implementation of IACTIVEMODEL
VOID animate (INT element, ACTIVEDATA *newstate);
BOOL actuate (WORD key, INT x, INT y, DWORD flags);
private:
You will see that the READOUT class is derived off (and implements) theIACTIVEMODELinterface.
Note in particular that IACTIVEMODEL is an abstract class and class READOUT must therefore implement all of its functions, even if some of them are going to do nothing.
For information on how to obtain a valid product ID for the definition of READOUT_KEY see the reference section on theLicencing Interface.
Model Construction and Licencing
Code of the following form is required in every VSM DLL. It is required in order to facilitate the construction of both graphical and electrical models by ISIS and PROSPICE.
extern "C" IACTIVEMODEL * __export createactivemodel (CHAR *device, ILICENCESERVER *ils)
// Exported constructor for active component models.
{ if (ils->authorize (READOUT_KEY)) return new READOUT;
else
return NULL;
}
extern "C" VOID __export deleteactivemodel (IACTIVEMODEL *model) // Exported destructor for active component models.
{ delete (READOUT *)model;
}
The creatactivemodel function must alsoauthorize the modelusing the ILICENCSERVER interface. If a model fails to authorize correctly, it will not receive any further service from the simulator.
Initializing the Model
Once the model has been authorized by the licence server, ISIS will call its initialize function, and pass it anICOMPONENTinterface. This links it to the voltmeter component on the schematic. Almost invariably, the model will preserve this interface for use its other member functions.
VOID READOUT::initialize (ICOMPONENT *cpt) { // Store ICOMPONENT interface and initialize.
component = cpt;
// Get origin and style for readout text
The initialization code also establishes the location of the READOUT_1 sprite, where it will eventually draw the reading, and creates a text style in which the text will be drawn. The "ACTIVE READOUT"
style is one of the pre-defined text styles accessible from the Set Text Styles command in ISIS. The results of these actions are stored in member variables for use by the plot and animate functions.
Combined Graphical/Electrical Models
Although the READOUT model implements only graphical functionality, the VSM API provides for models to implement electrical functionality as well, within the same C++ model class. This works through the use of multiple inheritance, with the model class deriving off bothIACTIVEMODELand ISPICEMODEL, for example. The following two functions allow for this possibility and enable a graphical model to return its electrical interface(s). In this case however, they are coded to return NULL.
ISPICEMODEL *READOUT::getspicemodel (CHAR *) { return NULL; } IDSIMMODEL *READOUT::getdsimmodel (CHAR *) { return NULL; } Drawing on the Schematic
The major function of class READOUT is to draw the voltmeter and its reading on the screen, both when ISIS redraws the entire schematic, and also as a result of changes in the reading itself. The plot function deals with the former whilst the animate function handles the latter.
The plot function must ensure that the entire graphics of the voltmeter are redrawn. To do this, it first calls ICOMPONENT::drawsymbol(-1) which causes ISIS to draw the standard (non-animating) version of the library part. Then it calls ICOMPONENT::drawsymbol(1) which draws the READOUT_1 symbol on top of that. And finally it draws the readout text itself.
VOID READOUT::plot (ACTIVESTATE state)
// Plot function - this is called for normal rendering.
{ component->drawsymbol(-1);
component->drawsymbol(1);
component->drawtext(textorg.x, textorg.y, 0, TXJ_CENTRE|TXJ_MIDDLE, readout);
}
The animate function is more complex since it must process theACTIVEDATAstructures it receives from theRTVPROBEprimitive.
VOID READOUT::animate (INT element, ACTIVEDATA *data) // Animate function - this is called whenever an event is // produced by the simulator model.
// We interpret real values only, as follows:
if (data->realval > 0.001)
// Now we work out where to place the decimal point:
if (absval >= 1000)
// Final, re-draw the display value within the result text // within it:
TheRTVPROBEtransmits real valued data, so the data->realval member will contain the actual voltage measurements. This value is processed to establish the best way to display it, using no more than 5 characters. The logic enables values from +/- 0.01 to 999.9 to be displayed; any larger values appear as +MAX or -MAX.
Once the result string has been generated, the model calls ICOMPONENT::drawsymbol(1) to draw a blank display panel (thus obliterating any previous reading) and then ICOMPONENT::drawtext to draw the new reading.
Note that the animate function does not redraw other parts of the voltmeter graphic; only those parts which change need to be updated.
Event Handler
VSM models which need to respond to mouse or keyboard events can do so through their actuate function. Since the READOUT model does not need to do this, it just returns FALSE.
BOOL READOUT::actuate (WORD key, INT x, INT y, DWORD flags) { return FALSE;
}
INTRODUCTION
The active component technology built into ISIS is unique in that it allows you to create your own library parts which can then be animated by the simulator. This greatly enhances the usefulness of the circuit animation facility since you are not restricted to a small set of hard coded animated components.
Creating your own active components is reasonably straightforward if you are familiar with creating ISIS library parts and simulator models in PROTEUS. However, like the creation of good simulator models it requires a good grasp of electronics and some imagination in order to achieve the best results.
Pre-requisite skills include:
• Familiarity with the 2D graphics capabilities of ISIS, including the use of graphics styles, and knowledge of how to adjust colours, line widths, fill styles etc. Full details are to be found in the ISIS manual.
• The creation of ordinary library components (devices). Again, this is covered in detail in the ISIS documentation.
• The creation of simulator models (MDF files). Theanalogueanddigitalmodelling tutorials are the best place to start with this.
There are basically two types of active component:
• Indicators- these are components which respond graphically to events occurring within the simulation. Examples include light bulbs, LEDs and logic probes. Indicators can either be n-state, or bitwise, and can be controlled directly from the pins of the parent part, or from probes located within a more complex simulator model.
• Actuators- these are components which have mouse operated elements, and whose operation changes the electrical state of the circuit. Examples include switches, potentiometers and logic state inputs. Actuators can be latched, or momentary and can have an arbitrary number of states.