K210 Road Sign Indication Action

K210 Road Sign Indication Action1. Hardware Connection2. Code Analysis3. Main Functions4. K210 Program Burning5. Experimental Phenomena

1. Hardware Connection

K210 Vision ModuleMSPM0G3507
5V5V
GNDGND
TXRX2
RXTX2

Physical Connection Diagram

image-removebg-preview

 

Schematic Diagram

image-20251029164049976

image-20251029164030395

image-20251029164356332

2. Code Analysis

Control Principle

K210 Protocol

Header 1Header 2LengthFunction CodeCar TypeX-axis SpeedX-axis SpeedY-axis SpeedY-axis SpeedZ-axis SpeedZ-axis Speedchecksum
0xFF0xFC0x0A0x12XXLow ByteHigh ByteLow ByteHigh ByteLow ByteHigh ByteXX

Control Flow Chart

Yes
No
Yes
No
Start
K210 sequentially learns 3 types of road signs
Road sign learning completed
Car moves forward
K210 recognizes specified road sign
Car executes specified action

revaction.c

K210 Partial Source Code

3. Main Functions

Upper_Data_Parse

Function Prototypevoid Upper_Data_Parse(uint8_t *data_buf, uint8_t num)
Function DescriptionHost computer data parsing function: processes different instructions based on function code (func_id) in data buffer. When function code is FUNC_MOTION, parses speed parameters (Vx_recv, Vy_recv, Vz_recv) and controls car movement (stops motors when speed is 0); when function code is FUNC_RGB, parses RGB color components, sets RGB light color and sends data
Input Parametersdata_buf: pointer to received data buffer num: data length (not used in function)
Return ValueNone

Upper_Data_Receive

Function Prototypevoid Upper_Data_Receive(uint8_t Rx_Temp)
Function DescriptionHost computer data receiving function: receives data in fixed format (with PTO_HEAD as header, PTO_DEVICE_ID as device ID), stores it in RxBuffer, and sets New_CMD_flag when reception is complete
Input ParametersRx_Temp: received single byte data
Return ValueNone

4. K210 Program Burning

After downloading and opening CanMV IDE, we need to first drag the k210_selfL.py file from the k210 source code provided in this course to CanMV IDE to open it, then connect the IDE, here using helloworld.py as example

image-20251029180540342

After successful IDE connection, the phenomenon is as follows

image-20251029181342135

Here we use helloworld.py as an example, open the top menu bar Tools -> Save currently open script as (main.py) to CanMV Cam

image-20251029205906069

image-20251029181630720

Both Yes/No can be selected here. When the following status appears, the write is successful.

image-20251029181701230

5. Experimental Phenomena

After burning the program, K210 will learn three types of road signs. Use the button on the side closer to the K210 TF card for learning. Collect five samples for each type. After successful collection, the car will move forward. When recognizing the first type of road sign, it will turn right; the second type will turn left; the third type will stop. If using firmware version 2.1.1, the button pin needs to be changed to 17. Please see source code analysis for details