Interactive Debugging
Interactive simulation of microcontroller circuits provides a powerful extra dimension in application design and debugging. Proteus VSM offers a complete design package, with schematic editing and capture, using a library of components which provides a graphical symbol for the schematic, a mathematical model for circuit analysis and component pin-out for use in the circuit layout. These are provided in two software packages, ISIS schematic capture and ARES PCB layout. Detailed guidance on using Proteus VSM is given in Appendix E.
ISIS Schematic
The application design concept may be outlined using a block diagram and converted to provisional circuit, which can be entered into ISIS. The components are selected from the library of parts, placed on the screen and connected using virtual wiring. The result is a schematic such as that for MOT1 seen in Figure 9.3, which includes a virtual oscilloscope for monitoring the output.
Mixed mode simulation uses standard circuit modeling techniques for the analogue parts of the circuit. For example, the mathematical model for a resistor is V ¼ IR. The behavior of reactive components (e.g. capacitors and motors) is modeled using complex mathematics, which is used to represent the phase relationships between voltage and current, and hence transient and frequency response in switching circuits. Overall, the analogue parts of a circuit are represented as a set of nodes connected together by these components, forming a mesh. This is then represented by a set of simultaneous equations in the form of a matrix, which can be solved for any given input signals. This process is repeated at intervals to predict the output and provide a dynamic, interactive model of the circuit.
Modeling the digital circuit elements, on the other hand, is simply a question of representing the logical processes performed by the components using a suitable logical model. For example, the output of an AND gate is A$B (see Appendix B). The microcontroller is represented by a combination of its internal logic and the application program attached. The effects of all types of component can then be combined to give a reasonably complete model
of the whole circuit. The main limitation of the simulation is that it sometimes fails to converge on a solution, especially in complex or high-speed circuits. The model then needs to be simplified, resulting in a less accurate simulation. Of course, the model is only an approximation to the real circuit in any case, especially when modeling complex devices such as motors.
The components used in MOT1 are mostly generic types, that is, they do not represent a specific component. For example, the resistor has a model described as an ‘analogue primitive’ or generic model. The capacitor is the same. The push button is an active device, that is, it can be operated on screen, in either transient (click on button) or latched (click on control spot) mode. The generic NMOS FET (see Appendix B) could be replaced by a specific component that has a model tailored to the operating parameters of that particular device. The dc motor parameters can be changed in the properties dialogue (i.e. operating voltage, nominal speed and coil resistance).
The microcontroller, in contrast, is a specific device from a particular manufacturer. It needs a machine code program (hex file) to be attached to determine its operation. This can be created in a built-in editor and, if a PIC, assembled using a copy of MPASM included with the simulation package. The hex file is attached via the component properties dialogue (double- left-click on the component). The clock speed (100 kHz) and configuration word can also be defined in this dialogue. The components are selected from the component libraries as illustrated in Figure 9.4.
The oscilloscope is one of a selection of virtual instruments. The power supplies are represented by a ground (0 V) connection and a power terminal whose supply voltage is
specified by the label (þ5 V and þ12 V). These additional items are selected via the mode toolbar buttons at the left of the edit window (see Appendix E for details).