PIC Simulator IDE 6.96

0
303

A Windows-based shareware for the simulation of PIC microcontrollers. It provides users with a powerful, easy-to-operate and quick processing environment

Anagha P.


PIC Simulator IDE is a powerful tool that assists simulation of PIC family of microcontrollers. It provides developers with a rather simple, comprehensive, user-friendly graphical user interface (GUI) for Windows. This tool also provides users with features such as integrated simulator (emulator), Basic compiler, assembler, disassembler and debugger.

Currently, this program offers full support to the 57 microcontrollers from Microchip’s PICmicro 10F, 12F and 16F series. These models are listed in the table on page III. Some of the microcontroller models are provided with only limited support. It does not back some high-level functionalities such as AllDigital, Adcin, Read, Write, Hseropen, Hserout, Hserin, Hserget, Count, PWMon, PWMduty and PWMoff statements. But all the other basic compiler elements are fully supported. Another limitation is that, only Digital I/O is simulated for these models. The microcontrollers with limited support are listed in the table.

Features
The main simulation interface of the program shows the internal architecture of microcontroller. It has several functionalities such as EEPROM data memory editor, FLASH program memory editor, hardware stack viewer, variable simulation rate, simulation statistics, PIC assembler, an interactive assembler editor for beginners, PIC disassembler and configuration bits editor.

8AB_Fig_1
Fig 1: Home screen
5A5_Fig_2
Fig 2: Tools menu
Explore Circuits and Projects Explore Videos and Tutorials

The powerful PIC Basic compiler with smart Basic source editor features the three basic integer data types (1-bit, 1-byte and 2-byte), and optional 4-byte that supports 32-bit arithmetic. The program bundles various simulation modules and interfaces, and also offers support for external simulation modules. It provides breakpoints manager for code debugging, along with breakpoints support.

PIC Simulator IDE is provided with PC’s serial port terminal for proper communication with real devices connected to serial port. It has extensive program options, and even colour themes to customise the appearance. All these factors make this tool simple, interesting and user-friendly.

Installation
Windows Vista, Windows 7 and Windows 8 users: After installing the setup file picsimulatoridesetup696.exe, when you run the program for the first time, right-click on the application shortcut in Windows Start menu (or on the executable file picsimulatoride.exe) and choose the option Run as administrator. Else, an error message would be displayed, which reads: Unexpected error; quitting.

This needs to be done only for the first time the program is opened. From next time onwards, the file can be opened as normal by clicking the shortcut in Start menu or double-clicking the program file using left mouse button and the program gets launched.

READ
LTSpice IV: Ideal for SMPS Simulations
D61_Fig_3
Fig 3: Basic compiler
Z47_Fig_4
Fig 4: Modules and interfaces

The default storage location of program files is the PIC Simulation IDE subfolder in Program Files folder. Some example files to work with are stored in this subfolder. Modifying these files requires admin rights, without which the error message “Run-time error ‘75’: Path/File access error” appears. It also contains three manuals for the users: for getting started, compiler reference and for external modules. Modifying files stored in Program Files folder requires admin rights.

To permanently set the program to run with administrator privileges, right-click on the program icon, select Properties, click on the button Advanced and tick the Run as administrator check box. Administrator rights are not required if the project files are stored in a user private folder (for example: My Documents.)

Getting started
The main window (refer Fig. 1) shows the location of the program being executed, name of the PIC selected, clock frequency, mnemonics of the instruction last executed and the one about to be executed, instructions and clock cycles counter, real-time duration of the simulation and the statuses of internal registers.

The File menu has options to load a program to the PIC memory, clear memory and save memory. From the Simulation menu, you can start or stop a simulation, execute the next step of simulation (when Step By Step simulation rate is selected), or run to the next Basic statement for programs generated by integrated Basic compiler. The user can set the simulation rate to Step By Step, Slow, Normal, Fast, Extremely Fast, and Ultimate from Rate option in the menu bar.

AZB_Fig_5
Fig 5: Timer
64F_Fig_6
Fig 6: 7-segment LED

2AZ_boxThe Tools option (Fig. 2) gives a variety of modules and interfaces to choose from. Basic compiler opens the integrated Basic compiler editor window, as shown in Fig. 3. The Basic Compiler Reference Manual in Help menu of main window (or Options of Basic compiler editor window) contains more information on this module.

The Assembler command starts integrated assembler. In this window, the assembler source files can be edited and assembled. A similar Disassembler option starts disassembling automatically when this option is selected. Once the operation is complete, the output file is displayed and the user is prompted to save it.

Other main modules and interfaces include Microcontroller View, EEPROM Memory Editor, 8 x LED Board, 7-Segment LED Displays Panel, Stepper Motor Phase Simulator, Oscilloscope, Signal Generator, LCD Module, etc. Fig. 4 shows the screenshot of some of these modules.

Example 1: Timer0 module simulation
The easiest example file given in the package is that of an 8-bit Timer0 module of PIC16F84. The BASIC file timer0.bas uses Timer0 module interrupts to periodically change the value on Port B pins. The assembler source file timer0.asm was generated using Basic compiler integrated with the tool and the hexadecimal source file timer0.hex was generated using the integrated assembler:

TRISB = 0x00 ‘set all PORTB pins as
outputs
PORTB = %11111111 ‘make all PORTB
pins high
INTCON.T0IE = 1 ‘enable Timer0
interrupts
INTCON.GIE = True ‘enable all
un-masked interrupts
OPTION_REG.T0CS = False ‘set Timer0
clock source to internal instruction
cycle clock
End
On Interrupt ‘interrupt routine
PORTB = PORTB – 1 ‘decrement the
value on PORTB
INTCON.T0IF = 0 ‘enable new TMR0
interrupts
Resume

Go to File > Load Program, or press Ctrl+L. Browse and select the file timer0.hex from the window, and open it. The path of the file now appears in the box next to Program Location, and the file will be loaded into IC program memory.

READ
Portability and Low-Power - Drive Power Analysis

Select the PIC model from Options > Select Microcontroller (or simply click on the box next to Microcontroller in main window) and select the appropriate microcontroller (PIC16F84 in this example) from the window.

To open the graphical view of microcontroller pinout and logic states, click on Tools > Microcontroller View. Select the simulation rate to Extremely Fast from Rate in menu bar (or press Ctrl+F5.) The simulation will start immediately when you select Simulation > Start, or press F1. To stop the simulation any time, click on Simulation > Stop (or press F3.)

It is to be noted that, in order to compile this file for other PIC microcontroller models, you may have to change T0IE and T0IF bit names in the source code to TMR0IE and TMR0IF. The datasheet of the model you want to use would have the correct bit names for the INTCON register.

Example 2: 7-segment LED display simulation

The following Basic program makes the numbers 0 to 100 display on a 7-segment LED display:

658_A56_Table

Dim digit As Byte ‘input variable for
GETMASK subroutine
Dim digit1 As Byte ‘current high
digit
Dim digit2 As Byte ‘current low digit
Dim mask As Byte ‘output variable
from GETMASK subroutine
Dim mask1 As Byte ‘current high digit
mask
Dim mask2 As Byte ‘current low digit
mask
Dim i As Byte
Dim phase As Bit
Symbol d1enable = PORTC.0 ‘enable
line for higher 7-segment display
Symbol d2enable = PORTC.1 ‘enable
line for lower 7-segment display
TRISB = %00000000 ‘set PORTB pins as
outputs
TRISC.0 = 0 ‘set RC0 pin as output
TRISC.1 = 0 ‘set RC1 pin as output
d1enable = False
d2enable = False
mask1 = 0
mask2 = 0
phase = 0
INTCON.T0IE = 1 ‘enable Timer0
interrupts
INTCON.GIE = 1 ‘enable all un-masked
interrupts
OPTION_REG.T0CS = 0 ‘set Timer0 clock
source to internal instruction
cycle clock
loop:
For i = 0 To 99
digit1 = i / 10 ‘get current high
digit
digit2 = i Mod 10 ‘get current low
digit
TMR0 = 0 ‘reset Timer0 to prevent its
interrupt before both masks are
determined
digit = digit1
Gosub getmask ‘get mask for high
digit
mask1 = mask
digit = digit2
Gosub getmask ‘get mask for low digit
mask2 = mask
Gosub show1 ‘display new mask
Gosub show2 ‘display new mask
WaitUs 500 ‘delay interval suitable
for simulation
‘use large delay for the real device,
say WAITMS 500
Next i
Goto loop
End
On Interrupt ‘Timer0 interrupt
routine
‘continuously switch between high and
low digit displays
If phase = 0 Then
phase = 1
Gosub show1
Else
phase = 0
Gosub show2
Endif
INTCON.T0IF = 0 ‘enable new TMR0
interrupts
Resume
getmask: ‘get appropriate 7-segment
mask for input digit
mask = LookUp(0x3f, 0x06, 0x5b, 0x4f,
0x66, 0x6d, 0x7d, 0x07, 0x7f,
0x6f), digit
Return
show1: ‘show high digit on its
display
d2enable = False
PORTB = mask1
d1enable = True
Return
show2: ‘show low digit on its display
d1enable = False
PORTB = mask2
d2enable = True
Return

Similar to the previous example, open File > Load Program and select the file 7segment.hex. Select the microcontroller PIC16F877. Go to Options > Change Clock Frequency or click on the box next to Clock Frequency in the main window and enter the value 4.

READ
Pocket-Friendly Oscilloscopes Under Rs. 50,000

Select 7-Segment LED Displays Panel from Tools. That will open the 7-segment displays window. In this panel, click on Setup button just below display 2. On the orange field next to Display Enable option, click twice to select the pin that will be used, that is, PORTC and 0. Click on Setup button below display 1 and click twice near Display Enable label as before, and select PORTC,1. Select the Rate to Ultimate. Start simulation by pressing F1.

Now the LED module starts displaying numbers from 0 to 99. The screenshot of this is shown in Fig. 6.

Licence
This version of PIC Simulator IDE runs on Evaluation licence. You can start the program 30 times; each session will last for 120 minutes (two hours). After this trial period, a licence needs to be purchased for further use.

Download latest version of the software: click here


The author is a technical correspondent at EFY, Bengaluru

LEAVE A REPLY