Week8. Electronics Design¶
Group assignment:¶
use the test equipment in your lab to observe the operation of a microcontroller circuit board send a PCB out to a board house
Group assignment can be viewed at this link. - week8 Group assignment
Introduction to Oscilloscope¶
An oscilloscope is a powerful and versatile electronic test instrument that allows you to observe the varying signal voltages in electrical circuits. It graphically displays these voltages as waveforms, showing how signals change over time. This makes oscilloscopes essential for viewing and analyzing the behavior of electronic devices, particularly for diagnosing malfunctions and ensuring system stability. —from GPT
This is what we have in our lab,
These voltage waveforms are displayed graphically.
What I learned this week?¶
In this week’s electronic design, I learned the following points:
1. Basic knowledge of circuit design¶
Designing a functional circuit board requires a lot of electronic knowledge support, otherwise the efficiency is very low. Just like the micro main control board, it can be roughly divided into three categories: digital serial port, GND, VCC (3.3V/5V), different The sensors can be connected to the corresponding pins according to their instructions. Without this concept, it will feel like there are a lot of digital interfaces and there is no way to start.
2. Installation and use of libraries in EDA tools¶
Learned to use the EDA tool, kicad, which can install many libraries to make circuit board design more efficient.
3. Understand the overall process of electronic design¶
Understand the entire design process of an embedded board, have a basic understanding of the structure and purpose of the PCB board, and be able to understand most of the components of the PCB board
Individual assignment:¶
use an EDA tool to design a development board to interact and communicate with an embedded microcontroller, produce it, and test it extra credit: try another design workflow extra credit: design a case for it extra credit: simulate its operation
The following are the 7 steps we have summarized that need to be completed for electronic design:
- Create Schematic
- Create Board Design
- Generate Gerber
- Convert Gerber to PNG
- Convert PNG to GCode
- CNC Mill the board
- Soldering PCB
What project do I want to do?¶
I want to use xiao as the main control, so that when the button is pressed, the OLED screen will switch to display the four phrases “Good morning”, “Good afternoon”, “Good evening”, and “Good night”.
1. Create Schematic¶
what is EDA tool?¶
Electronic Design Automation (EDA) tools are a category of software used for designing and developing electronic systems such as integrated circuits (ICs) and printed circuit boards (PCBs). These softwares assist electronic engineers throughout the entire electronic design process from conceptual design, schematic drawing, PCB layout design, to the final manufacturing stage. By using EDA tools, engineers can create complex circuit designs and conduct simulation tests to verify the functionality and performance of the design before physically manufacturing the circuit board.
EDA tools include but are not limited to tools for the following stages:
Schematic Capture: Software used for drawing circuit diagrams, which is the first step in creating an electronic design, used to define the logic structure of the circuit. Simulation: Software that simulates the behavior of the circuit before the actual circuit board is manufactured, which can be digital, analog, or mixed-signal simulation. PCB Layout and Design: Software used for designing the specific layout of a PCB, including component placement and routing. Library Management: Maintenance of component libraries, including the standard electronic component packages and parameters. Design Rule Checking (DRC): Automatic checking of the circuit design against predefined rules and standards to ensure the manufacturability and reliability of the design. Generating Manufacturing Files: Such as Gerber files, which are the standard file format required for PCB manufacturing. Popular EDA software includes Cadence, Altium Designer, Eagle, KiCAD, and others. These tools significantly increase design efficiency, reduce error rates, and are indispensable helpers in modern electronic design.
Content above come from GPT4
I chose kicad as the design tool for my circuit board. KiCad is a free software for printed circuit board design, This software gives me the impression that it is easy to operate and does not have a large learning threshold. It is friendly to beginners. The interface layout is very clear and it is easy to find the corresponding tool positions.
and then download it
Schematic Editor & PCB Editor are the two interfaces that I need to use.
Then I need to install fab’s library first, this is the website to download thelibrary: https://gitlab.fabcloud.org/pub/libraries/electronics/kicad download the zip file, unzip the file, then install in schematic edditor. If the installation is successful, it will be show up in the schematic library.
Then I start to draw schematic of my board.
Open the software, and you can first find out the modules and corresponding components I need to use from this location.
Because I need to use XIAO ESP32 C3 as the main control, I put the XIAO schematic diagram on the drawing board first Then open the wiki of seeedstudio_XIAOESP32 C3 - XIAO ESP32 C3_wiki
Later I discovered that my classmate’s XIAO was welded like this:
The advantage of this is that the board can also be used in other projects. In order to reuse materials, I decided to also choose the SMD welding method, so I also needed to choose the schematic diagram of the SMD XIAO.
I first found all the original components I need to use from the library, like this:
Then connect each corresponding pin as needed,
First solve the OLED:¶
Here I used Grove’s OLED, which has 4 interfaces, namely: GND / VCC / SDA / SCL
Among them, GND is a conventional ground, VCC is usually connected to 3.3V or 5V, SDA is connected to D4 according to the schematic diagram, and SCL is connected to D5.
I found this header in the fab library:
Then is the SMD Button¶
(switch tactile moron which I can find in fab library)
Design an input circuit to the PCB board where the SMD button is connected to a GPIO pin (here i set GPIO4) and GND. Add a pull-up resistor (a value in the range of 10KΩ to 100KΩ usually works) to the button’s input pin to ensure that the pin remains high when the button is not pressed.
Using the label tool, connect the connected Pins, and then I got this schematic
2. Create Board Design¶
Select in the top menu bar“Tool-From schematic to PCB”
Before drawing the PCB board, we need to adjust the parameters first to ensure that unnecessary losses occur during the manufacturing process. Open the menu bar “File-Circuit Board Settings”
Then we get the original PCB diagram including schematic connection tips, then use the line drawing tool to connect the corresponding pins
Then use the edge tool to draw the outline of the board
3. Generate Gerber¶
Select “File-Manufacturing Output-Gerber” in the top menu bar
First, the drilling file must be generated,
It should be noted here that my final board did not use the drilling file, but it was used in the previous PCB boards, so the previous version of the drilling example here.
4. Convert Gerber to PNG¶
At this time we need to use this online tool - gerber2png
Drag and drop the 3 master files into this online tool,
then we select different layers to generate Then generate 3PNG files
This one is the old file, I’ll show you how I set the drilling parameters
5. Convert PNG to Gcode¶
At this time we need to use this online tool - mod
First, upload the traces file¶
then change dpi to 1000, make sure the image is clear.
Then click this Make sure the data is the selected value, then click Calculate
Second, upload the outline file¶
also change dpi to 1000, make sure the image is clear. change the speed to 2mm/s,then click mill outline
Make sure the data is the selected value, then click Calculate
* upload the drills file(This is just as an example)¶
also change dpi to 1000, make sure the image is clear. change the speed to 2mm/s,then click mill outline Make sure the data is the selected value, then click Calculate
then I got the Gcode file:
and you can get the file from here:
Ttop_layer_outline_1000dpi (2).png.nc
top_layer_traces_1000dpi (2).png (2).nc
6. CNC Mill the board¶
Send the file to the machine.
Here is what we have in our lab. It is made by JingYan Instruments Technology.
Cutting PCB boards can be roughly divided into 4 steps 1. open the Gcode 2. set the zero point Then I need to set the zero point of the tool head, and use this tool to move the tool head to the corner of the processing area to ensure that it does not exceed the area of the copper plate.
Test whether the software interface buttons can control the operation of the device: click Emergency Reset Coordinates cleared Regenerate toolpath Click to start
cut the outline of the board Import the frame file, the same operation as cutting the trace file
here we are, we go the final board:
7. Soldering PCB¶
This PCB board is relatively simple, with only 4 original components.
It look like this after soldering:
This PCB board was made wrong before. The resistor was connected in the wrong position, causing the circuit to fail. At this time, compare the pictures
Testing¶
Next, I used GPT to generate a piece of code to test the PCB board.
code show as below
#include <Arduino.h>
#include <U8g2lib.h>
#define BUTTON_PIN 0 // 假设您将SMD按钮连接到GPIO0
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
const char* messages[] = {"Good morning", "Good afternoon", "Good evening", "Good night"};
int messageIndex = 0;
bool buttonState = HIGH;
bool lastButtonState = HIGH;
unsigned long lastDebounceTime = 0; // 上次切换的时间
unsigned long debounceDelay = 50; // 去抖延迟
void setup(void) {
pinMode(BUTTON_PIN, INPUT_PULLUP); // 启用内部上拉电阻
u8g2.begin(); // 初始化显示屏
}
void loop(void) {
bool reading = digitalRead(BUTTON_PIN);
// 如果检测到状态改变
if (reading != lastButtonState) {
lastDebounceTime = millis(); // 重置去抖定时器
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// 如果按钮状态更改并保持时间足够长,则视为有效更改
if (reading != buttonState) {
buttonState = reading;
// 只有当按钮从高电平变为低电平时才切换消息
if (buttonState == LOW) {
messageIndex = (messageIndex + 1) % 4; // 切换消息
}
}
}
lastButtonState = reading; // 更新上一次按钮状态
// 在OLED上显示当前消息
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(0,22,messages[messageIndex]);
u8g2.sendBuffer();
delay(100); // 略作延迟
}
As I mentioned in the week06, regarding the understanding of the code, I will not repeat the description here.
This code mainly uses the
const char* messages[] = {"Good morning", "Good afternoon", "Good evening", "Good night"};
This code defines a string array containing four different greetings that will be displayed on the OLED screen.
When a button is pressed or released, it does not simply change state all at once, but rapidly and repeatedly over a short period of time. This can cause the circuit to falsely detect multiple presses or releases.
unsigned long lastDebounceTime = 0; // 上次切换的时间
unsigned long debounceDelay = 50; // 去抖延迟
Therefore,I need to use the above code to define debounce related variables, record the time of the last button state change and the debounce delay (50 milliseconds).
In the code, the pin of the SMD button is not defined. I decided to use GPIO4 as the connection pin, so this position of the code needs to be changed to “4” Check first, then burn
The final effect is like this
and here is the hero shot