张三叔

[Shenzhen University Electronic Competition] 32-bit microcontroller core board design

 
Overview

2020 Shenzhen University Electronic Design Competition Work Report

Title: 32-bit microcontroller core board design

Summary

[Abstract] The design is mainly divided into four modules: STM32 core board, OLED display, five-wire four-stepper, TFT.

In addition to the core microcontroller, the STM32 core board includes a basic circuit with a reset button, three independent buttons, two LEDs, download interface and serial communication interface, buck circuit, crystal oscillator circuit, JTAG/SWD debugging interface; five wires and four The phase stepper is connected to the fan to control the fan speed through buttons; the OLED and TFT color screen modules have been led out through pin headers. This design has initially realized the basic functions of the 32-bit microcontroller core board and the normal use of the new modules.

[Keywords] STM32 core board; OLED; five-wire four-term stepper machine; TFT

Table of contents

1. demand analysis................................................ ................................................................. ............................. 

2. Plan selection and justification........................................ ................................................................. .....................

3. System architecture and function description........................................ ................................................................. ...........

4. Theoretical analysis and calculation........................................ ................................................................. .....................

5. Circuit Diagram and PCB................................................ ................................................................. .....................

6. Debugging and test results........................................ ................................................................. ............

Conclusion...................................................... ................................................................. ........................................

【references】.............................................. ................................................................. .....................

32-bit microcontroller core board design School of Electronics and Information Engineering: He Naijia Major: Electronic Science and Technology Student Number: 2018161050 School of Electronics and Information Engineering: Lian Tongsheng Major: Electronic Information Engineering Number: 2018132032 School of Electronics and Information Engineering: Chen Houyu Major: Microelectronics Science and Engineering Number: 2018163066 School of Electronics and Information Engineering: Su Yongbiao Major: Communications Engineering Number: 2019282108

1. demand analysis

Functional requirements:

In addition to the core microcontroller, this design includes 1 reset button, 3 independent buttons, 2 LEDs, download interface and serial communication interface, OLED display driver, and leads to some or all IO ports through pins, and can realize motor, Features such as trolley, light panel and color touch screen.

Technical performance indicators;

1.

The circuit schematic diagram and PCB layout are modular, standardized, beautiful and neat;

2.

The test ensures that the functions of each module are used normally and the IO interface is normal;

3.

Make PCB and solder components to be complete and beautiful.

Required knowledge and materials:

1.

Learn how to use Lichuang EDA platform;

2.

Learn the development principles of 32-bit microcontrollers, relevant hardware and software knowledge such as schematic drawing, programming testing, etc.;

3. PCB design, including knowledge of component layout, component routing, adding teardrops, copper pouring and proofing.

4. Main materials required: 32-bit microcontroller core board schematic diagram and corresponding PCB, STM32F103RCT6 chip (see below for details on chip selection), five-wire four-phase stepper motor ULN2003D1013TR, TFT color screen, OLED display, and PCB board. The remaining secondary materials such as resistors and capacitors will not be described in detail.

2. Plan selection and demonstration

The important issue that needs to be solved first for this question is the selection of MCU. We proposed two options:

1. STM32 series chips.

2. AVR32 series chips.

In order to facilitate the smooth progress of follow-up work, we have conducted a comprehensive and detailed comparative analysis, which is discussed as follows:

The main advantages of AVR microcontroller are high performance, high speed and low power consumption. It cancels the machine cycle, uses the clock cycle as the instruction cycle, and implements pipeline operations. However, the address range of AVR's on-chip RAM is 0~00DF (AT90S2313) and 0060~025F (AT90S8515, AT90S8535). They occupy the address of the data space. These on-chip RAMs are only used to store data and are usually not used. Has the function of a general register. When the program is complex, general-purpose registers R0~R31 are not enough. Moreover, AVR has no bit operations and can only control and judge related register bits in byte form. Furthermore, by consulting the information, we know that programming in C language is quite different from the 51C language we are used to, which is not conducive to our efficient use.

In comparison, the STM32 series is slightly better in all the above aspects. Moreover, the STM32 series of microcontrollers can integrate rich on-chip resources, and the circuit coverage is wide but not complicated. Secondly, it can be developed based on the firmware library and programmed in C language. It has a lot of information and is cost-effective.

Further considering various factors such as power consumption, price, familiarity and chip resources, in summary, our team chose the STM32F103RCT6 chip from ST (STMicroelectronics).


3. System architecture and function description

3.1 STM32F103 chip

STM32F103 is a microcontroller based on a 32-bit CPU that supports real-time simulation and embedded tracking. The STM32F1 series is a mid- to low-end 32-bit ARM microcontroller. This series of chips is produced by STMicroelectronics (ST). Its core is Cortex-M3. The chip integrates timers, CAN, ADC, SPI, I2C, USB, UART, and other functions.

3.2 Crystal oscillator circuit module

The high-speed external clock signal is provided by an 8MHz passive crystal oscillator, and the low-speed external clock signal is provided by a 32.768KHz passive crystal oscillator, and two load capacitors are added respectively. The frequency of the crystal oscillator can be divided into the required frequency by software design of the chip.

3.3 Reset circuit module

Pin 14 of the STM32F103 chip is connected to the reset pin (nRST) of the main control chip. When the reset button S2 is pressed, the system will be reset to the initial state.

3.4 Communication download interface circuit**

 The communication download interface circuit selects USART serial communication. The +5V pin is connected to a red diode to determine the power-on condition.

3.5 JTAG/SWD debugging interface

Designed JTAG/SWD debugging interface to help hardware debugging

3.6 LED and independent button circuit

The LED circuit selects blue and green LED lights, and the independent button circuit defaults to high level.

3.7 电压转换电路

此外,电压转换电路也很重要,虽然大部分IO口都能承受5V电压,但有些不行,所以采用 AMS1117芯片加压为 3V3

3.8  OLED显示屏接口电路

对于OLED的设计,我们小组决定与核心板分开设计,在核心板上留有OLED显示屏接口,其CS、RES、SCK、DIN引脚都上拉,另外建一原理图来画OLED驱动电路,采用的是0.98寸基于SSD1306驱动芯片的OLED,以4线SPI模式通信。

3.9 五线四项步进机模块

使用ULN2003D达林顿晶体管,留有5个输入输出引脚,其中OUT1-4引脚用来控制五线四项步进机,OUT5用来接喇叭。使用了6脚排针,1号脚接5V,用来为电机和喇叭供电。

3.10 TFT彩屏触摸模块

TFT彩屏触摸接口,用14脚排母,引出所有引脚,T_IRQ、T_DIN、T_CS、T_CLK、TFT_SCK、TFT_SDI、TFT_RST、TFT_CS引脚上拉。打算外接的彩屏为2.8寸基于ILI9341控制芯片的TFT屏,以SPI模式通信。

3.11 其他一些设计电路

(1**)BOOT0和BOOT1引脚下拉,从用户闪存启动,并且为BOOT0预留接高电平以便从系统存储器启动。

(2**)为了能起控制作用也设计了外扩引脚,把部分引脚引出来。



4. 理论分析与计算

STM32核心板:

l  STM32的内核为 Cortex-M3 CPU

架构如右图所示:

    本设计芯片引脚图如下图所示

l  GPIO模式:其允许通过配置软件将GPIO引脚配置成8种模式,而STM32的通用输入/出脚通常分为 GPIOC GPIOD…GPIOG.

l  AMS1117降压电源模块:稳压 3.3V

l  外设ADC转换电路:STM32F103RCT6挂载的ADC外设,其内嵌的12位ADC共有3个且彼此相互独立,同时每一个ADC均设有6个外部通道。

拓展模块:

电机接口电路:

使用ULN2003D达林顿晶体管,留有五个输入

输出引脚,其中OUT1-4引脚控制五线四项步

进机,OUT5可接喇叭,通过6脚排针从 STM32

核心板引出,1号脚接5V用于电机跟喇叭供电。

步进电机型号为28BYJ-48,是一种步进减速电机

下图中,中间的部分是转子,由一个永磁体组成,边上的是定子绕组。当一组定子通电时,会产生一个方向的磁场,当定子产生的磁场和转子的磁场不是一个方向时,定子和转子间会产生一个扭力是转子运转。依次改变绕组的磁场就会使转子正转或者反转,比如通电的方向为A-B-C-D时,电机正转,反方向通电时,电机反转

一般电机的驱动方式为八拍方式驱动: A AB B BC C CD D DA

还有一种方式为四拍方式驱动: AB-BC-CD-DA-AB

28BYJ-48步进电机的电机步进角为5.625度,四项八拍驱动,且该步进机为减速步进机,带减速齿轮,减速比为1:64,因此输出轴的步进角为5.625/64=0.08789度。从上可知,对于电机,64个脉冲转动一圈,对于输出轴,4096个脉冲一圈。若控制买个脉冲间隔1ms,则输出轴上一个周期的时间便是4.096s,通过改变脉冲频率,便可改变转速。

TFT彩屏用14脚排母:

引出所有引脚,T_IRQ、T_DIN、T_CS、T_CLK、

TFT_SCK、TFT_SDI、TFT_RST、TFT_CS引脚上拉,

外接2.8寸基于ILI9341控制芯片的TFT屏,SPI通信。

● OLED显示屏:

采用0.98寸基于SSD1306驱动芯片的OLED,CS、

RES、SCK、DIN引脚上拉,以四线SPI通信,另外

本设计将OLED模块与核心板分开设计,在核心板上

预留OLED显示屏接口,引脚引出。

序号 名称 说明
1 VCC 电源(3.3V)
2 CS 片选信号,低电平有效,连接 F103 核心板的PB12
3 RES 复位引脚,低电平有效,连接 F103 核心板的PB13
4 D/C 数据指令控制,DC=1,传输数据,DC=0,传输指令连接 F103 核心板的PC3
5 SCK 时钟线,连接 F103 核心板的PB14
6 DIN 数据线,连接 F103 核心板的PB15
7 GND 接地

OLED 显示模块是一款集 SSD1306 驱动芯片、0.96 寸/128*64 分辨率以及驱动电路为一体的集成显示屏,我们通过 SPI 接口对 OLED 显示屏进行控制。将 OLED 显示屏插在 所设计的STM32 核心板上的 OLED 显示屏接口,即可通过核心板实现对 OLED 显示屏的控制。

●   TFT彩屏

本次使用的彩屏是以ILI9341驱动,采用14Pin SPI通信的。

ILI9341是一个用于TFT液晶显示的单芯片控制驱动器,具有262,144色的 [240xRGB](水平)x320(垂直)像素显示解决方案。它的组成包括一个720通道的源极驱动器,一个320通道的栅极驱动器,172800字节用于图形显示的GRAM,以及供电电路。

ILI9341有精确的电压(软件)控制,来支持全色,8色显示模式和睡眠模式,这使得ILI9341成为一个理想的中小型手提产品的LCD驱动器,比如数字电话,智能手机,MP3和PMP。

内部模块结构图如下:

5.电路图和PCB

图一为本次设计的32位单片机核心板的原理图:

本设计的32位核心板采用STM32F103RCT6核心板,基础模块基本实现,拓展模块如OLED模块的具体设计如图二所示,五线四相步进机以及TFT彩屏模块通过引脚排针引出,电机使用ULN2003D达林顿晶体管,OUT1-4用于控制五线四相步进机;TFT彩屏用14脚排针引出所有引脚,T_IRQ、T_DIN、T_CS、T_CLK、TFT_SCK、TFT_SDI、TFT_RST、TFT_CS引脚上拉。

# 6.调试与测试结果

基础部分中的复位按键,独立按键,led,下载接口和串行通信接口,oled 驱动,外扩引脚均完备,此外还拓展了一些,如步进电机、喇叭等等。

6.1  LED

  使能控制LED的引脚,写1点亮,写0 熄灭。

若要实现流水翻转可起初只点亮一个led,然后反转两个led 的输出信号即可

6.2   独立按键

烧写按键控制led变换来测试按键是否正常。对于该板独立按键的连接引脚,因为接了电源,默认高电平,当按下按键,IO 为低电平。(效果与视频演示时展现)

6.3  OLED 显示屏模块:

本设计中利用 OLED 显示原理以及 SSD1306 芯片工作原理实现OLED显示器显示,并编写程序基于 SSD1963 芯片控制 OLED 模 块驱动,最终在应用层通过调用 API 函数验证 OLED 驱动是否能够正常工作。

OLED 显示模块支持的 SPI 通信模式需要 4 根信号线和 1 根复位控制线,分别是:OLED片选信号 CS、命令/数据控制信号 D/C、串行时钟线 SCK、串行数据线 DIN 以及复位引脚 RES。 因此,只能往 OLED 显示模块写数据而不能读数据,在 SPI 通信模式下,每个数据长度均为 8 位,在 SCK 的上升沿,数据从 DIN 移入到 SSD1306,并且是高位在前。D/C 线用作命令/数据 控制。

The OLED display process is as follows. First, configure the relevant GPIO, secondly, turn off the display, configure SSD1306, turn on the display, then clear the screen, then write to the GRAM on the STM32, and finally, update the GRAM on the STM32 to the OLED to complete the OLED display.

The test results are as shown below

6.4 Stepper Motor Module

First connect the wires in order, and then write the code for the stepper motor. Enable four output pins and use eight beats, so declare the array {0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09}

Enter the loop and output the pin value corresponding to the array. Each state is delayed for a period of time to control the rotation of the motor. When the array is read in the opposite direction, the motor reverses. When the delay time is 1ms, one cycle becomes 4.096s.

6.5 speakers

It is an interesting thing to control the speaker to play music with a microcontroller. There is too much knowledge in it, not only about microcontroller control but also about music.

The two basic parameters of musical performance are the frequency value of each note (pitch) and its duration (duration). Therefore, as long as the frequency and duration of the excitation signal output to the speaker are controlled, continuous musical sound can be emitted.

1. Tone control

The level of frequency determines the level of pitch. The frequency corresponding to each note name from bass 1 to treble 1 in the simplified notation is shown in the table below.

In order to reduce the even-order harmonic components of the output, the waveform output to the speaker should be a symmetrical square wave, so a two-way frequency divider should be added in front of the speaker. The table shows the different preset numbers of the counter for each scale frequency. The method of loading preset numbers to achieve frequency division saves resources and is easier to implement than the feedback reset method.

2. Control of tone length

The duration of a note must be determined based on the tempo of the music and the number of beats per note.

According to each beat constant, a timer is used to delay a certain period of time so that the frequency is at the same frequency during this period.

6.6 TFT color screen

(The above implementation functions will be further demonstrated in the video.)

Conclusion

In this design, we started from understanding the most basic structure of the STM core board, then learned to design the PCB board, component layout, and wiring, and then learned to write the program and verify the functions. We practiced the design work almost from beginning to end. once. In addition, due to the epidemic, we also learned additional knowledge about simulation. It is no exaggeration to say that this topic has enabled us to gain countless important knowledge. The key points are hereby written into a report and the results will be displayed online. I would like to thank all the teachers for their careful guidance and patient review! At the same time, thank you for the platform and financial support provided by Lichuang!

【references】

[1] Tang Hu, Wei Ran, etc. Practical tutorial on circuit design and production - based on Lichuang EDA. Beijing: Electronic Industry Press, 2019.

[2] Li Hui. Principle analysis and hardware circuit design of STM32 microcontroller. Shaanxi, 2018.

[3] Microcontroller design based on STM32, Baidu Encyclopedia, http://www.51hei.com/bbs/dpj-120138-1.html .

[4]0.96-inch OLED12864 display design plan, CSDN,

https://blog.csdn.net/chengoes/article/details/105743754?from=groupmessage,groupmessage

.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2024-11-22 12:22:44

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号