# Introduction to the work
This project comes from the Lichuang·Liangshan School development board winter vacation training camp. Based on the Liangshan School, the RoboMaster main control expansion board is produced. Refer to the original factory [C-type board] (https://www.robomaster.com/zh-CN/ products/components/general/development-board-type-c/info) for circuit design. The expansion board expands 24V (6S battery) buck, USART, CAN, PWM, battery voltage monitoring and other functions, and can be used with the host computer to achieve visual control and other functions.
# Picture display
! [Screenshot 2023-02-13 144559.png]

![WeChat picture_20230223002400.jpg]

# Function description
##! ! The advantages of Liangshan School! !
Liangshan School has rich storage configurations, with onboard **8MB SPI flash**, **SDRAM**, **MicroSD card slot**, **dual LCD screen interface**, which has surpassed several cheap core boards. You know, the last one I used with this configuration was the STM32H7 Pi priced at RMB 300.
We are currently studying the use of these advanced extension functions to write the program with control algorithms into the external SPI flash, and at the same time, the car's configuration information can also be stored.
## For hardware design,
I tried Jialichuang’s four-layer board for the first time and had a good experience.
The patch feels great for a while, and the welding crematorium.
##
The power supply part of the 24V step-down circuit is equipped with one XT30 input and three XT30 output interfaces (24V). In order to adapt to the 6S power battery, a 24V step-down 5V~1.5A circuit (MC34063ADR2G) is designed to supply power to the core board and CAN chip through 1117_3.3 LDO; a 24V step-down 5V~3A circuit (TPS5450DDAR) is used to drive the rudder. machine, ESC, remote control receiver and other high-power equipment.
![image.png]

! Notice!
The 1.5A step-down circuit can step down the voltage by 5V, which can be used to charge mobile phones. However, it will cause power loss when the Liangshan pie is plugged in. This has not been ruled out yet. A 0R resistor is used to build two output capacitors, and the entire board is temporarily powered by 5V3A.
## ADC voltage monitoring
Voltage monitoring uses the PA1 pin, which is connected through a resistor voltage divider.
![image.png]

## USART
enables USART0 and USART1. USART1 connects to the host computer for line identification and controls the car to patrol the line.
## The DBUS receiver
car can be operated remotely and uses the DJI DT7&DR16 remote control receiving system.
The receiver uses the D-BUS protocol to communicate with the Liangshan School, which is essentially a USART, using USART2_RX (PC11). Since high level represents 0 and low level represents 1 in the DBUS protocol, an MMBT3904 inverter is added to the receiving circuit.
Setting parameters: baud rate 100Kbps, 8-bit data, even parity, 1 end bit
reference [DT7&DR16 2.4GHz](https://www.robomaster.com/zh-CN/products/components/detail/122)
! [image.png]

## The CAN bus
extended version enables CAN0 (PD0, PD1) and CAN1 (PB12, PB13), using the TJA1044GT/3Z CAN transceiver driver.
The four wheel sets mounted on the car all communicate through the CAN bus. The connector is selected from the GH1.25 series, which can realize two-way transmission of control data, send control information from the Liangshan School, and read the angle, speed, current and other information of the motor.
Note that CAN_H and CAN_L should be distributed as equal lengths as possible; if a bus already contains a 120R resistor, R21 and R22 do not need to be soldered.
![image.png]

## PWM
leads to 6 sets of PWM pins for subsequent expansion of other functional ESCs.
![image.png]

## LED
uses pin PA5 to control the LED of WS2812. The data output pin is reserved and the LED light strip can be externally expanded. ![image.png]

## Other functions lead to
I2C
![image.png]

# The program code
program is developed using MDK-ARM, and the driver is transplanted with reference to the open source C-type board routine.
The CMSIS-RTOS2 real-time operating system is enabled, and some basic codes will be open sourced in the future (after improvement).
# Summary
- I came into contact with Lichuang Training Camp in my freshman year. I walked step by step and studied (baipiao) for three years, and gained a lot.
- This work does not implement some of the functions shown in the routine, which is somewhat insufficient because these functions are not used to run on the microcontroller in my project. There is no necessary CAN bus tutorial in the learning materials, so I spent a lot of time reading the official GD materials and transplanting the driver alone, and finally achieved the desired goal. (If the Liangshan School wants to add CAN bus teaching materials, we can discuss it together)
- The actual use experience of the Liangshan School is also very good. With the self-designed expansion board, it is expected to be replaced by localization (bad smile)