UnoArduSim : A Simulator to Learn Arduino Programming and Debugging Codes without Arduino Board

Arduino

BySharad Bhowmick 0

UnoArduSim : A Simulator to Learn Arduino Programming and Debugging Codes without Arduino Hardware

Arduino Uno is one of the most used micro-controllers backed by a very large developer community. The cost and ease of use makes Arduino boards an attractive option for making simple DIY electronics projects. A simulator is used to speed up the process of writing and debugging codes as you do not need any hardware and don’t have to make any physical connections to test your programs. Furthermore, a simulator simplifies the process of debugging, especially if both software bugs and hardware issues are suspected. In this tutorial, we will be learning about UnoArduSim, a simulator which has Arduino Uno and Mega board and have an option to select a up to of 24 I/O devices.

What is UnoArduSim?

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.

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. It supports all native Arduino language elements except the ‘goto’ instruction. Furthermore, some C/C++ language elements it does not support includes Bit-saving, union, and the oddball “comma operator is also unsupported.

Interface

This simulator has a very interactive and easy-to-understand interface. The interface of the Simulator is broadly divided into three parts. The code pane, Variable Pane and the Lab Bench Pane. Apart from the 3 panes, there is a menu bar containing all the menu options and a toolbar containing icon for quick actions. The image below shows the interface of UnoArduSim.

UnoArduSim Interface

Code Pane

From the name itself, we can understand that the code pane contains the code or the program. Code pane can be used to track the execution when the program is running, it also highlights any error in the code with red color highlight.

Double clicking the code pane opens the Edit/View, where you can modify the code. 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 also gives an option to auto add semicolon or highlight the functions. 

UnoArduSim Codepane

Variable Pane 

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.

UnoArduSim Variable Pane

Lab Bench Pane

The lab bench pane shows the selected Arduino board, i.e. either an Uno or Mega. 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 microcontrollers, 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. The Lab Bench Pane is shown in the image below:

UnoArduSim Lab Bench Pane

The board also features an option to observe the waveform at each I/O pin. It can be done when you are executing the program, you have to click on the specific pins to see the digital waveform. You can select up to 4 waveforms to be displayed on the screen.

UnoArduSim Waveform

Menu Bar 

The Menu bar contains all the option to operate and control the simulation, it gives us options such as File, Find, Execute, Options, Configure, VarRefresh, Windows and Help. Brief introduction about all the functions is given below:

File:

Load INO / PDE Prog - Allows the user to choose a program file having the selected extension. The program is immediately given a Parse.

Edit/View (ctrl-E ) - It opens the editor window.

Save - Save the edited code to the existing file.

Save As - Save the edited code in to a new file.

Next ( '#include ') - Used for displaying the next '#include' file in the Code Pane

Previous - Used for displaying the previous file in the Code Pane

Exit - Used for exiting the simulator.

Execute:

Step-Into (F4) - Used to proceed instruction by a single instruction

Step-Over (F5) - Used to proceed instruction by a single instruction over one complete function call.

Step-Out-Of (F6) - Advances execution by just enough to leave the current function.

Run-To (F7) - Runs the program only till the desired line.

Run (F9) - It executes and runs the code.

Halt (F10) - It stops the execution of the code.

Reset - It is used to reset the program to the start state.

Slow Motion - It is used to slow time by a factor of 10.

I/O devices 

I/O Devices are divided into two categories, smaller ‘I/O’ devices and Big ‘I/O’ devices. The segregation is based on the size of the device in real world, 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. All the input and output peripherals are shown in the image below: 

UnoArduSim Input Output Devices

A user can select a total of 16 smaller ‘I/O’ device and 8 Big ‘I/O’ devices.

UnoArduSim Limitations !!

The simulator comes with 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.  

Apart from the above-mentioned limitation, the simulator has no support for function calls being made through user-declared function-pointers.

Arduino Simulators Alternatives

There are a lot of alternate Arduino simulators available in the market, some of the most common simulators are:

  • Tinkercad Circuits
  • Virtual Breadboard & Avatar Hardware
  • PICSimLab
  • Wokwi
  • IO Simulator
  • Proteus
  • Fritzing

How to use the UnoArduSim?

First download the software from the website and unzip the file.

UnoArduSim Download

In the folder, find the UnoArduSim.exe file and double click to run the simulator.

The first step is to select your microcontroller. To do that, click on the Configure in the menu bar and open preference from the drop-down menu which appears. A new pop-up window will appear, here you can select the Board, TWI Bytes and it has features like auto indent, auto insert closing, etc. Choose the board and click on load.

UnoArduSim Preferences

Now, for selecting the Input and output peripherals, again click on the Configure in the menu bar and open ‘I/O Devices’ from the drop-down menu which appears. A new pop-up window will appear, here you can choose all the required peripherals from the given menu.

UnoArduSim IO Devices

Programming

If you already have an 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. Alternatively, you can click on the File and click on Edit/View. You can also press Ctrl + E simultaneously to open the Editor.

After writing your program, click on the compile button.

UnoArduSim Program

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.

UnoArduSim Evert Peripheral Block

Now, click on the Execute in the menu bar and select the Run option, it will start executing the program.

UnoArduSim Program Execution

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.6

UnoArduSim Simulator

Conclusion

The UnoArduSim is an easy-to-use simulator. The simulator has lot of features which you will easily be able to use by playing a bit with the software. It makes debugging easier by highlighting the error. So, even if you are new into the world of microcontrollers and trying to learn Arduino programming or someone who wants to debug your code or know how your code will perform without investing time and resources in assembling the components in a fast and efficient manner then this software is extremely useful for you. I hope you found this article helpful. If you have any question or doubt related to this software, then post your queries in the comment section below.

Get Our Weekly Newsletter!

Subscribe below to receive most popular news, articles and DIY projects from Circuit Digest

Comments

Log in or register to post Comment