Setup and Simulation of Arduino UNO Simulation Development Environment

Source: Internet
Author: User
Tags dsn

Setup and Simulation of Arduino UNO Simulation Development Environment

1. Introduction to the Proteus simulation platform

Proteus software is an EDA tool software published by Labcenter electronics. (Guangzhou fengbiao electronics Technology Co., Ltd. is the general agent of this software in China ). 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. Three-step development

Editor

Choose your favorite editor (such as Notepad ++, Utraedit, Source Insight, vim, slickedit, and notepad), and use this to write the Source program.

C/C ++ Compiler

You can select your favorite C/C ++ compilers (such as Winavr, CodeSourcery, Keil, IAR, WinARM, and Watcom) based on the CPU model. Generally, compilers can generate standard compilers. 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.

Hardware simulation diagram

The Component Simulation library is available under the Model in 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

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

Figure 1 hardware simulation schematic of Arduino UNO

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.

4. Download and set Arduino development software

1. download and install the Arduino integrated development environment (Arduino IDE)

Download and install Arduino IDE from the official website. The latest stable version is 1.0.6.

Http://arduino.cc

Http://arduino.cc/en/Main/Software

2. Select the Arduino board type and serial port

2. During simulation, you can select either of 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.

Figure 2-select a model

Figure 3-select a serial port

3. Set Arduino IDE's personal preferences (important)

Choose File> Preferences.

Figure 4-select preferences

Find the preferences.txt file.

Figure 5-select preferences.txt

Preferences.txt

[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] first disable the Arduino IDE;

Preferences.txt;

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. Simulation of the first Hello World Program

The Hello World Program displays "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 is as follows:
/// 0. Pin Definition
# Define LED_PIN 13 // define the LED pin as the data PIN 13 (DIG13)

/// 1. Initialization
Void setup (){
PinMode (LED_PIN, OUTPUT); // initialize DIG13 to OUTPUT
}

/// 2. Loop
Void loop (){
DigitalWrite (LED_PIN, HIGH); // DIG13 outputs a HIGH level
Delay (1000); // delay 1 second
DigitalWrite (LED_PIN, LOW); // DIG13 output LOW level
Delay (1000); // delay 1 second
}

(1) use Arduino IDE To Open Blink. ino and compile it;
(2) The. hex and. elf files are generated under the d: \ MyHexDir directory;
(3) Click CP. bat in the directory where. ino is located. Two files are added to the directory. hex and. elf;
(4) use Proteus to 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 breakpoint debugging;
(5) Click Run simulation in the lower left corner of Proteus. If the LED light in Figure 1 flashes, your simulation running environment is set correctly.

Intel places the small "Curie" on an Arduino Motherboard

Arduino and Raspberry Pi: Which one is more suitable for your DIY platform?

Arduino VS Raspberry Pi: which one is your dish?

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.