黄土马家

[Training Camp] The decision is yours, Detective Pikachu!

 
Overview

Design ideas

What kind of sparks will come out when a mechanical dog meets Hongmeng? When I first started making a mechanical dog, I asked people around me for their suggestions on what kind of design it should look like. "It needs to be good-looking", "It needs to be smart and fun", "It needs to be able to walk", "It needs to be able to look after homes and homes", "It needs to be able to chat with me", well, after researching the demand, we found that the mechanical dog is still very interesting. , very scalable.
I just happened to catch a ride at the training camp. After thinking about it for a while, I decided to name this project: Detective Pikachu based on my love for Pi Shen. The basic functional design is as follows:
image.png
Standing on the shoulders of giants makes things much easier. In my spare time, I went through the training camp courses, and the functions are basically in place.
  • HiSilicon Hi3861 module is used as the main control, and the basic control functions can be divided into three types. Static angle control is relatively simple. The routine has an angle control API that can be called. Dynamic control is also relatively simple. Just change the array parameters. You need to study gait control and read the data to control the phase difference.
  • In terms of intelligence, I happen to have Tuya's nano development board on hand, and I have collaborated with the Lichuang community on activities before, so I can make the best use of it. In this way, it is more convenient to implement App control, and subsequent mobile phone panel development is easier. It depends on the SDK information, develop Hi3861 peripheral source code, and expand IO control or serial port control.
  • Functions such as "Looking after the home" and "Chat with me" are still a bit troublesome. The main time is limited, and the hi3861 data of the real-time audio and video transmission data of the camera has not been found. Simply use the IPC adapter board made before and connect it to the finished product.
  • As for the hardware shell, I'm not that good at it, so I just copied it as taught in the course. Of course, the leather god should use bright yellow. In subsequent revisions, corresponding design adjustments should be made to the legs.
PS. The original design was to use a gimbal for the camera. By directly connecting the gimbal's servo to the adapter board, you can directly control the dog's steering through the camera interface. The adapter board was designed, but I later discovered that the gimbal was too heavy for the mechanical dog to carry, so I had to endure my tears and replaced it with a card camera.

hardware design

PCB drawing board

I have never had the opportunity to do practical projects on Lichuang EDA before. It has been a long time since I drew my own drawing board. This time I tried it. Fortunately, I still have the foundation and passed the first draft. Give Lichuang EDA a call and save yourself the trouble of installing AD. There are not many problems when using it online. The double-layer board can be drawn smoothly and easily.
PS. I encountered some small problems in the process. Different from the PC version, there was a problem with the loading process of Google Chrome and it could not be opened. Just change the browser and it will be fine. Problems with the professional version have been reported to FAE.
Main control board:
The main control board schematic diagram is similar to the one in the tutorial. Hi3861 is used as the main control. In order to facilitate wiring and subsequent insertion of expansion boards, the PCA9685 is placed on the bottom and the expansion pins are placed on both sides of the module.
image.pngimage.png
Expansion board:
The expansion board was directly used in a previous project. I originally wanted to connect it directly to the gimbal, but the weight was too heavy. In the end, I used an IPC card machine instead. This adapter board was not used this time and is reserved for future projects. Right~
image.pngimage.png
The last expected rendering was originally intended to be like this, placed on the back of the great detective, but the back part was replaced with a card machine due to the overweight. However, when working on a project, you need to flexibly adjust according to the actual situation. After all, time is limited and there is still a lot to do ~
image.png

Hardware structure

The appearance of the hardware structure, getting started with solidworks is very similar to the previous one. After this set of procedures, it is quite rewarding. The calf spacers are very important to pay attention to. If you look carefully, you will not miss them, or they will be uneven during assembly. I have seen many students encounter this problem.
For the sake of accurate dimensions, basically all the dimensions have remained unchanged. After completing the project, it seems that the soles of the feet can be modified to increase the stress-bearing surface. Then, the size of the positioning posts that fix the board does not match the PCB 7*4cm in the course, and it needs to be modified. Fortunately, these are minor problems, and overall the process went smoothly.
image.png

Assembly and debugging

In anticipation, the boards and materials for Lichuang's one-stop service arrived. I took some time off work to start welding and debugging. Fortunately, I didn’t return the welding skills to the teacher.
image.png

image.png
There is also a small pitfall here. The purchased buttons do not correspond to the package on the PCB. They did not come up when I burned the firmware for the first time. After further investigation, I found that the level of the EN pin has been pulled low. I tested it with a multimeter and found that the buttons did not take effect. So I finally changed the direction and only soldered two contacts, and it was done.
image.png
After the burning is done, the acrylic cutting piece is in place, start assembling, and pick up the skin!
image.png
Install the legs first, then the body. Based on guesswork, I found that the screws were tightened correctly. It feels a bit like that~
image.pngimage.png
When assembling the finished product, I encountered a problem. If I look carefully at the assembly drawing and renderings, the legs are backwards. It seems that the tutorial does not correspond to the real thing. After some confusion, I followed the course video and installed it in the direction below. Facts have proved that the impact is not big, the angle determines the position, and there will be some differences in the static posture of the front and back.
image.pngimage.png
The finished product is installed, come on, show it~
image.png

software design

Environment setup

The Ubuntu tutorial provides a mirror which is more convenient and provides one-stop downloading and compilation. By the way, I also studied the python environment. I originally thought why there are two languages. After reading the program, I found that python actually transmits json data to the module, and the bottom layer still relies on C. Considering that I would like to expand the app's functions and change the underlying layer in the future, I simply tried out the Python functions. All subsequent development will be based on the C language SDK package.
image.pngimage.png

basic function

After the first burning was completed, the test found that except for the installation mode, the other modes had the same effect. After looking at the source code, it turns out that the parameters written in the routines are all the same. Normally at this step, the basic functions of the training camp should be implemented.
image.png

const char *html = "<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title> Chuanzhi Education Yuanqi Pai</title><style> body {user -select: none;text-align: center;} table {margin: 0 auto} td div {width: 150px;height: 150px;border: 1px solid darkgrey;display: flex;align-items: center;justify-content: center;color: black;} #s {background-color: red;color: white;} td div:active {background: deepskyblue;color: white;} button {margin: 0.5rem;width: 9rem;height: 3rem; font-size: 1.2rem;border-radius: 1rem;} button:hover {border-radius: 1rem;background-color: deepskyblue;color: aliceblue;}</style></head><body><h1>Hongmeng Dog control</h1><button id="a">Installation mode</button><br>





<br>
<button id="b">Stay where you are</button><br>
<br data-tomark-pass>
<button id="c">Squat</button><br data-tomark-pass>
<br data-tomark-pass>
<button id="d">Forward</button><br data-tomark-pass>
<br data-tomark-pass>
<button id="e">Back</button><br data-tomark-pass>
<br data-tomark-pass>
<button id="f">Turn left</button><br data-tomark-pass>
<br data-tomark-pass>
<button id="g">Turn right</button><br data-tomark-pass>
<br data-tomark-pass>
<script> function u(p) {return `${p}`;}function g(i) {return document.getElementById(i);}function fe(e, f) {e.addEventListener('click', function (e) {/* do something*/f();});}function fg(u, f) {let x = new XMLHttpRequest();x.onreadystatechange = function () {if (this.readyState == 4 && this.status == 200) {f(x);}};x.open("GET", u, true);x.send();}function fp(u, d, f, p) {let x = new XMLHttpRequest();if (p) {x.upload.addEventListener('progress', function (e) {p(e);});}x.onreadystatechange = function () {if (this.readyState = = 4 && this.status == 200) {f(x);}};x.open('POST', u, true);x.timeout = 45000;x.send(d);}
fe(g('a'), () => {fg(u('/dog/init'), () => {});});
fe(g('b'), () => {let data = {"type": 3, "count": 30, "list": [[74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100]]};fp(u('/dog/cmds'), JSON.stringify(data), () => {});});
fe(g('c'), () => {let data = {"type": 3, "count": 30, "list": [[74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100]]};fp(u('/dog/cmds'), JSON.stringify(data), () => {});});
fe(g('d'), () => {let data = {"type": 3, "count": 30, "list": [[74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100]]};fp(u('/dog/cmds'), JSON.stringify(data), () => {});});
fe(g('e'), () => {let data = {"type": 3, "count": 30, "list": [[74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100]]};fp(u('/dog/cmds'), JSON.stringify(data), () => {});});
fe(g('f'), () => {let data = {"type": 3, "count": 30, "list": [[74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100]]};fp(u('/dog/cmds'), JSON.stringify(data), () => {});});
fe(g('g'), () => {let data = {"type": 3, "count": 30, "list": [[74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100]]};fp(u('/dog/cmds'), JSON.stringify(data), () => {});});</script></body></html>";
It can be seen from the source code that there are only two parameter arrays [74, 111, 24, 151, 24, 151, 74, 111, 100], [24, 151, 74, 111, 74, 111, 24, 151, 100], As long as these two data are prepared, the basic control of static angle control and attitude control can be realized. There is still one gait control left. I used the provided tool to generate an array and tested it. The effect is good, but it does not feel smooth. It is far from the effect seen on the Internet and is not satisfactory.
image.pngimage.png
After reading some information about mechanical dogs on the Internet and asking friends (special thanks to Xiao Yi), I roughly understood the gait principle of the mechanical dog. As long as there is a certain phase difference between the swinging leg and the supporting leg, different gaits can be achieved. .
image.png
image.png
Based on this principle, the path of a leg is simulated. Then the long debugging process started, and the control function was simply encapsulated to distinguish it from the web side.
Finally, the basic control modes, static, dynamic, and gait, retain a total of sixteen postures. Of course, not all of them are perfectly debugged. After all, there are still many functions waiting to be scheduled~
image.pngSmart functions
As a developer in the IoT industry, the next most important thing is to add intelligent functions to the project. Depending on the needs, mobile phone control, camera screen, and speaker control can all be solved together after being connected to the cloud. The Hi3861 is connected to the cloud platform through the adapter board, and the camera is also connected to the same cloud platform to facilitate the control function of the speaker later.
image.png

image.png
The first version of the panel side was relatively weak and was built directly on the panel workbench. Later, we made an optimization and upgrade to the UI, and it looks much more pleasing to the eye.
image.png
I originally planned to change the mode names to skill names, such as lightning flash, one hundred thousand volts, etc., but I was afraid that the postures would not be correct during debugging and I would forget them, so I changed the following few.
image.png

Finished product function display

Detective Pikachu, finished product
image.png
Use your mobile phone to control the four directions and press pause to return to the initial installation state. Twelve static, dynamic, and gait patterns. You can click the button to enter the detective camera mode for patrol monitoring. The camera supports intercom function. Support Tmall Genie voice control.
Get it done and call it a day, let’s go, Pikachu!
image.png
image.png

Video link

B station video link : https://b23.tv/8AalVBd    
One of the servos was adjusted to the end and it broke. You can see that one of the legs in the gait is not that normal, but it doesn't matter.
Fortunately, there are other videos saved. For other videos, see the attachment below.

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-19 01:11:45
  • Understanding and applying digital-to-analog converters
  • I used TI's graphics driver library to make an LCD driver for the competition...
  • Questions about STM32F CAN port operation
  • Has anyone used AT45DB161D?
  • Doubts about the implementation of 2440 sleep wakeup
  • How to avoid high frequency interference?

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号