3904 views|2 replies

2

Posts

0

Resources
The OP
 

Controllable non-motor vehicle direction indicator based on LED dot matrix screen [Copy link]

1. Project Introduction

I am a beginner of single-chip microcomputers. I signed up for the DIY competition with the spirit of a newborn calf not afraid of a tiger. The main purpose is to take the opportunity to set a concrete goal for myself to promote learning and gain experience. Through this competition, I can say that I have completed my first single-chip microcomputer work in the true sense, which is also quite commemorative. The specific development process can be said to be stumbling and full of difficulties. It can also be said that I learned and applied it at the same time. I stepped on many pits and made many mistakes... But fortunately, I finally barely completed the work. But in terms of level, it is definitely very low compared to the big guys~ But since I have already signed up, I will shamelessly post the results and share them. I hope that it can be a reference for the new comrades who have just started. Haha, please forgive me for making fun of you big guys~

The title of this project is a bicycle direction indicator based on GD32. The expected goal is very simple: to control the pattern of the LED dot matrix screen with a joystick. The reason why I chose this topic at that time was because of a practical life demand. Since I often ride and commute at night, I often see some night riding enthusiasts installing a warning light on the rear seat tube of their bicycles on the road. The specific effect is similar to that shown in Figure 1 below. These taillights basically have some simple operating modes, such as flashing, constant light, etc. After installing this taillight, it can serve as a warning at night, mainly used to remind the cyclist of the vehicle behind, effectively improving the safety of the cyclist (of course, the brightness of the taillight cannot be too high. If it shakes the vehicle behind, it is neither moral nor safe). At first, I felt that this little idea was very good. I also wanted to buy one to install on the car, but then I thought that this thing had too single function and the pattern was also monotonous. There was still a lot of room for improvement, so I had the idea of making a taillight with the function of indicating the driving direction. The so-called driving direction indication is actually similar to the role of car turn signals. When turning, slowing down, and moving forward, the rider can control the indicator light through the controller to prompt the vehicle behind him to his next running status. However, due to the limited space of the bicycle, it is definitely impossible to install turn signals on both sides of the tail like a car, so the idea of using a dot matrix screen to draw a direction arrow to achieve the prompt effect is shown in Figure 2.

Figure 1 Actual picture of taillight

Figure 2 Dot matrix display effect diagram

(II) System Block Diagram

The system structure of this project is very simple, mainly composed of five components: control joystick, 8*8LED dot matrix, MAX7219 driver board, GD32E231 development board and power supply. The system block diagram is shown in Figure 3. The control joystick, MAX7219 driver board and LED dot matrix and their working principles will be explained in detail below, while the power supply and development board will not be explained.

Figure 3 System structure diagram

(III) Description of the hardware working principle

The actual picture of the dual-axis joystick is shown in Figure 4. Its essence is actually a bidirectional potentiometer plus a micro switch. Its working principle is very simple: the cross joystick is a bidirectional 10K resistor. As the joystick direction changes, the resistance value of the tap changes. In the original state of using 5V power supply (3.3V is used in this project), the X, Y read voltage is about 2.5V (1.65V in this project). When the push button is pushed in one direction, the voltage value increases, up to 5V (the maximum in this project is 3.3V); when pushed in the opposite direction, the voltage value decreases, and the minimum is 0V. That is, the module has two analog outputs and one digital output interface. The output values correspond to the (X, Y) dual-axis offsets, and the type is analog; the button indicates whether the user presses on the Z axis, and the type is digital switch.


Figure 4 Dual-axis joystick controller

The MAX7219 driver module and the LED dot matrix screen are shown in Figure 5, and the schematic diagram is shown in Figure 6.

Figure 5 MAX7219 driver board and LED dot matrix screen

Figure 6 MAX7219 and LED dot matrix schematic

The MAX7219 is an integrated serial input/output common cathode display driver that connects a microprocessor to an 8-bit 7-segment digital LED display, a bar graph display, or 64 independent LEDs. It includes an on-chip B-type BCD encoder, a multiplexer scan loop, a segment word driver, and an 8*8 static RAM to store each data. Only one external register is used to set the segment current of each LED. The MAX7219 is compatible with SPI, QSPI, and MICROWIRE, and it has a segment driver with limited slew current to reduce EMI (electromagnetic interference). It also has a convenient four-wire serial interface that can be connected to all common microprocessors. Each data can be addressed without rewriting all displays when updating. The MAX7219 allows the user to choose to encode or not encode each data. The MAX7219 uses a three-wire serial interface to connect to the 8031 microcontroller. In terms of usage, the serial data of MAX7219 is serially input from the Din pin in the form of a 16-bit data packet, and is sent to the 16-bit shift register inside the chip one bit at each rising edge of CLK, regardless of the state of the Lout pin. The Load pin must be turned high at the same time or after the 16th CLK rising edge, but before the next CLK rising edge, otherwise the shifted data will be lost. The operator only needs to program and send a 16-bit data packet to simply operate the LED bit selection and segment selection, set and change the working mode of MAX7219. The data format of the 16-bit data packet is shown in Figure 7 below, and the read and write timing is shown in Figure 8.

Figure 7 7219 data format

Figure 8 7219 read and write timing diagram

Among them: D7~D0: 8-bit data bit, D7 is the highest bit, D0 is the lowest bit; D11~D8: 4-bit address bit; D15~D12: Don't care bit, usually all 1. MAX7219 can address 14 internal registers through D11~D84-bit address bit decoding, which are 8 LED display bit registers, 5 control registers and 1 empty operation register. The LED display register is composed of internal 8×8 static RAM. The operator can directly address the bit register individually to refresh and maintain data as long as V+ exceeds 2V (usually +5V). The control register includes: decoding mode, display brightness adjustment, scan limit (select the number of scan bits), shutdown and display test registers. The register address allocation table is shown in Figure 9 below. When initializing 7219, send the specified parameters according to the address in the table below to complete the parameter setting. For specific parameter configuration, please refer to the source code.

Figure 9 7219 register address allocation table

(IV) Programming

The driver implementation of this project is very simple. Because there is a 7219 driver board, it does not take too much effort to get it done. In terms of specific implementation, this design mainly uses SPI to realize data transmission, so only three pins need to be defined and initialized. In this project, PB13 SPI1_SCK, PB15 SPI1_MOSI, and PB1 are used to connect the CLK, DIN, and CS pins of the 7219 driver board. After the initialization and configuration are completed, it is necessary to write the data sending function. It should be noted that when sending data, the chip select pin level must be lowered before writing the address and data. At this point, pay attention to the timing diagram of 7219. After writing the sending function, it is also necessary to initialize 7219. The specific method is to write specific data to the specific register of 7219 through the data sending function just written. If this step is not performed, 7219 will not work properly. After all the above configurations are completed, the LED dot matrix screen can actually work. At this time, as long as the array font library is passed to 7219 through the sending function, the screen can be driven to display patterns. The format of the font is very easy to understand. Simply put, it uses 8 bytes of hexadecimal data to represent the display content of 8 rows of LEDs from top to bottom, so as to form a pattern. Writing a font is actually very simple, and you can do it with just a few strokes of a pen.

Since the purpose of this design is to indicate the direction, I drew a few arrow patterns myself. But if it is just a static display, it is too low. At least the pattern should be animated, right? The method to make the pattern on the dot matrix screen animated is actually very simple. In short, it is to use a loop and operate the matrix to make the data in the font library animated, and then continuously refresh the display to form an animation effect due to the visual persistence effect. The specific implementation method of the function is in the source code, which is not difficult to understand, so I will not go into details here. However, it should be noted that when calling the data sending function, you must add a delay before and after it, otherwise the pattern will become a bunch of garbled characters... The specific reason is unknown. It is currently speculated that it may be due to the mismatch between the operating frequencies of 7219 and GD32...

The method of using the joystick to control the pattern is also very simple. In short, it is to read the signal through the ADC, and then continuously judge and display the call in the loop. In this design, only two output pins of the joystick are used, so you only need to configure the ADC of two channels to realize the signal reading. The specific method adopts the two-channel configuration of non-DMA mode. After the configuration is completed, write the ADC value reading function, and then write it in the interrupt function so that the ADC values of the two channels can be continuously and quickly updated. What needs to be paid attention to here is the configuration of the sampling period. The accuracy can be set smaller to improve the real-time performance, because only the position information of the joystick is read, and it is useless if the accuracy is too high.

After completing the above work, the content of the main function is very simple. You only need to execute the system clock configuration, SPI initialization, SPI initialization, MAX7219 driver initialization, ADC initialization, and then execute the loop. The content in the loop is mainly to continuously determine the push direction of the joystick according to the ADC return value, so as to control the LED dot matrix to display the arrow in the corresponding direction. The specific effect can be seen in the video demonstration.

(V) Demonstration of achievements

photo

Short video

(See attachment)

Note: As shown in the video, when you push the joystick upward, the screen displays an upward arrow, which means the vehicle will move forward; when you push the joystick to the left, the screen displays a leftward arrow, which means it is about to turn left, and the same applies to turning right; when you push the joystick backward, the entire LED screen lights up, which means the vehicle is slowing down or about to stop.

(VI) Summary and Outlook

After the overall introduction, I feel very ashamed and guilty... because as far as the current situation is concerned, the finished product is too simple. The original idea was to use Bluetooth as a communication connection method to achieve remote control, so that the joystick can be neatly installed on the handle. In addition, I also want to integrate the dot matrix driver chip, main control chip, power circuit, etc. on a board, and then 3D print a package that can accommodate batteries and circuit boards to reduce the size and further optimize power consumption and performance, making it a small product that can be directly installed on the car... However, due to my low level and limited time, these ideas have not been realized before the deadline... However, in the follow-up work, I will continue to work hard to continuously improve it~ After all, it is my first microcontroller work, I hope to get off to a good start, haha~

I would also like to give special thanks to my good friend LuLu for his strong support. Thank him for helping me solve problems tirelessly and allowing me to appreciate the beauty of technology!

image-20190622212247-1.png (22.71 KB, downloads: 0)

image-20190622212247-1.png

image-20190622212247-2.png (18.08 KB, downloads: 0)

image-20190622212247-2.png

演示视频.7z

2.01 MB, downloads: 5

MAX7219点阵资料包.7z

719.81 KB, downloads: 5

工程文件.7z

1.54 MB, downloads: 9

说明文档.7z

995.15 KB, downloads: 6

This post is from GD32 MCU

Latest reply

Thanks for sharing   Details Published on 2021-4-10 17:08
 

189

Posts

0

Resources
2
 

Thanks for sharing

This post is from GD32 MCU
 
Personal signature单片机软件/硬件交流群:127034610
 
 

661

Posts

0

Resources
3
 

Thanks for sharing

This post is from GD32 MCU
 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list