他们逼我做卧底

STC8G-51 microcontroller development board

 
Overview

To learn a microcontroller, you must have a microcontroller development board. The reason is very simple: if you want to learn to drive, and you only watch video tutorials on how to drive without actually getting on the car, you probably won't be able to learn it in ten thousand years.

 

So what kind of development board is suitable for novices?

 

First, you must be able to learn and practice all the basic knowledge of microcontrollers.

 

These basic knowledge include: IO port, PWM, timer, ADC analog-to-digital conversion, serial communication, I2C communication, SPI communication, parallel communication, watchdog, low-power power management, etc.

 

Hongjing STC51 microcontroller is undoubtedly the most suitable. First of all, its teaching materials have penetrated into major universities, and many teachers also use it for teaching. Furthermore, it is indeed very simple, and there is a wealth of information online, especially for beginners.

 

Second, in addition to learning the basic knowledge above, you can also do some projects on the development board.

 

After many people use ordinary development boards to learn, they feel that they have learned it, but they still feel that they can't do anything. It doesn’t matter if one person feels the same way, but almost everyone feels the same way. Do you think it’s strange?

 

The reason is the lack of project practice. You said that there are projects on those ordinary development boards, but they are all "ghost-making" gadgets, such as intelligent flower watering systems and smoke alarm systems. The practicality of the products is too poor to even I don't even believe that this system can be used in practice...

 

Because in actual application, the flower watering system you made. First of all, from the appearance, it’s a mess and it doesn’t look like a product at first glance. Then, there are so many wires wound around it, and the stability is really poor. Everyone who saw it gave it a bad review!

 

Considering the above two points, let's see if we can design a microcontroller development board that can perfectly solve the above two problems.

 

----------I am the dividing line---------

 

The first one: You must be able to learn all the basic knowledge of microcontrollers.

 

1. IO port

 

The IO port is the output port. In the final analysis, the microcontroller is playing with IO. As a beginner, the IO port is the key to opening a new world. You must learn it!

 

As an "input port" learning, there is nothing more suitable for beginners than "buttons". Buttons play an important role in teaching us to understand the input of pins! No matter how popular "touch" is in society, buttons must be placed on the development board.

 

How many buttons should be placed? Too much is a waste, less is not enough. Let’s put 3 buttons on the development board, and most electronic projects can be realized.

 

As an "output port" to learn, there is nothing more suitable for beginners than "LED". How many beginners are excited about lighting up an LED.

 

In order to increase the fun, here we use 3 colors of red, yellow and green, and 3 LEDs, which can not only realize the 3LED running water light, but also imitate the operation process of the traffic light system and become familiar with the execution process of C language.

 

2. PWM pulse width modulation

 

PWM output is also a kind of knowledge that beginners must master. It can be used in breathing lights, motor control, steering gear control and other occasions. Isn't it funny if those who work on microcontrollers don't know PWM?

 

Using the above LED, you can do a breathing light experiment. This is achieved by adjusting the PWM duty cycle.

 

Let’s have another one with FM, add a passive buzzer, remember, it is passive, we don’t want active one, passive buzzer with PWM can output do ri mi fa so la xi tone, making music is not Dream.

 

Using the IO port to simulate PWM can increase beginners' understanding of the PWM principle. However, after simulating PWM, the microcontroller may not be able to do other things. Therefore, if the microcontroller has hardware PWM, it would be perfect...learn to simulate PWM understanding first. Principle, then use hardware PWM to do more projects.

 

3. Timer, UART serial port, watchdog

 

These items are standard features of ordinary microcontrollers, and of course STC microcontrollers have them.

 

4. ADC analog-to-digital conversion

 

With the Internet of Everything and the explosion of sensors, ADC, as a peripheral that can convert analog voltage into digital voltage, is increasingly needed.

 

So we also need to find a microcontroller with its own ADC peripherals.

 

What experimental study can be done with ADC? It is better to add a lithium battery to our product and use ADC to measure the battery voltage.

 

Adding a lithium battery to the development board is a good idea, as it allows our development board to create more mobile and portable projects.

 

5. I2C port

 

In the past, when we learned I2C communication, we always liked to use 24C02 for teaching. However, the STC microcontroller itself already has its own EERPOM, and then adding a 24C02 to the circuit always felt like something was wrong.

 

Why not, let's find another chip for I2C communication and choose from a variety of options. Let's choose a 3-axis acceleration sensor. With it, we can not only learn I2C communication, but also bring us more unlimited creativity.

 

6. SPI port

 

Considering the fun of the product, we must have a screen for this development board. To display Chinese characters on the screen, we must have an external FLASH chip with a large enough storage capacity to store the Chinese character fonts.

 

Here we choose 25Q64 for SPI port communication, with 8M capacity, which can store several font libraries with different fonts and different pixel sizes.

 

7. Parallel communication

 

The UART serial port, I2C port, and SPI port mentioned above are all models of serial communication. Almost all external sensors and IoT communication modules use one of these three.

 

In order for beginners to better understand the difference between serial communication and parallel communication, we must add a parallel communication device.

 

We choose an LCD screen with 8-bit parallel communication. 12864 is 8-bit parallel communication. However, compared with the color LCD screen, the effect of 12864 is a bit worse. Moreover, the wiring method of the color TFT driven by the 8-bit parallel port is exactly the same as that of 12864. The learning method is the same. If you don’t have enough knowledge, why don’t you come up with something that will be more effective?

 

Commonly used TFTs on development boards are 2.4-inch, 2.8-inch, and 3.2-inch. Their resolutions are all 240*320, and they are all ordinary front-view screens. If you look at them slightly crookedly, the color will be "off". This Screens with this kind of effect are no longer accepted as products. It's like using a mechanical hard drive after using a fixed hard drive.

 

The resolution of 320*240 is actually very difficult for the 51 microcontroller. We will not pursue a higher resolution screen. However, we know that at the same resolution, the smaller the screen, the clearer it will be. , the better the effect, so we start from this point and choose a 2.0-inch screen.

 

This time, we must choose an IPS multi-angle screen. This kind of screen is what people can accept now. Since we want to do a project on the development board, it must be made into a product level.

 

8. Low power consumption power management

 

Needless to say, low power consumption is the trend in electronic products. Therefore, we need a microcontroller with a low-power management unit to facilitate beginners' learning.

 

----------I am the divider----------

 

The above are our requirements for the development board. Based on the above factors, we chose STC’s latest STC8G2K64S4 as the main control chip of the development board.

 

This microcontroller has a 10-bit ADC, hardware PWM, hardware I2C, hardware SPI, 4 UART serial ports, 5 16-bit timers, and a low-power management unit. It is simply a microcontroller tailor-made for beginners.

 

----------I am the dividing line----------

 

Second: In addition to learning basic knowledge, you must also do product-level projects

 

Some people say that this is too much. You can learn the basics and make products, so why don't you go to heaven?

 

I really thought of this, please read on.

 

Ordinary development boards, considering the development needs, will use pin headers to lead out all the pins, and then they cannot be blocked by the screen, so they are relatively large.

 

However, most of the pins derived from the pin headers have been used by the chips on the development board, and few people are using these pins to connect external modules.

 

In fact, we only need to lead out the unused microcontroller pins of the chip on the development board. Moreover, we can put the pin headers or header headers on one side of the circuit board, and put the LCD screen on the other side of the circuit board. This can reduce the size of the circuit board and make it closer to the actual product.

 

In addition, the pins on the development board should include ordinary IO, PWM port, UART serial port, I2C port, SPI port, and ADC analog-to-digital conversion port to facilitate the connection of more external sensors and communication modules.

 

--------Am I a dividing line or a dividing line--------

 

Do I need to remove the lithium battery and install a charger? No, no, that's ancient electronics.

 

We just need to add a lithium battery charging chip to the development board, such as TP4056.

 

Add a USB to TTL chip CH340 to realize program download and serial communication.

 

Is it troublesome to download the STC program? Do I need to force the development board to power off and on?

 

It doesn't matter, we add a button power switch to it, and it can be downloaded with just one click, and it can also be used as a reset button, killing two birds with one stone.

 

------Can't figure out whether it is a dividing line or a dividing line------

 

Based on the above considerations, the schematic diagram of the development board is released.

 

Make the PCB.

 

Just 3D print a shell and put it on.

 

According to actual measurement, the 3D printed shell is not resistant to falling. As long as it falls on the ground, the chance of breaking is very high. Don't ask me how I know...

 

Since we want to make product grade, we'd better find a mold factory to make the shell. Although it's a bit expensive, the shell made by the mold has a very good feel and quality, and is also very thin...

 

For those pins on the back, it is better to add the pin names to facilitate us to connect external modules. As follows:

 

Because the space on the back of the shell is limited, I can only write its IO pin names. For those multiplexed pin names, just look at the picture below. I want UART, I2C, SPI, etc., all available.

 

After the development board is ready, of course, the corresponding routine code must be prepared for learning.

 

First, do basic routines for all basic knowledge.

 

Now that you’ve learned the basic routines, you have to do some projects, right? Come on, the application routines are also ready.

 

Want to know how different the application examples are from the actual product? Come on, picture above.

 

Bilibili video tutorial:

https://www.bilibili.com/video/BV1QU4y1t7JA/

 

If you support me, here is the Taobao link:

https://item.taobao.com/item.htm?ft=t&id=645481198623

 

Download link for all materials including routines:

Link: https://pan.baidu.com/s/1Wbdvx-enD0m9RHfIpnuOWg 
Extraction code: w1cv

 

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-07-09 04:40:32

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

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号