miSim DE Back Index Next

Chapter 5 - Plugins

Available Plugins

miSim DE is released with a set of available plugins, defined in the settings file. These plugins carry out a number of different functions. As the code is freely available, they may also serve as templates for writing your own plugins. Plugins may slow down simulation, depending on how much work they need to carry out to synchronise with the simulated processor. In general therefore, plugins can be divided into three classes, Fast, Medium and Slow.

The following is a list of the available plugins, their type and what they do. More details of each are available in the following section.

Plugin Type ConfigurableFunction
Television Medium NoSimulates a video display
Simple Led Medium NoA simple, non configurable LED
Better Led MediumYesA configurable LED
Simple Switch Fast YesA switch, toggle or momentary
Keypad Fast YesA hex keypad
Five Switches Fast YesA set of five switches
LED Array Medium NoAn array of four LEDS
7 Segment LED MediumYesOne or two seven segment LED displays
Memory MonitorFast NoDisplays the registers and EEProm contents
Breadboard Fast YesDisplays the chip I/O state
LCD Display Slow YesHD 44780 compatible LCD display
Stepper Motor MediumYesA Stepper Motor
Capacitor DelayMediumYesA capacitor delay input

Fast plugins make no attempt to synchronise with the processor - they either only update when simulation is completed, or only respond to user actions. Examples of fast plugins would be the Memory Monitor (which only updates at the end of a 'Step' or 'Over', or when 'Stop' is clicked) or the Simple Switch, which interacts with the microcontroller only when the user presses the switch. Simulation speed is hardly affected by Fast Plugins at all.

Medium plugins respond to output from the microcontroller. Whenever a signal from the microcontroller ports changes, a Medium plugin is informed of the event and can perform an appropriate task. Clearly the task will take longer if the plugin must decode a complex set of signals, or if it must draw graphics to the screen. Simulation speed will depend on how much work the plugin will do for each signal change, and how often the simulated program alters those signals. Examples of Medium plugins are the LEDs, which update whenever the port outputs change, or the Television plugin, which builds a video picture from the outputs generated by the microcontroller.

Slow plugins are exactly synchronised with the microcontroller, so that they can behave correctly with regards to generating signals to the microcontroller. A Slow plugin is informed after each instruction is simulated, so that it can update or monitor signals for the microcontroller. In fact, the interrupt simulation for the microcontroller is a form of slow plugin. Invoking a plugin every time an instruction is executed slows down the processor enormously. An example of a Slow plugin is the LCD display, which times its busy signal to be synchronised with the microcontroller. In fact the LCD plugin does its best not to slow down simulation, by only requesting full synchronisation when it is busy.


Configuring Plugins

Configurable plugins may allow the user to control any aspect of their function. The Plugin Window provides a standard way to edit each plugin's configuration - either by editing a text string that defines how the plugin behaves, or through custom controls. The configuration text may take any format that suits the plugin, but there are conventions that are described below which are common to many plugins. In miSim DE 2.0 Plugins may also specify a set of controls that will be displayed in the Plugin window to configure them. These controls may include drop-down boxes for selections, check boxes and text input.

If the configuration of a plugin is likely to be very complex, the Plugin author can choose to design their own user interface to edit or view that configuration.

Port Connections

Plugins are often connected to a port on the microcontroller. The connection can be specified in a standard notation - the port name followed by a colon and the number of the bit to be connected to. On the PIC16X84, the ports are named 'Port A' and 'Port B'. Port A is a five bit port (bits 0 to 4) and Port B is an eight bit port (bits 0 to 7). Therefore, to connect a Plugin to a single pin of one of these ports, the connection might be specified as:

Port A:0 - For Port A, Bit 0

The notation of port name:bit number is used in this manual to identify a particular bit on a given port, and is used in config strings for the same purpose.

Plugins may wish to connect to more than a single pin of a port, however. miSim DE provides a standard piece of software to handle these connections, called the Port Mapper. The Port Mapper provides a standard way of describing and processing a larger number of connections to one or more ports. To describe the connections, each of the signals that must be linked to the plugin is named with a single character. For example, if the Plugin has a four bit bus, the four connections that must be made could be called '0','1','2' and '3'. If the Plugin has an Enable signal, it might be called 'E'.

To tell the port mapper the connections from the Plugin's signals to the microcontroller, the config string lists a port name, followed by the signals connected to that port. The signals listed for each port are in order of the port bits - with the '0' bit last. So the mapping:

Port A:ER

Connects the signal 'E' to Port A, bit 1 and the signal 'R' to Port A bit 0. If a port bit is not connected to any signal, it can be marked with an 'x'. Only as many bits as are connected need to be listed. Another example would be:

Port A:WRxE

Which maps the signal 'W' to Port A, bit 3 and the signal 'R' to Port A, bit 2. Bit 1 of Port A is not mapped to any signal. Port A bit 0 is mapped to the signal 'E'.

If more than one port is mapped, then each port mapping is comma separated. For instance:

Port A:WRxE, Port B:3210

Which adds to the Port A Mapping above the signals '3' to '0' mapped to bits 3 to 0 on Port B.


Plugin Details

Television

Television Plugin

The Television plugin simulates a composite video display connected to Port A:0 for the sync signal, and Port B:0 for the brightness signal. The plugin assumes that the processor is running at 12MHz. This is compatible with the hardware and software developed by Rickard Gunée to play Pong and Tetris on the PIC MCU. For more information on generating video signals in software on the PIC MCU, visit Rickard's excellent homepage.


Simple LED

Simple LED Plugin

The Simple LED Plugin is a handy code example for producing a Plugin that responds to an output from the microcontroller. In this case, the LED lights when Port B, bit 0 is high ('1').


Better LED

Better LED Plugin

The Better LED is more sophisticated than the Simple LED in that the port that the LED is connected to can be configured, as can the colour of the LED. As with the Simple LED, the LED lights when the chosen port pin is high ('1').

The configuration string for the Better LED is as follows:

Port Name:Bit Number [Colour]

Port Name is the name of any port for the simulated microcontroller. In the case of the PIC16X84, the choices are 'Port A' or 'Port B'. The bit number is the bit number on the port. The PIC16X84 Port A can have a bit number of 0 to 4 (it is a five bit port). Port B can have a bit number of 0 to 7 (an eight bit port). The Colour parameter is optional and is a single character indicating the colour of the LED. The colour may be 'r' - Red, 'g' - Green or 'b' - Blue. If no colour is specified, the LED will be red. An example configuration for a green LED connected to Port B, bit 5 would be:

Port B:5 g


Simple Switch

Switch Plugin

The Simple switch provides both momentary and toggle switches in one. You can click 'Toggle' to switch from 'On' to 'Off' and back again. Clicking 'Momentary' will turn from 'On' to 'Off', or vice-versa only as long as the button is clicked. The switch can be connected to any Port pin, with the configuration string:

Port Name:Bit Number

For example to connect a switch to Port A, bit 0, the configuration would be:

Port A:0


Keypad

Keypad Plugin

The Keypad plugin encodes the button pressed as a hex value and sends it to the microcontroller. The configuration string specifies which port bits to send the four bit data to. The port mapping uses the four signals as '3','2','1' and '0', they can be mapped to the microcontroller port using the standard syntax:

Port Name:Mapping [,PortName:Mapping]

For example to connect the keypad to Port B, bits 0-3, the configuration would be:

Port B:3210


Five Switches

Five Switch Plugin

The five switch plugin shows five switches as check boxes that can be selected or deselected. The switches are connected to the microcontroller through a port mapping, with the five signals identified as '4','3','2','1' and '0'

For example to connect switches to Port A, bits 3-0 and Port B bit 1, the configuration would be:

Port A:4321, Port B:0x


LED Array

LED Array Plugin

The LED Array is an array of four red LEDs connected to Port B, pins 0 to 3. It cannot be configured, but is an example of altering the simple LED plugin to provide different behaviour.


7 Segment LED

7 Segment LED Plugin

The Seven Segment LED plugin can provide one or two seven segment LEDs connected to port B. The configuration string decides one of the following settings:

ConfigurationBehaviour
bOne digit, each segment connected to a separate pin
d1One digit, displays hex value on pins 0-3
d2Two digit, displays hex values on pins 0-7


Memory Monitor

Memory Monitor Plugin

The Memory Monitor plugin displays the contents of the Registers and EEProm of the microcontroller being simulated. It updates when simulation is complete - i.e. after each 'Step' or 'Over' command, or when 'Stop' is clicked to stop a running simulation.


Breadboard

Breadboard Plugin

The breadboard plugin displays the I/O state of the microcontroller. Each I/O pin is marked as either green (0 - low) or red (1 - high) to show its level. In addition, a grey pin 'shadow' inside the body of the microcontroller indicates that the pin is defined as an input (Controlled by the TRIS register on Pic Microcontrollers).

The configuration for the breadboard plugin allows the user to select the package type for the microcontroller being used, and to set the breadboard to update only when simulation stops, or after each simulated instruction. If 'Always update' is selected, the breadboard will refresh after every instruction - this will dramatically slow down simulation.


LCD Display

LCD Display Plugin

The LCD Display simulates a HD 44780 controlled LCD display. The display has three controlling signals, and either four or eight data lines that must be connected to the microcontroller. The display may be one, two or four lines deep, and may have eight, sixteen, twenty, twenty-four, thirty-two or forty columns. Note that some combinations of height and width are not available. Those that are supported are shown below:

 Columns
Rows 81620243240
1YesYesYesYesYesYes
2NoYesYesYesYesYes
4NoYesYesNoNoNo

The three controlling signals are 'R' - Read/write, 'E' - Enable and 'S' - Select. The eight data signals are indentified by the digits '0' through '7'. If a four bit interface is being used (selected in software), then only bits '7' through '4' need to be connected.

To configure the LCD, the height and width are specified, then the port mappings for the control and data signals are given. The LCD plugin uses a Port Mapper to read these settings, so the format for the mappings is standard, and shown below. The basic config therefore is of the form:

HEIGHTxWIDTH, Port Mappings

A Port mapping consists of the Port name, a colon and then the relevant signals that are connected to that port. The signals are listed in port bit order, with the least significant bit last. Pins that are not connected to a signal are indicated with an 'x'. Therefore the mapping 'Port A:ExxRS' will connect the signal 'E' to Port A, bit 4, the 'R' signal to Port A, bit 1 and the 'S' signal to Port A, bit 0. If more than one port is mapped to different signals, then the additional ports are separated by commas.

In the case of the LCD plugin, the signals are 'R','E','S' and '7-0', though signals '4-0' are not needed if a four bit interface is being used. A simple configuration for a one line, eight character display connected with an eight bit interface might be:

1x8, Port A:ERS, Port B:76543210

A two line by twenty character display, connected with a four bit interface might be:

2x24, Port A:ERS, Port B:7654xxxx

For more information on the HD 44780 display controller and writing software for it, you can visit Peer's LCD Pages or Ian Harries' LCD Information


Stepper Motor

Stepper Motor Plugin

The Stepper Motor plugin simulates a bipolar stepper motor that takes four inputs - mapped as signals '3', '2', '1' and '0'. The size of a single step can be controlled by entering the appropriate value into the text box in the stepper window - the default is a step of 7.5 degrees. A typical configuration string simply maps the signals onto the appropriate port pins, for instance:

Port B:3210xxxx to map the singals onto the upper four bits of Port B.

Capacitor Delay

The capacitor delay plugin is a real time plugin - it is not synchronised to the simulation, but operates in a separate thread. It simulates a capacitor delay - setting the output bit to the inverse value of the input bit after a certain time. The input and output bits are mapped as signals 'I' and 'O' respectively, and might be used in a configuration such as:

Port B:IO to map the input to Port B:1 and the output to Port B:0.

The duration of the delay is shown in the window of the plugin, and may be altered by typing in a new number. The delay is in milliseconds.

Index Next