借用STC官网的一句话:2022,32位8051元年 !国之重器 大国脊梁 全部工规 强抗干扰
看到这,是不是脑子已经浮现出那独具一格的官网首页了,没错,今天我们来推荐一款2022最新32位8051内核的单片机:STC32G12K128。为了帮助大家更好地学习STC32,我们特意设计了这款十分精致的核心板,板载CH340芯片,拿到开发板即可使用,板子上还预留了一个LED灯、一个按键,还外挂了一个24C02存储器,为你的STC32学习之旅更加方便。接下来介绍一些核心板的主要特性:
1 芯片特性
STC32G系列单片机以超强抗干扰/超低价/高速/低功耗为目标的32位8051单片机,在相同的工作频率下,STC32G系列单片机是传统的8051单片机越快70倍。由此可见STC的32位单片机的性能并不一般。
芯片内置高精度的R/C时钟,不需要外接晶振即可使用,主频为33Mhz。芯片提供了丰富的数字外设,包括4路串口、5个定时器、2租带死区控制的高级PWM定时器以及IIC、SPI、USB、CAN、LIN接口以及超高速的12位ADC以及比较器,满足大部分设计需求。我们有什么理由可以拒绝STC推出的这款高性价比的32位单片机呢?
2 板载资源
主控芯片:STC32G12K128,LQFP-48贴片封装
电源连接:使用1个Type C进行供电或与电脑连接进行程序下载
串口下载:使用CH340N芯片与电脑进行通信,无需外接下载器
LED显示:一个电源指示灯以及一个状态指示灯
按键控制:一个常闭开关用于芯片冷启动下载,一个带中断功能的独立按键
程序扩展:使用IIC接口外挂一个M24C20 EEPROM芯片
排针接口:将芯片引脚全部引出,兼容其它主流单片机核心板引脚排列。
基准电压源:使用CD431基准电压源,为单片机提供稳定的2.5V参考电压。
这款核心板板载串口下载,可以很方便得进行学习和调试,从最基础的输入输出功能的学习、串口通信、IIC通信以及单片机的中断、定时器、PWM等重要功能都可以在这个核心板中学习。核心板的所有引脚引出且兼容其它主流单片机,板子外形上下排针间距为15.24mm(600mil),可以插到面包板或洞洞板上,便于功能的扩展与调试,可以快速完成项目的验证,让单片机学习更加简单。
3 优势特点
外观小巧:板子尺寸仅为53.36mm*22.86mm(2100mil*900mil),可任意搭配底板进行项目开发
性价比高:用51的价格玩32的性能
设计灵活:所有功能引脚IO引出,便于各种功能的验证
调试方便:板载CH340N串口芯片,无需下载器即可程序下载与调试
4 应用场景
电路EDA软件学习,学习电路原理图、PCB的设计,学会制作一块最小系统
高校教学应用,学习微机原理与程序设计,使用该核心板完成课程设计项目
电子爱好者学习,掌握单片机电路设计与程序开发能力,学习项目开发规范
电子工程师验证,快速上手STC32单片机的学习,对所需的功能进行验证开发
竞赛学习与训练,可以在电赛中快速搭建所需电路
5 视频教程
核心板教学视频请移步Bilibili,欢迎大家一键三连~
视频教学链接:https://space.bilibili.com/494969171/channel/collectiondetail?sid=635687
6 项目进度
时间
项目记录
2022-07-18
完成核心板电路设计
2022-07-20
修改基准源电路,完成核心板焊接与功能调试
下一步
核心板扩展项目设计中。。。
一、核心板简介
随着技术的升级,传统的8051内核已经难以满足日常的学习和设计需求,增强型8051内核的STC15系列单片机出现在了大家的视野。随着IAP技术在单片机领域的不断发展,STC推出了IAP系列的单片机,它的一个显著特点带仿真功能,可以在Keil里调试程序,可以帮助我们快速找到程序运行中的Bug。目前IAP15单片机已广泛应用于各类单片机课程以及专业赛事中,其中最为人熟知的是在蓝桥杯单片机赛中的主控就是IAP15单片机。
为了帮助大家更好地学习单片机理论与应用基础,未来电子工作室参考时下比较流行的STM32最小核心板的设计,设计出了这么一款板载USB下载电路与EEPROM存储电路的核心板。我们提供了完善的设计流程文档与视频资源,从电路原理图的设计、PCB的设计与焊接调试的硬件设计基础讲起,到开发环境搭建,核心板各个功能的程序功能演示,再结合蓝桥杯历届大赛的赛题项目与一些实用的电子设计项目分析,帮助大家更好地学习这款单片机的应用开发,十分适合高校单片机教学、蓝桥杯训练、爱好者学习以及工程师学习和快速开发使用。
图1-1 IAP15F2K61S2核心板硬件图解
二、板载资源
主控芯片:IAP15F2K61S2,LQFP-32贴片封装
电源连接:使用1个Type C进行供电或与电脑连接进行程序下载
串口下载:使用CH340N芯片与电脑进行通信,无需外接下载器
串口通信:一个4Pin的排针对外引出,可与外接设备进行串口通信
LED显示:一个电源指示灯以及一个状态指示灯
按键控制:一个常闭开关用于芯片冷启动下载,一个带中断功能的独立按键
程序扩展:使用IIC接口外挂一个M24C20 EEPROM芯片
排针接口:将芯片引脚全部引出,兼容其它主流单片机核心板引脚排列。
这款核心板板载串口下载,可以很方便得进行学习和调试,从最基础的输入输出功能的学习、串口通信、IIC通信以及单片机的中断、定时器、PWM等重要功能都可以在这个核心板中学习。核心板的所有引脚引出且兼容其它主流单片机,板子外形上下排针间距为15.24mm(600mil),可以插到面包板或洞洞板上,便于功能的扩展与调试,可以快速完成项目的验证,让单片机学习更加简单。
图1-2 IAP15F2K61S2核心板尺寸图
三、优势特点
外观小巧:板子尺寸仅为53.36mm*22.86mm(2100mil*900mil),可任意搭配底板进行项目开发
性价比高:使用增强型51内核芯片,功能引脚丰富,价格便宜
设计灵活:所有IO引出,便于各种功能的验证
调试方便:板载CH340N串口芯片,无需下载器即可程序下载与调试
质量过硬:使用嘉立创优质PCB以及正品元器件,保障产品质量
教程齐全:配套用户手册、代码例程、完整的开发教程视频。从电路设计、PCB设计到软件 编程调试,以完善的知识体系与扩展项目在学习单片机的过程中培养嵌入式工程师的开发能力与学习能力。
四、应用场景
电路EDA软件学习,学习电路原理图、PCB的设计,学会制作一块最小系统
高校教学应用,学习微机原理与程序设计,使用该核心板完成课程设计项目
电子爱好者学习,掌握单片机电路设计与程序开发能力,学习项目开发规范
电子工程师验证,快速上手IAP15单片机的学习,对所需的功能进行验证开发
竞赛学习与训练,可以在电赛中快速搭建所需电路以及对蓝桥杯单片机赛进行训练
借用STC官网的一句话:2022,32位8051元年 !国之重器 大国脊梁 全部工规 强抗干扰
看到这,是不是脑子已经浮现出那独具一格的官网首页了,没错,今天我们来推荐一款2022最新32位8051内核的单片机:STC32G12K128。为了帮助大家更好地学习STC32,我们特意设计了这款十分精致的核心板,板载CH340芯片,拿到开发板即可使用,板子上还预留了一个LED灯、一个按键,还外挂了一个24C02存储器,为你的STC32学习之旅更加方便。接下来介绍一些核心板的主要特性:
1 芯片特性
STC32G系列单片机以超强抗干扰/超低价/高速/低功耗为目标的32位8051单片机,在相同的工作频率下,STC32G系列单片机是传统的8051单片机越快70倍。由此可见STC的32位单片机的性能并不一般。
芯片内置高精度的R/C时钟,不需要外接晶振即可使用,主频为33Mhz。芯片提供了丰富的数字外设,包括4路串口、5个定时器、2租带死区控制的高级PWM定时器以及IIC、SPI、USB、CAN、LIN接口以及超高速的12位ADC以及比较器,满足大部分设计需求。我们有什么理由可以拒绝STC推出的这款高性价比的32位单片机呢?
2 板载资源
主控芯片:STC32G12K128,LQFP-48贴片封装
电源连接:使用1个Type C进行供电或与电脑连接进行程序下载
串口下载:使用CH340N芯片与电脑进行通信,无需外接下载器
LED显示:一个电源指示灯以及一个状态指示灯
按键控制:一个常闭开关用于芯片冷启动下载,一个带中断功能的独立按键
程序扩展:使用IIC接口外挂一个M24C20 EEPROM芯片
排针接口:将芯片引脚全部引出,兼容其它主流单片机核心板引脚排列。
基准电压源:使用CD431基准电压源,为单片机提供稳定的2.5V参考电压。
这款核心板板载串口下载,可以很方便得进行学习和调试,从最基础的输入输出功能的学习、串口通信、IIC通信以及单片机的中断、定时器、PWM等重要功能都可以在这个核心板中学习。核心板的所有引脚引出且兼容其它主流单片机,板子外形上下排针间距为15.24mm(600mil),可以插到面包板或洞洞板上,便于功能的扩展与调试,可以快速完成项目的验证,让单片机学习更加简单。
3 优势特点
外观小巧:板子尺寸仅为53.36mm*22.86mm(2100mil*900mil),可任意搭配底板进行项目开发
性价比高:用51的价格玩32的性能
设计灵活:所有功能引脚IO引出,便于各种功能的验证
调试方便:板载CH340N串口芯片,无需下载器即可程序下载与调试
4 应用场景
电路EDA软件学习,学习电路原理图、PCB的设计,学会制作一块最小系统
高校教学应用,学习微机原理与程序设计,使用该核心板完成课程设计项目
电子爱好者学习,掌握单片机电路设计与程序开发能力,学习项目开发规范
电子工程师验证,快速上手STC32单片机的学习,对所需的功能进行验证开发
竞赛学习与训练,可以在电赛中快速搭建所需电路
4 视频教程
核心板教学视频请移步Bilibili,欢迎大家一键三连~
视频教学链接:https://space.bilibili.com/494969171/channel/collectiondetail?sid=635687
6 项目进度
时间
项目记录
2022-07-24
完成核心板电路设计
2022-08-15
视频教学录制完成
### Project Introduction
Question F to participate in the 2021 National E-Sports Competition: Intelligent Medicine Delivery Car. The image processing part is the H750 core board equipped with OPEMMV, and the main controller is the F401 microcontroller, including motor drive, power module and other parts.
This open source project opens up the motor drive circuit and PCB, and already opens up the image processing and control solutions.
Let’s take a look at the basic requirements of the question:
![wCB6ApoNmQwUzfLSfMdUpMTwQY86HPLl7ChtwSJk.png]
![QQ screenshot 20211217133723.png]
Analysis: To realize the intelligent car automatically identifying the ward number and road surface information, the car needs to have an image recognition module. What we choose here is to carry OPENMV's H750 microcontroller core board (see below for detailed analysis of the image processing part). The result of image processing communicates with the main control microcontroller through serial communication, and controls the movement of the smart car according to the requirements of the question.
In addition, each requirement has a stipulated completion time, and speed is the key to victory. Our team chose the "tricycle" structure: two main driving wheels and a passive universal wheel. This structure can make the car's movement more flexible and have more advantages in right-angle turns and return to the original place. The drive module that drives two DC motors is the DRV8701 module. See below for the specific circuit and analysis.
- - -
### Project function introduction
* The power supply part of the car uses a 12V model aircraft battery, which is stepped down to 3.3V through the DCDC step-down module to supply power to the microcontroller and other modules;
* Use the DRV8701 motor drive module (see the project document for details);
* Image processing Part of it uses the H750 core board equipped with OPENMV, and the identification scheme is template matching;
### For the circuit explanation
of the motor drive part,
the driver chip we chose is **Texas Instruments**'s DRV8701, a brushed DC motor full-bridge gate driver, which has the advantages of wide input voltage, convenient and flexible control, and small package size.
DRV8701 can realize single-channel DC motor control by using an H-bridge circuit composed of four QN3109 N-channel MOS transistors and some peripheral circuits. See the picture below for the actual picture.
This schematic diagram is drawn based on the DRV8701 official data manual. The motor chopping current is about 3.25A. When powered by a lithium battery (about 12V), it can drive the DC motor model MG513 very well.
![QQ screenshot 20211215164002.png]
In this system, the total power source comes from a lithium battery (voltage is about 12V). The peripheral circuits such as microcontroller and motor drive require a working voltage of about 3.3V, which requires a step-down module.
At the same time, due to the need to supply power to two microcontrollers and two motor drive modules, considerable requirements are placed on the working current and working stability of the buck module.
After many selections, we chose the SY8303 DCDC step-down chip, which has the advantages of wide input voltage, high switching frequency, and small package size. The physical diagram of the SY8303 step-down module circuit is shown in the figure below.
![QQ screenshot 20211215164238.png]
- - -
### Software
main control program part:
the basic part of the single-car drug delivery mode and the functional part of the main control microcontroller program flow chart in the dual-car drug delivery mode is shown in the figure below.
![QQ screenshot 20211215164635.png]
Although the title puts forward the requirement that the body projection cannot be pressed, in fact, as long as the car body can be traced according to the red solid line, the effect of not pressing the line can be obtained. Therefore, the first single chip microcomputer The first task is to be able to track along the line; secondly, the visual part is the eyes of the microcontroller. When the sensor is limited, all the information that vision can provide must be made timely and fully effective use, so data transmission is also an important part of the microcontroller. Task; in addition, during the debugging process, it is necessary to output some debugging logs and print debugging data, which are also important tasks of the microcontroller.
To summarize, these tasks of the microcontroller are mainly divided into two categories: one is the complex front-end line tracking task, and the other is the background data transmission task (including data transmission with the visual part and the host computer).
The first is the front-end task: the entire process of completing the task is actually a process of constantly switching between multiple different complex states. Therefore, the overall front-end business program adopts the finite state machine program architecture to more conveniently display and implement each The relationship between states and the task content of each stage.
Next is the background task: In addition to data transmission, background tasks also update some important control quantities. In view of the large number of background tasks and strong periodicity, we reused the timing resources of a timer, adopted the program architecture of time slice polling, implemented a simple "castrated version of the operating system", and then placed different tasks separately. Go to their respective tasks and perform time slice polling of different tasks in the timer.
Image recognition program part:
The image is responsible for tracking, number recognition, determining steering direction, etc. The specific flow chart is shown in the figure below
! [QQ screenshot 20211215165019.png]
1) Automatic tracking
straight line tracking is mainly to do the red straight line in the center of the track Edge detection and Hough line detection (the effect after processing is shown in Figure 6). After detecting the straight line, calculate the offset of the center x coordinate of the straight line relative to the image center coordinate, and send it to the microcontroller. The microcontroller passes the offset through PID After calculation, it is applied to the speed of the two wheels, and the car rotates through the differential speed of the two wheels, automatically following the direction of the red solid line, thereby realizing automatic path finding.
The second part of the tracking part is the recognition of right-angle intersections. The basic steps are the same as those of straight line recognition. Finally, the angle between the two straight lines and the intersection of the two straight lines are compared to form the basis for digital recognition. The cross recognition effect is shown in the figure below
! [QQ screenshot 20211215165144.png]
2) Number recognition
The number recognition in this system uses the template matching function in OpenMV, which can automatically match patterns that are basically the same size and angle as the template image. After confirming the ward number, the corresponding digital picture stored in the microcontroller flsah will be used as the template picture. When encountering an intersection, the image captured by the camera is template matched with the target number. If the match is successful, the position of the corresponding number is recorded and compared with the X coordinate of the cross center to determine the turning direction of the car and then sends it to the microcontroller. Turn command. The number recognition effect is shown in the figure (taking the recognition of the number 4 as an example).
![QQ screenshot 20211215165235.png]
Image processing part number recognition part code:
``` C
def find_single_num(img,num,y_thre): #Find numbers
if(num==3):
for temp in template3:
r3=img. find_template(temp, 0.7, step=1, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if(r3):
if(r3[1]+r3[3]/2>y_thre):
black_num=0
for x in range(r3[0],r3[0]+r3[2]):
if img.get_pixel (x,int(r3[1]+r3[3]/2))<40:
black_num+=1
if(black_num>2):
img.draw_rectangle(r3)
return r3[0]+r3[2]/2
elif (num==4):
for temp in template4:
r4=img.find_template(temp, 0.7, step=1, search=SEARCH_EX)#, roi=(10, 0, 60, 60))
if(r4):
if (r4[1]+r4[3]/2>y_thre):
black_num=0
for x in range(r4[0],r4[0]+r4[2]):
if img.get_pixel(x,int(r4 [1]+r4[3]/2))<40:
black_num+=1
if(black_num>2):
img.draw_rectangle(r4)
return r4[0]+r4[2]/2
elif(num==5) :
for temp in template5:
r5=img.find_template(temp, 0.7, step=1, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if(r5):
if(r5[1]+ r5[3]/2>y_thre):
black_num=0
for x in range(r5[0],r5[0]+r5[2]):
if img.get_pixel(x,int(r5[1]+r5[ 3]/2))<40:
black_num+=1
if(black_num>2):
img.draw_rectangle(r5)
return r5[0]+r5[2]/2
elif(num==6):
for temp in template6:
r6=img.find_template(temp, 0.7, step=1, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if(r6):
if(r6[1]+r6[3]/2 >y_thre):
black_num=0
for x in range(r6[0],r6[0]+r6[2]):
if img.get_pixel(x,int(r6[1]+r6[3]/2)) <40:
black_num+=1
if(black_num>2):
img.draw_rectangle(r6)
return r6[0]+r6[2]/2
elif(num==7):
for temp in template7:
r7=img.find_template( temp, 0.7, step=1, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if(r7):
if(r7[1]+r7[3]/2>y_thre):
black_num= 0
for x in range(r7[0],r7[0]+r7[2]):
if img.get_pixel(x,int(r7[1]+r7[3]/2))<40:
black_num+=1
if(black_num>2):
img.draw_rectangle(r7)
return r7[0]+r7[2]/2
elif(num==8):
for temp in template8:
r8=img.find_template(temp, 0.7 , step=1, search=SEARCH_EX) #, roi=(10, 0, 60, 60))
if(r8):
if(r8[1]+r8[3]/2>y_thre):
black_num=0
for x in range(r8[0],r8[0]+r8[2]):
if img.get_pixel(x,int(r8[1]+r8[3]/2))<40:
black_num+=1
if(black_num >2):
img.draw_rectangle(r8)
return r8[0]+r8[2]/2
return 0
``
- - -
### Image processing part intersection recognition part code:
``` C
def check_cross(img ): #Intersection identification
left_y=0
right_y=0
for blob in img.find_blobs([(100,200)], pixel_threshold=500,merge=True, margin=5,roi=(0,0,60,120)):
img. draw_rectangle(blob.rect())
left_y=blob.cy()
img.draw_cross(blob.cx(), blob.cy())
for blob in img.find_blobs([(100,200)], pixel_threshold=500,merge= True, margin=5,roi=(100,0,60,120)):
img.draw_rectangle(blob.rect())
right_y=blob.cy()
img.draw_cross(blob.cx(), blob.cy())
if(left_y and right_y):
if(math.fabs(left_y-right_y)<20):
return 1
return 0
find_cross_flag=1
``
- - -
### The picture
test site is as shown below:
![QQ screenshot 20211215165345.png ]
The overall photo of the car is as follows:
![QQ screenshot 20211215165418.png]
The test video is attached. It was taken early in the project and has flaws.
PCB_PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2_2022-09-24.pdf
PCB_PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2_2022-09-24.json
PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2_2022-09-24.pcbdoc
Gerber_PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2_2022-09-24.zip
PCB_PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2022-09-24.pdf
PCB_PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2022-09-24.json
PCB_2021 Question F-Smart Medicine Delivery Car + Team with Weird Name Can Win the Prize_2022-09-24.pcbdoc
Gerber_PCB_2021 Question F-Intelligent medicine delivery car + team with weird team name can win the prize.zip
Schematic_2021 Question F-Smart Medicine Delivery Car + Team with Weird Name Can Win the Prize_2022-09-24.pdf
SCH_2021 Question F-Smart Medicine Delivery Car + Team with Weird Team Name to Win the Prize_2022-09-24.json
2021 Question F - Smart Medicine Delivery Car + Team with Weird Name Can Win the Prize_2022-09-24.zip