1098 views|2 replies

654

Posts

26

Resources
The OP
 

[DigiKey Creative Contest] Raspberry Pi Remote Control Car Work Submission [Copy link]

 

Title of the work: Raspberry Pi remote control car
Author: lb8820265

1. Introduction

DIY Raspberry Pi remote control car, the main modules used include: Raspberry Pi 4B, PicoW, Raspberry Pi CSI interface camera, MPS MEZS91202A power module, TB6612NFG motor driver. Raspberry Pi obtains camera data and then pushes the stream through RTSP, the computer receives the video data, and the mobile phone host computer connects to PicoW to control the movement of the car and the camera pan/tilt movement. The car can be used as an advanced toy and video surveillance robot.

2. System Block Diagram (Combined Graphics and Text)

The system hardware connection block diagram is shown in the figure below.

Each module is connected through a perforated board, as shown in the figure below.

The hardware connection schematic is shown in the figure below.

The hardware of the car is mainly centered on Raspberry Pi 4B and PicoW. The 3S lithium battery powers the Raspberry Pi 4B and PicoW through two MPS power modules. The Raspberry Pi 4B is connected to the CSI Raspberry Pi camera, and PicoW is connected to the servo gimbal, encoder, and motor drive module. The motor drive module is powered by the 3S battery, the MPS power module, and the PicoW control, and then connected to the DC motor. The DC motor speed information is obtained by the encoder and then fed back to PicoW, so that stable speed control can be performed. The Raspberry Pi 4B, PicoW, computer, and mobile phone are all connected to the same wireless router.

The car software mainly includes three parts, PicoW software, mobile phone host software, and Raspberry Pi 4B software. PicoW software mainly includes: UDP network communication, PWM motor control, PWM servo control, motor drive module control, GMR encoder data acquisition, mobile phone communication protocol formulation, speed control algorithm, etc. The mobile phone host software is written on the Android system, mainly including: UDP network communication, joystick control, communication protocol formulation. The Raspberry Pi 4B runs the Ubuntu Mate 20.04 operating system. Its main function is to obtain the camera data of the CSI interface, and then push the video data to the wireless router through the RTSP protocol, and then the computer side obtains the push stream through the VLC software and displays it.

4. Functional description of each part (combined with pictures and text)

(Description and explanation of the functions implemented by each part, presented in combination with pictures and text)

The functions of the mobile phone Android program, PicoW program and Raspberry Pi 4B program are explained in detail.

3.1 PicoW UDP Network Communication

The UDP initialization procedure is shown in the figure below.

The UDP communication program callback is shown in the figure below. In the callback function, the data sent by the mobile phone is received and analyzed, and the speed and distance data are sent back to the mobile phone.

3.2 PicoW PWM function module, motor and servo control

PWM is used in two places: the motor and the servo. The PWM initialization procedure is shown in the figure below.

The servo PWM control program is shown in the figure below.

The motor PWM control program is shown in the figure below.

3.3 PicoW encoder data acquisition

The encoder is used to obtain the motor speed. The encoder initialization code is as follows.

The data acquisition code is as follows.

3.4 PicoW Timer

The timer is used to control the car and the servo regularly, and control the flashing LED light. The timing is 50ms. The timer initialization code is as follows.

The timer callback function is shown in the figure below.

3.5 PicoW Control LED

The LED light of PicoW is controlled by a wireless communication chip. To control the LED, you must first initialize the communication chip. As mentioned earlier, the control of the LED cannot be performed in the interrupt function, but only in the main function. Set the flag to 1 in the timer, keep querying in while, and then flip the LED light. The code is as follows.

3.6 Android mobile phone timer and control logic

Since the Android program on the mobile phone is too large, its core code is introduced here. The control data is continuously sent in the mobile phone timer. The timer function and code are as follows.

3.7 Raspberry Pi 4B camera video streaming

The core code for obtaining camera data and streaming via RTSP is shown in the figure below.

raspivid -o - -t 0 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8090/}' :demux=h264

3.8 Obtaining video streaming data on the computer

The computer mainly obtains data through VLC software. Enter the IP address of the Raspberry Pi in the network media. The IP needs to be queried and is different for different users. Then add the port number 8090. For example, my URL address is: rtsp://192.168.31.159:8090/, and then click play.

4. Source Code

Android mobile source code: https://download.eeworld.com.cn/detail/lb8820265/630787

PicoW source code: https://download.eeworld.com.cn/detail/lb8820265/630786

5. Demonstration video of the work’s functions

Demo video link: https://training.eeworld.com.cn/video/38973

6. Project Summary

This project mainly uses PicoW and Raspberry Pi 4B purchased from DigiKey. The project is complex and difficult, involving 4 devices that need to be programmed and more than ten hardware devices. The project is very interesting and can be used to monitor robots. In the future, it can also be used for automatic driving and has strong scalability.

VII. Others

Some photos of the interface of the project's Android mobile terminal are as follows.

The car is photographed from multiple angles as follows.

The family photo is below.

digikey_iot_contest_2023_zuopindoc.doc

6.52 MB, downloads: 5

This post is from DigiKey Technology Zone

Latest reply

Yours is a bit similar to my work, but I use ESP32, and the Raspberry Pi consumes too much power.   Details Published on 2024-1-15 09:21
Personal signatureQQ:252669569
 
 

1w

Posts

204

Resources
2
 

Great! ! Thank you for your hard work

This post is from DigiKey Technology Zone
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 
 

6744

Posts

2

Resources
3
 

Yours is a bit similar to my work, but I use ESP32, and the Raspberry Pi consumes too much power.

This post is from DigiKey Technology Zone
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

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