Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

“Innovation for the Masses, Entrepreneurship for Everyone”. Schools are increasingly emphasizing maker education, with enthusiasm rising as they begin to offer maker education courses and build maker laboratories when conditions allow, investing generously. However, many schools are financially constrained and struggle to find a starting point. Indeed, many friends say that hardware has become cheaper, with counterfeit versions costing less than 20 yuan, and DIY options around 10 yuan, but the reality is that applying for hardware requires a plan, and the process can be lengthy and complicated, taking months or even years. By the time the equipment arrives, it may be too late. Teachers are not without enthusiasm to purchase hardware themselves, but this is not a sustainable solution. In fact, like Teacher Fangjun from Zibo, who initially bought hardware to play with, he started with a few students, then grew from an interest group to a club, and from a club to an interest class to classroom teaching. I suddenly remembered those few kids I taught during my volunteer teaching, who installed software very well.

From my experiences in 2012 and 2013 while teaching in Haiqing Town, Huangdao District, Qingdao City, and Caoxian County, Heze, as well as my occasional visits home, many schools currently face a shortage of office funds, making it difficult to conduct maker education activities. Later, I met Yang Feng from Portable Technology, and we hit it off, discussing the design of hardware development courses. I then selected some commonly used hardware modules from frontline teaching and purchased components from Taobao, assembling about 30 Scratch portable experiment kits. The Arduino chips used were domestic versions, with the price of the Arduino Uno compatible version being 24 yuan and the Arduino Nano small board priced at 19 yuan, significantly reducing costs. At that time, I only included red, green, and blue LEDs, RGB full-color lights, buzzers, photoresistors, and DuPont wires, even using breadboards that cost 4 yuan each. However, the accompanying courses were delayed, which was frustrating, but schools could adopt this approach for their own teaching.

Of course, if DIY, the cost of an Arduino is around 10 yuan.

But some schools are severely short of funds. What can be done? I suddenly recalled my senior year in 2010 at Donghua University when our department invited our senior, Shang Hang from Shida Affiliated High School, to explain robotics to us. At that time, we used the VJC robot simulation environment, which was enlightening. Now, using VMware, VirtualBox, and Qemu to simulate operating systems, simulating Arduino circuit boards is naturally not a problem. Thus, I began to pay attention to circuit simulation software.

I had also been exposed to robot simulation software Microsoft Robotics Studio, which I tried out briefly; it is an excellent software that allows students to learn about robots and engage in programming activities even in cases of insufficient funding.

Microsoft Robotics Studio is an environment based on Windows for researchers, robotics enthusiasts, and commercial developers, allowing simple implementation of robotic applications with various types of hardware. The features and benefits of the Microsoft Robotics Studio development environment include: integrated robotics development platform, lightweight real-time orientation services, and scalability. Source: Microsoft Robotics Studio Introduction Series

Microsoft Robotics Studio targets a wide audience, accelerating the development and popularization of robotics. The real-time simulator is an important part of this. It can be displayed immediately from computers and gaming consoles when it is affordable, widely applicable, and utilizes robotics simulation technology. Games rely on photo-realistic rendering effects created using physical simulators with parameters defined by real-time systems. This is an excellent starting point for our efforts.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Software Interface

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Microsoft Robotics Studio

Yesterday, while aimlessly flipping through books in the library, I came across a book , which introduces

Electronic Design Automation (EDA), developed from Computer-Aided Design (CAD), Computer-Aided Manufacturing (CAM), Computer-Aided Testing (CAT), and Computer-Aided Engineering (CAE).

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Arduino Software and Hardware Collaborative Design Practical Guide

It introduces four software: Fritzing, Virtual BreadBoard, Proteus, and EAGLE. It was enlightening.

I originally planned to buy this book on JD for 50.2 yuan, but found it available on the JD reading app, then discovered that the annual subscription for JD reading was 98 yuan, so I purchased the subscription to read this book for free.

By utilizing the above four software, one can simulate circuits and learn Arduino hardware programming without incurring costs.

Software Introduction

Fritzing

Fritzing is an electronic design automation software that supports designers, artists, researchers, and enthusiasts in participating from physical prototypes to further real products. It also allows users to document their Arduino and other electronic-based prototypes, share with others, teach electronics in classrooms, and create layouts for printed circuit boards.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Fritzing

Fritzing is a multi-language-supported circuit design software that can simultaneously provide three types of views: breadboard/schematic/PCB layout. Regardless of which view the designer uses to design the circuit, the software will automatically synchronize the other two views. It can also generate the necessary gerber files for production, PDF images, and CAD format files, greatly promoting and popularizing the use of Fritzing. — Source:

I personally think one of the benefits of using Fritzing is that when students design circuits, they first simulate using the software, plan before acting, avoiding burning out electronic components or wasting time on futile exploration.

Arduino Sample Support and Programming

Fritzing contains all the circuit diagrams of the built-in examples of Arduino, facilitating learning. In practical teaching…

Virtual BreadBoard (VBB)

The Arduino simulation tool Virtual BreadBoard is currently a paid software, but surely everyone has a way to use it for free.

Proteus Circuit Simulation Software

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Selected View

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Simulated AC power source and light bulb, with the brightness of the bulb varying with the size of the AC voltage.

Solutions

In the (this book should pay me advertising fees), detailed methods for simulating Arduino hardware and various hardware through circuit simulation software and writing programs are provided for reference. (Okay, I admit I’m lazy, too lazy to write so much)

The above simulation software can be used in conjunction with Arduino software, and the simulation software will automatically load the hex file generated by the Arduino software to execute the program and simulate.

Teachers can set up the environment in the computer room and transmit it to students’ machines over the network, allowing students to simulate on their computers. It is also best if the teacher has a set of actual hardware, as simulated experiences cannot match the intuitiveness of real hardware.

Moreover, I suddenly thought about whether there are plugins similar to circuit simulation for 3D modeling software like 3dmax. If so, it would be possible to combine model design and circuit design directly. Of course, there should be such software in industrial streets, but unfortunately, none are simple and easy to use.

Simulation is not the goal, just a means; teaching students to combine hardware and software hands-on is more important and meaningful. It merely provides all students with the opportunity to engage with hardware and software when funds are limited. — Zhou Yulin, Nanjing University of Chinese Medicine

I suddenly had a question. When it comes to open-source hardware, it must be Arduino. Arduino is certainly easy to learn, with abundant resources for promotion, but STC and others are also good, just not necessarily suitable for compulsory education schools. However, learning is definitely not a problem at the high school level. Back in 2013, Teacher Jin Shuhui from Shida Affiliated High School led students to play with microcontrollers. So you see, the key is still to have appropriate guidance and to adopt suitable methods for teaching knowledge to students.

Another divine suggestion is to search for Proteus and Arduino to find related content, interested parties can look it up.

Overall, the Arduino simulation hardware part is based on the Proteus schematic, while the program driving part relies on the Hex file generated by compiling the Arduino program in the Arduino IDE.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Arduino drives LED lights

Atmega328P is the chip used for Arduino UNO, which replaces Arduino Uno pin 19 with Arduino pin 13, connected to ground through a 10k resistor. Simulation results

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

LED light on, red square

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

LED light off, blue square

For specific tutorials, refer to two articles: Arduino Learning Notes Based on Proteus 01 – Arduino UNO Experiment Board Design

The following content is reprinted from EEboard: http://www.eeboard.com/bbs/forum.php?mod=viewthread&tid=3429 II. Proteus Simulation Methods for Arduino Microcontroller The basic process of Arduino microcontroller simulation in Proteus is: writing the program in Arduino IDE, establishing the hardware in the Proteus ISIS software module by drawing the electrical schematic. After completing the program, select the Tools menu item in the Arduino IDE programming interface, then choose Board → Arduino Duemilanove w/ATmega328, or Board → Arduino Uno, and click the compile button to generate the Hex file (binary machine code file). With the Hex file ready, go to the Proteus schematic, double-click the ATMEGA328P microcontroller chip in the schematic, and a dialog box will appear. Use the file directory browsing method to determine the location of the Hex file and set some working state parameters for the microcontroller chip. Finally, click the play button at the bottom left of the Proteus ISIS software interface to see the running effect of the Arduino microcontroller in the Proteus simulation environment.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 4 Arduino Program Compilation Figure 4 shows the simplest Arduino microcontroller project example, where the task is to make the LED connected to digital port 13 of the Arduino microcontroller blink. To successfully simulate this project, two points must be particularly noted: one is the generation and location determination of the Hex file for the Arduino program, and the other is the loading of the Hex file into the ATMEGA328P chip in the Proteus schematic and setting the working parameters.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 5 Arduino Project Example LED Blinking Schematic After compiling the Arduino program, the Hex file will be automatically deleted. However, in the Proteus simulation of the Arduino microcontroller, the Hex file generated by the Arduino software needs to be used. Since Arduino 1.0 automatically deletes the Hex file after use, it is necessary to modify the following: First, create a folder on the D drive specifically for Hex files, naming it as desired, I named it Arduino_Hex. Then, click on the Arduino software interface menu bar, select File -> Preferences, open the dialog box, as shown in the figure, check the two parameters under Show verbose output during, double-click the preferences.txt file to find the file location, then double-click to open it with Notepad. Click the OK button at the bottom of the preferences dialog, then close the Arduino IDE programming interface. Finally, add the line build.path=d:\Arduino_Hex at the end of the opened preferences document and save it. This way, every time you compile an Arduino program, you can see the compiled Hex target file in d:\Arduino_Hex.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 6 Arduino Preference Parameter Settings After discussing the generation and location determination of the Hex file for the Arduino program, let’s talk about another important issue: loading the Hex file into the ATMEGA328P chip in the Proteus schematic and setting the working parameters. Double-click the ATMEGA328P microcontroller in the Proteus ISIS schematic, a dialog box will appear. Click the folder button for the Program File parameter to determine the location of the Hex file, and find the current program’s Hex file in the d:\Arduino_Hex folder. The previous program’s Hex file will be overwritten by the newly compiled Hex file, so every time you simulate a project, you must compile the Arduino program.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 7 Loading the ATMEGA328P Microcontroller’s Hex File in Proteus and Parameter Settings After confirming the Hex file, there are three parameters to revise: first, change the “CLKDIV8 (Divide clock by 8)” parameter to “Unprogrammed”; second, change the “CKSEL Fuses” parameter to “(1111) Ext. Crystal 8.0-MHz”; third, set the Clock Frequency parameter in Advanced Properties to 16Mhz. Finally, click the OK button in the editing dialog box, and then simulation can proceed. There is a video on the internet about Arduino microcontroller Proteus simulation, explaining how to establish the Proteus schematic and how to write the Arduino program, as well as how the program is compiled and simulated. However, in this video, the Hex file generated after compiling the Arduino program was not found in the specified directory, but was still found in the default directory.

III. Arduino Microcontroller Proteus Simulation Project Example The task of this simulation project is to press the K1 (forward) button, K2 (reverse) button, and K3 (stop) button, causing the DC motor to perform corresponding actions, and the motor speed will also change when adjusting the potentiometer. (All images can be enlarged by double-clicking!)

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 8 Simulation Diagram of DC Motor Forward, Reverse, Start, and Speed Regulation The electrical symbols in the simulation diagram use chip components, power terminals, virtual instruments, and connection labels, which are extracted from their respective model libraries.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 9 Extraction of Electrical Symbols in the Simulation Diagram The electrical symbols in the simulation diagram use power terminals with VCC power and ground symbols, virtual instruments with four-channel oscilloscopes and DC voltmeters, and connection labels indicate that two wires with the same label are electrically connected, such as labels A, B, and PWM in Figure 8. As for chip components, the simulation diagram uses resistors, capacitors, CPUs, oscillators, DC motors, voltage regulators, L298N drivers, etc. There are typically two methods for extracting chip components: parent-child category retrieval and keyword query method. The parent-child category retrieval method involves selecting the component model library, then clicking the “P” button to open the component query extraction dialog. For example, to extract the microcontroller chip ATMEGA328P, find Microprocessor ICs in the category, AVR Family in the sub-category, and Atmel in the manufacturer, then find the ATMEGA328P chip in the narrowed search results. Once found, double-click the chip to extract it to the DEVICES column on the left of the ISIS interface for use during schematic drawing.

Figure 10 Parent-Child Category Retrieval Method for Chip Components The keyword query method allows users to input the name of the component they wish to extract in the keyword input bar of the component query extraction dialog. For example, to search for motor components, simply input “motor” and press Enter to easily find the required component in the results.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 11 Keyword Query Method for Chip Components According to the electrical schematic of the DC motor control shown in Figure 8, once the hardware circuit is completed, the remaining task is to write the program and compile it for simulation. This simulation project I designed involves both digital and analog input/output. The button inputs and the motor direction control pins A and B of the L298N driver are digital input/output, while the potentiometer input and the speed control pin PWM of the L298N are analog input/output. The Arduino commands for digital input/output are digitalRead(digital port number) and digitalWrite(digital port number, LOW or HIGH); the Arduino commands for analog input/output are analogRead(analog port number) and analogWrite(digital port number, 0~255). The analog port only has an input mode, while the analog output of Arduino is output in the form of PWM signals from digital ports that have PWM output functionality. The correspondence between the digital and analog ports of the Arduino microcontroller and the pins of the ATMEGA 328 chip is shown below. The pins labeled 0~13 correspond to the digital ports, and the pins with the symbol “~” before 0~13 correspond to ports that have PWM output functionality. The pins labeled A0~A5 are the analog ports.

Circuit Simulation: Mastering Arduino Open Source Hardware with Zero Investment

Figure 12 Correspondence Between Arduino UNO Ports and Atmega328P Pins With the correspondence between Arduino UNO ports and Atmega328P pins established, it becomes easier to use the Proteus hardware simulation diagram to write Arduino programs with a targeted approach. Since the following program contains detailed comments, I will not elaborate on the function of each line of Arduino program.

Arduino Program: // Task: Control the motor start/stop and forward/reverse with buttons, adjust motor speed with potentiometer. int K1=5; // Connect K1 (forward) button to digital port 5 int K2=6; // Connect K2 (reverse) button to digital port 6 int K3=7; // Connect K3 (stop) button to digital port 7 int potpin = 3; // Connect potentiometer to analog port 3 int A=2; // Control motor start/stop and direction with digital ports 2, 3 int B=3; int PWMpin = 9; // Output PWM signal from digital port 9 to control motor speed // Initialization void setup(){ pinMode(K1,INPUT); // Set digital ports 5, 6, 7 to input mode pinMode(K2,INPUT); pinMode(K2,INPUT); pinMode(A,OUTPUT); // Set digital ports 2, 3 to input mode pinMode(B,OUTPUT); } // Main program void loop(){ // If K1 (forward) button is pressed if(digitalRead(K1)==LOW){ // Motor moves forward digitalWrite(A,HIGH); digitalWrite(B,LOW); } // If K2 (reverse) button is pressed if(digitalRead(K2)==LOW){ // Motor moves in reverse digitalWrite(A,LOW); digitalWrite(B,HIGH); } // If K3 (stop) button is pressed if(digitalRead(K3)==LOW){ // Motor stops digitalWrite(A,LOW); digitalWrite(B,LOW); } int sensorValue = analogRead(potpin); // Read potentiometer sampling value sensorValue = sensorValue/4; // Convert sampling value 0-1024 to 0-255 analogWrite(PWMpin, sensorValue); // Output processed value as PWM signal delay(20); }

After completing the program, compile the Hex file, load the Hex file into the Proteus simulation diagram in the Arduino microcontroller chip, and finally click the play button at the bottom left of the simulation diagram to see the running effect of the Arduino DC motor control project.

IV. Conclusion I often receive inquiries from netizens interested in maker culture about whether it is possible to minimize hardware costs while still doing interesting electronic projects with Arduino microcontrollers. Therefore, this article discusses how to achieve our creative practices through simulation methods when funds are limited. Why is it necessary to learn Arduino? In fact, many learners have spent a lot of energy chasing the progress of electronic technology, learning various microcontrollers and smart logic components like 51, ARM, DSP, and FPGA just to do some applications, not realizing how much time and money it would consume. They ended up only doing some simple experiments with LED lights and digital tubes, which ended hastily, only to pursue the next new thing. What enjoyment can there be in using microcontrollers for applications in such a chase? Fortunately, the Arduino system, which adheres to an open learning architecture, is becoming increasingly popular, allowing anyone eager to create to complete a project in a short time and access a wealth of shared resources online. You will find that with Arduino, the world of microcontrollers is no longer so foreign and daunting; microcontrollers become an easy-to-use tool that allows us to focus our energy on the parts of our work that best reflect our personal innovation spirit.

Children’s Maker Help

Leave a Comment

Your email address will not be published. Required fields are marked *