Introduction to the use of UnoArduSim
Source: InternetPublisher:奥特man123 Keywords: Simulator Arduino Updated: 2024/12/17
Arduino Uno is one of the most commonly used microcontrollers supported by a very large developer community. Cost and ease of use make Arduino boards an attractive choice for making simple DIY electronics projects. Simulators are used to speed up the process of writing and debugging code because you don't need any hardware and don't have to make any physical connections to test your program. In addition, simulators simplify the debugging process, especially when software bugs and hardware problems are suspected. In this tutorial, we will learn about UnoArduSim, a simulator with Arduino Uno and Mega boards and the ability to select up to 24 I/O devices.
What is UnoArduSim?
UnoArduSim was developed by Professor Simmons at Queen's University in Ontario, Canada. He uses the platform to teach second-year students in the Department of Electrical and Computer Engineering. The graphical simulator was developed to allow students to test their robotics code without any additional hardware.
UnoArduSim is an Arduino simulator that allows you to do real-time code debugging on Arduino Uno and Arduino Mega boards. The simulator is used to compile and test code. It supports all native Arduino language elements except the "goto" instruction. In addition, some C/C++ language elements that it does not support include Bit-saving, union and the weird "comma operator".
interface
This simulator has a very interactive and easy to understand interface. The interface of the Simulator is roughly divided into three parts. The Code Pane, the Variables Pane and the Lab Bench Pane. In addition to the 3 panes, there is a menu bar that contains all the menu options and a toolbar that contains icons for quick operations. The following figure shows the interface of UnoArduSim.
Code Pane
From the name itself, we can understand that the code pane contains the code or the program. The code pane can be used to track the execution of the program while it is running, and it also highlights any errors in the code in red.
Double-clicking the code pane opens an edit/view where you can modify the code. It has a useful feature that lets you conveniently select built-in function calls (or built-in "#define" constants) to include in your code from a provided list. It also provides options for automatically adding semicolons or highlighting functions.
Variables Pane
It is located below the code pane in the lower left corner of the screen. It contains the current value for each user. The window also displays the variable values during execution.
Lab Bench Pane
The Lab Bench Pane displays the selected Arduino board, either Uno or Mega. It also has different peripherals that are selected using the configuration options. The microcontroller on the Lab Bench Pane behaves exactly like the real board. All the I/O devices and microcontrollers, namely "Uno" and "Mega", are very accurate. The electrical models of the components help in analyzing the behavior of the program accurately and even the electrical pins are labeled. For example: When you reset the board, the indicator LED flashes. The Lab Bench Pane looks like the following image:
The board also has the option to observe the waveform of each I/O pin. This can be done while executing the program and you have to click on the specific pin to see the digital waveform. You can select up to 4 waveforms to be displayed on the screen.
Menu Bar
The menu bar contains all the options to operate and control the simulation, it provides us with options such as File, Find, Execute, Options, Configure, VarRefresh, Windows and Help. Here is a brief introduction to all the functions:
document:
Load INO/PDE Prog - Allows the user to select a program file with a selected extension. The program immediately gets a Parse.
Edit/View (ctrl-E) − It opens the editor window.
Save - Saves the edited code to an existing file.
Save As - Saves the edited code to a new file.
Next ('#include') - Used to display the next '#include' file in the code pane
Previous - Used to display the previous file in the code pane
Exit − It is used to exit the simulator.
implement:
Step-Into (F4) - Used to continue a single instruction
Step-Over (F5) - Used to continue execution of instructions by a single instruction on a complete function call.
Step-Out-Of (F6) - Advance execution far enough to leave the current function.
Run-To (F7) − Runs the program only up to the desired line.
Run (F9) − It executes and runs the code.
Halt (F10) − It stops the execution of the code.
Reset - Used to reset the program to its starting state.
Slow Motion - Use to slow down time 10 times.
Input and Output Devices
I/O devices are divided into two categories, smaller "I/O" devices and large "I/O" devices. The segregation is based on the size of the devices in the real world, smaller "I/O" devices contain buttons, switch resistors, piezo speakers, color LEDs, 4-LED rows, 7-segment LEDs, pin jumpers, and analog sliders, while large "I/O" devices have servo motors, DC motors, etc. It also has other peripherals like MUX, displays, etc. All input and output peripherals are shown in the following figure:
The user can select a total of 16 smaller "I/O" devices and 8 larger "I/O" devices.
UnoArduSim Limitations!!
The simulator has almost no limitations. The biggest limitation is that libraries like Servo.h, Wire.h, OneWire.h, SPI.h, EEPROM.h, etc. can only be simulated. Their functionality is built directly into the simulator, so the actual files are not searched.
Few supported libraries
The supported libraries are 'SoftwareSerial.h', 'SPI.h', 'Wire.h', 'OneWire.h', 'Servo.h', 'Stepper.h', 'SD.h', 'TFT.h', and 'EEPROM.h'. Therefore, other libraries will not work as they will contain unsupported instructions and unrecognized files.
Real-time simulation
The execution times of Arduino program instructions are not accurate as they are not accurately modeled, so for each loop a "delay()" instruction is needed to run the program in sync with real-time pin level changes.
In addition to the above limitations, the simulator does not support function calls through user-declared function pointers.
Arduino simulator alternatives
There are many Arduino simulators available on the market. Some of the most common ones are:
Tinkercad Circuits
Virtual Breadboard and Avatar Hardware
PICSimLab
Woquai
IO Simulator
amoeba
Fritz
How to use UnoArduSim?
First download the software from the website and unzip the file.
In the folder, find the UnoArduSim.exe file and double-click it to run the simulator.
The first step is to select your microcontroller. To do this, click on Configure in the menu bar and open Preferences from the drop-down menu that appears. A new pop-up window will appear, and here you can select Board, TWI Bytes, it has features like auto-indent, auto-insert off, etc. Select the board and click Load.
Now, in order to select the input and output peripherals, click again on Configuration in the menu bar and open "I/O Devices" from the drop-down menu that appears. A new pop-up window will appear where you can select all the desired peripherals from the given menu.
programming
If you already have an Arduino code in '.ino' or '.pde' format, you can upload it directly by clicking File > Load INO or PDE.
To write code, double-click the code pane to open the editor. Alternatively, you can click File and then click Edit/View. You can also press Ctrl+E simultaneously to open the editor.
After writing the program, click the Compile button.
After compilation is complete, select the required I/O and assign pins on the I/O peripheral by typing on the space provided in the peripheral block according to the pins assigned in the program.
Now, click on Execute from the menu bar and select Run option, it will start executing the program.
Now, to see how your setup and code will perform by changing the inputs, change the values of the input peripherals by clicking the buttons or change the values on the peripheral symbols to see how your system should perform.
in conclusion
UnoArduSim is an easy to use simulator. This simulator has many features that you can easily use by using this software. It makes debugging easier by highlighting errors. So even if you are new to the world of microcontrollers and trying to learn Arduino programming or want to debug your code or know how your code will execute without investing time and resources in assembling components in a quick and efficient way, then this software can be very useful for you.
- Schematic diagram of MCU SPI interface circuit
- Simple USB interface data acquisition system
- Digital frequency meter made with ATmega8 microcontroller
- How to make a smart mirror using Raspberry Pi
- Make a capacitive soil moisture sensor using ESP32
- Experiment on using 51 microcontroller to drive relay
- SST89C58 electronic disk circuit and code
- Circuit principle and production of dot matrix Chinese character LED display
- Minimum system circuit of XC4003
- 815e motherboard
- Cricket sound simulator circuit
- Cicada chirping simulator circuit
- Dog barking simulator circuit 2
- One of the dog barking simulator circuits
- Cat meow simulator circuit one
- Fan natural wind simulator circuit 2
- Cat meow simulator circuit
- Fun lantern simulator circuit
- Simple natural wind simulator circuit for electric fan
- Simple natural wind simulator circuit.gif