Setup and Simulation of Arduino UNO Simulation Development Environment
1. Proteus simulation platform overview Proteus software is an EDA tool software published by Labcenter electronics Co., Ltd. (the general agent of this software in China is Guangzhou fengbiao Electronic Technology Co., Ltd ). It not only has simulation functions of other EDA tool software, but also can simulate single-chip microcomputer and peripheral devices. It is currently the best tool to simulate single-chip microcomputer and peripheral devices. It has been favored by electronics, especially single-chip computer enthusiasts, teachers engaged in single-chip computer teaching, and Scientific and Technological Workers dedicated to single-chip computer development and application. Previously, software such as EWB could only simulate digital circuits and analog circuits, rather than CPUs and programs. Currently, Proteus has several versions on the Internet, including 7.8 SP2, 7.10 SP0, and 8.0. These versions are relatively stable. The component model formats of these versions are compatible, and The DSN Simulation Principles file is the same. Version 8.0 only integrates the DSN schematic diagram, software editing environment, and compiler into an engineering file to become something like a "dumb camera", but it is more convenient for beginners of Proteus, because the program editor has been integrated internally and different compilers can be downloaded. 7. In version xx, the DSN simulation principle, editor and compiler are independent. Version 8.0 is integrated. 8.0 is not easy to set during multi-CPU simulation. After integration, the software is a little large and not as concise as version 7.xx. 2. Develop a three-step editor and select your favorite editor (such as Notepad ++, Utraedit, Source Insight, vim, slickedit, and notepad). Use this to write the Source program. C/C ++ compiler users can select their favorite C/C ++ compilers (such as Winavr, CodeSourcery, Keil, IAR, WinARM, and Watcom) based on the CPU model ), generally, compilers can generate standard. hex, and. executable target file in elf format. Arduino IDE actually uses gcc in Winavr. Use this to compile the source code written in step 1 into the. hex and. elf files. The Component Simulation library is under the Model in the hardware simulation figure Proteus. You can use these simulation components to design your own hardware simulation schematic, also known as the. dsn File. In the Proteus environment, load the. hex or. elf file generated in step 2 in the CPU using the self-designed. dsn File to simulate the operation .. The elf file contains debugging information. You can set a breakpoint debugging program in one step. Iii. Arduino UNO hardware simulation schematic diagram the simulation circuit diagram (Arduino UNO. dsn File under the HW directory) can simulate Arduino Diecimila or Arduino UNO board. The former uses the ftbench chip as the serial communication module, and later all uses the ATMEGA16U2 microprocessor instead of the ftbench. They all implement an asynchronous serial communication function on the USB. In the simulation, we used the physical interface model COMPIM In the Proteus serial port. COMPIM can completely replace the function of serial communication. It realizes the connection with the actual PC physical serial interface RS232, connect the Simulated Virtual World to the real world. In the lower-left corner of the figure, two virtual serial communication terminals (VT1 and VT2) are added to debug the use of serial communication to receive or send data. Other simulation circuits, which are Arduino Diecimila or UNO, are detailed with the pin name, the same as the implementation circuit board. With the Proteus simulation tool, you can double-click the Arduino UNO. dsn to open the Arduino simulation circuit diagram. Iv. Download and set up Arduino development software 1. download and install the Arduino integrated development environment (Arduino IDE) to the official website to download and install the Arduino IDE. The latest stable version is 1.0.6. Http://arduino.cchttp: // arduino. cc/en/Main/Software 2. select the Arduino board type and Serial Port 2. During simulation, select the first two boards. When connecting to the actual Arduino board, select the corresponding board and select the corresponding serial port. * ** Because this article uses the Arduino Simulation Development method, in the simulation circuit diagram, as long as you select the target execution file. hex or. elf file, it is equivalent to loading the program, so you do not need to load the program through a serial port.
3. Set Arduino IDE's personal Preferences (important) Select File> Preferences to find the preferences.txt folder [1]. Find the preferences.txt File in the File> preferencesof the arduino tool and open it in notepad. Add a line to the last part of the preferences.txt file and add build. path = d: \ MyHexDir to the editor. Set the directory name. For ease of observation, (I set build. path = d: ### ArduinoDbgDir ). [3] disable Arduino IDE first; save preferences.txt after saving the 4th token; do not change the above sequence. In this way, you can see the target file under d: \ MyHexDir during Arduino compilation, instead of automatically deleting it. 4. Compile (1) double-click the source file Blink. ino in the SW \ Blink directory to automatically open the Arduino IDE. (2) Click Sketch-> Verify/Compile to Compile and generate the target file. The target file is under d: \ MyHexDir (my directory is under d: ### ArduinoDbgDir ). (3) Click CP. bat to copy the. hex and. elf files to the directory where the current. ino file is located. You can edit the CP. bat file and change the directory. (4) You can set the location of the. hex or. elf file once in Proteus. when updating the. hex or. elf file in the future, it is automatically deemed that the latest file has been loaded. 5. The first Hello World Program to simulate and run the Hello World Program is to display "Hello, World!" on the computer screen !" In embedded system development, the flashing program of the LED is the Hello World Program, and the Hello World Program is very simple, generally, it is the first program to be run by programmers in the new development environment, but it is not simple. Although the Hello World Program is simple, it requires a lot of tedious work to select and configure the development tool chain for the simple program to run. Whether the Hello World program can run can verify that your compiling, development, and running environments are correct. The first program Blink. ino: // 0. pin definition # define LED_PIN 13 // define the LED pin as data PIN 13 (DIG13) // 1. initialize void setup () {pinMode (LED_PIN, OUTPUT); // initialize DIG13 as OUTPUT} // 2. loop void loop () {digitalWrite (LED_PIN, HIGH); // DIG13 output HIGH-level delay (1000); // 1 second delay digitalWrite (LED_PIN, LOW ); // DIG13 output low-level delay (1000); // delay 1 second} (1) Open Blink with Arduino IDE. ino, compiled; (2) generated in the Directory d: \ MyHexDir. hex and. (3) Click. CP. bat. Two files are added to this directory. hex and. elf; (4) use Proteu S open HW \ Arduino UNO. dsn, double-click the ATM ga 328P microprocessor, and select SW \ Blink in the Program file item. hex file, or Blink. elf file. If you load Blink. for the elf file, you can perform one step or set the breakpoint debugging. (5) Click Run simulation in the lower left corner of Proteus. If the LED light in Figure 1 flashes, the simulation running environment is correctly set.