UnoArduSim : A Simulator | Arduino Simulators Alternatives
Every Embedded Devloper or electronic enthusiasts knows and uses Arduino boards and Arduino IDE. I already published many articles on Arduino. Now we discuss UnoArduSim. The UnoArduSim is an Arduino simulator that allows you to do real-time code debugging on an Arduino Uno and Arduino Mega boards. This simulator is used for compiling and testing the codes.
UnoArduSim was developed by Professor Simmons of Queen’s University, Ontario, Canada. He used the platform to teach second year students of Department of Electrical and Computer Engineering. The graphical simulator was developed to allow students to test their robotic codes without requiring any additional hardware.
Arduino is a great platform, but If you’re trying to debug a program with a mix of software bugs and hardware issues, you could use a free helping hand! UnoArduSim.exe allows you to do a real-time test of most Arduino programs (for Uno, and Mega as of V2.8.0) without needing most actual hardware. Supported libraries are: TFT.h, SD.h, Stepper.h, Servo.h, SoftwareSerial.h, Wire.h, SPI.h, OneWire.h, and EEPROM.h (all for the Arduino V1.8.8 release)., as well as some 3rd party libraries for LCD and LED displays.
UnoArduSim provides a virtual target Uno board and allows the user to choose, and interface to, one or more of several types of virtual input/output devices. These include typical hobbyist DC gear-motor, stepper-motor, and servo motors, generic serial devices with selectable baud rate, generic I2C and SPI slaves, as well as I2C and SPI based LCD and LED controllers and port exapnders, an SD card and TFT display with SPI interfaces, digital and analog waveform generators, piezo speakers, LED’s. 7-Degment LED digits, push-buttons, resistive pull-ups and pull-downs, and slider potentiometers. All devices are accurately modelled electrically (and mechanically).
You can load and edit (and correct) your Arduino program, then run, run-to, halt, step-into, step-over, and step-out-of while watching all accessible program variables and monitoring pin levels (and even pin waveforms, which can also be saved). Simple and clear parse and execution error messages are provided.
UnoArduSim simulator has a very interactive and easy-to-understand interface. Interface of UnoArduSim is broadly divided into 3 parts. The code pane, Variable Pane and the Lab Bench Pane. There is a menu bar containing all the menu options and a toolbar containing icon for quick actions.
Code pane part contains the code or the program or Arduino sketch. It can be used to track the execution when the code or sketch is running, here you can get any error or warning in the code with red color highlight. You can modify the code by double clicking. It has a useful feature that lets you conveniently select the built-in function calls (or built-in‘#define’ constants) to be included in to your code from the list provided.
It is situated under the code pane in bottom left side of the screen. It contains the current values for every user. The window also displays values of variables during execution.
Lab Bench Pane
The lab bench pane shows the selected Arduino board. It also has different peripherals which are selected using the Configure option. The microcontroller on the Lab Bench Pane behaves exactly like a real board. All the I/O devices and both the micro-controllers boards, i.e. ‘Uno’ and ‘Mega’ are very accurate. The electrical model of the components is good for analyzing the behavior of your program accurately, even the electrical pins will be flagged. For example: When you reset the board, the indicator LED blinks.
You can observe the waveform at each I/O pin. You have to click on the specific pins to see the digital waveform.
The Menu bar contains all the option to operate and control the simulation, Here you can find many options such as File, Find, Execute, Options, Configure, VarRefresh, Windows and Help.
Smaller ‘I/O’ devices and Big ‘I/O’ devices are two types of I/O devices. The smaller ‘I/O’ devices contains, push button, Switched Resistor, Piezo Speaker, Coloured LED, 4-LED Row, 7-Segment LED, Pin Jumper and Analog Slider whereas the Big ‘I/O’ devices have Servo Motor, DC Motor, etc. and it also have other peripherals such as MUX, Displays, etc.
A user can select a total of 16 smaller ‘I/O’ device and 8 Big ‘I/O’ devices.
Limitations of UnoArduSim
UnoArduSim has few limitations. The biggest limitation is that libraries such as <Servo.h>, <Wire.h>, <OneWire.h>, <SPI.h>, <EEPROM.h> can only be emulated. Their functionality is directly built into the simulator and hence the actual files are not searched.
Few Libraries are supported – The supported libraries are ‘SoftwareSerial.h’, ‘SPI.h’, ‘Wire.h’, ‘OneWire.h’, ‘Servo.h’, ‘Stepper.h’, ‘SD.h’,’TFT.h’ and ‘EEPROM.h’. And therefore, the other libraries won’t work as the will contain unsupported directives and unrecognized files.
Real-time Emulation – The execution time of Arduino program instructions are not accurate as they are not modeled accurately, therefore for every loop a ‘delay()’ instruction is required to run your program that is synchronized to the real-time pin level changes.
UnoArduSim simulator has no support for function calls being made through user-declared function-pointers.
Arduino Simulators Alternatives
The most common simulators are:
- Tinkercad Circuits
- Virtual Breadboard & Avatar Hardware
- IO Simulator
How to use the UnoArduSim?
First download the software from the website and unzip the file. Find the UnoArduSim.exe file and run the simulator by double click.
Now select your micro-controller board with help of Configure in the menu bar and open preferences, TWI Bytes and it has features like auto indent, auto insert closing, etc. Choose the board and click on load.
Now, for selecting the Input and output peripherals, again click on the Configure in the menu bar and open ‘I/O Devices’. You can get a pop up window here you can choose all the required peripherals from the given menu.
Write a Program for Device
Normally we write arduino code on Arduino IDE with .ino format. So if you have Arduino code in a ‘.ino’ or ‘.pde’ format, you could directly upload it by clicking on the File>Load INO or PDE.
To write the code, double-click on the Code Pane to open the editor. OR go to File >Edit/View OR Ctrl + E.
After writing your program, click on the compile button.
After your compilation is complete, select the required I/O and according to the pins assigned in your program, Assign the pins on the I/O peripherals by typing on the space provided in evert peripheral block.
Now, click on the Execute > Run option for executing the program.
Now, to see how your setup and code will perform by changing the input, change the values of the input peripheral by clicking on the buttons or change the values on the peripheral symbols to see how your system should perform.
The UnoArduSim is an easy-to-use simulator. You can load and edit (and correct) your Arduino program, then run, run-to, halt, step-into, step-over, and step-out-of while watching all accessible program variables and monitoring pin levels (and even pin waveforms, which can also be saved). Simple and clear parse and execution error messages are provided. I hope you found this article helpful.