VMLAB is free virtual oscilloscope for AVR
VMLAB is one of well known free simulators that support AVR microcontrollers. You may get free version of VMLAB tools from amctools. The simulation is done not in real time as computer resources wouldn’t allow this, but all timings of processes viewed in virtual oscilloscope are tied to real world values.
VMLAB is a project workspace where special scripting language describes the initial conditionas and circuit showing to virtual simulator connections between hardware and microcontroller. Few pre-built examples you may find in folders C:\VMLAB\AVR_demo and C:\VMLAB\ WinAVRdemo (for default installation in C:\VMLAB\ folder).
VMLAB quite rich in its hardware support: Resistors, Grounded capacitors, Interactive switches / keys, LED diodes, Pulsed voltage source, Sine wave voltage source, Slider dependent voltage source (interactive), Non-ruturn-to-zero (NRZ) generator (interactive), Operational amplifier, Comparator, 2 inputs NAND gate, 8 bits D to A converter, RS232 based TTY (interactive), LCD module, I2C monitor (interactive), Interactive keypad 4x4 Multiprocess-dedicated: External Input, External Output. Actually you can do a wide range of simulations with your virtual embedded system before taking it to the real world. VMLAB also has a powerful scope feature where you can view voltages on pins or even some internal microcontroller register values like ACO, TIMOVF.
Following example will show how to make simple project using VMLAB tool.
Create new project by selecting Project-New.
Select project properties: project location, c file name, microcontroller, software tool-chain (WINAVR) for compiling and make file generation (automatic or define yours).
Press OK and you are transferred to project area, where you will find project file with selected properties:
.TRACE ; Activate micro trace
.POWER VDD=5 VSS=0 ; Power nodes
.CLOCK 1meg ; Micro clock
.STORE 250m ; Trace (micro+signals) storage time
Also there is leds.c file window opened with some example code.
Let’s simulate two blinking LED diodes on Atmega128. Connect them to pins PD0 and PD7 using current limiting 620Ohm resistors:
Set up the circuit connections in project file by adding script. Also let’s define signals we want to see in scope.
Connect diodes and resistors by writing four lines in project file:
D1 VDD D1_NODE
R1 D1_NODE PD0 0.62K
D2 VDD D2_NODE
R2 D2_NODE PD7 0.62K
After circuit is set up, then we can setup scope:
.PLOT V(PD0) V(PD7)
After project file is set up, then we need to write simple program:
Build the code. If there are errors then correct them according to messages. If everything is all right you should get message:
Now it’s time to run simulator. Open control panel
There you see the main peripherals. Diodes D1..8, three sliders (potentiometers), keypad and microcontroller settings: speed (you can slow down you code), temperature and clock speed.
In our project we need only diodes D1 and D2.
Open scope windows from View-Scope menu to be able visually see the signals on microcontroller pins.
Simulation is controlled using toolbar:
You may run your code continuously, step over, step in and out and animate (slow performance). Press GO/Continue button. In scope window you can see how signals are changing in microcontroller pins:
And in control panel you can see how Diodes D1 and D2 blink:
If simulation results are OK you may burn the code in to real chip.