当前位置:网站首页>How to make your own robot
How to make your own robot
2022-07-06 00:28:00 【acktomas】
How to make your own robot
Device Plus The editorial team
2016 year 5 month 23 Japan
How to use with Arduino The stepping motor of components and sensors is 2 Make your own robot on wheels :
Once you know the basics of using stepper motors , You can create some interesting projects , You can even make your own robot . This time, , I will try to build a 2 Wheel robots .
On top In an article , Use Arduino Control motor - Use servo motor for steering Make a remote control car , We made a remote control car , Among them, ordinary motor provides forward / Backward movement , The servo motor controls the steering .
In this 2 Wheel robot , forward / Backward movement and rotation can be accomplished by two motors placed side by side . You often see this 2 Robot with wheelbase as motion source . I want to make something with this versatility .
Make your own robot with this electronic construction recipe
About time :90 minute
Parts needed
- Arduino UNO R3
- 42mm Stepper motor 12V x2
- L6470 Stepper Motor Driver Kit
- L6470/42x34mm Stepping motor screw set ( Japanese version )
- 5mm Universal mounting base ( A set of 2 individual )
- 006P 9V Battery holder
Design of two wheeled robot
chart 1 – by 2 Wheel robot modeling
First , You need to think about 2 Complete design of wheeled robot . If there is 2 A motor , You can make one with a simple design 2 Wheel robots .2 A motor that rotates in the same direction provides forward / Move backward , Reverse rotation provides rotational capacity . This point , That is, basic motion control can be easily realized by using two motors , This has been adopted in many fields . Let's measure the dimensions of the stepping motor and other components to be used , And make a fuselage matching this size .
I use 3D The parts of the printer can be found here .
chart 1 Use free modeling software “123d design”, It shows that I'm right 2 The idea of a simple design of a wheeled robot body . I'm thinking about using a round piece of wood as a base , And set the stepping motor 、Arduino And battery connected to it . Because the two wheeled robot may eventually overturn forward or backward , So I will install a small ball caster on the back of the board as a support .
Determine the size of the wheel , Please place the stepping motor in the figure 1 On the round wooden block shown , Then measure the height from the floor . To that height , Add casters floating a little + 2-3mm The height at the time , You get the diameter of the wheel .
chart 1 3D Circular plates and wheels produced by printers
chart 2 Support ball casters
Besides , I simulated the part that locks the stepper motor to the board . There are four on the shaft side of the stepping motor 4mm Screw holes , So I made a part , They can be used to lock the circular plate to the stepper motor .
chart 2 The part that fixes the stepping motor on the circular plate
chart 3 3D Parts printed by printer
once 3D The printer produces parts , I installed the stepping motor and confirmed the size . It fits perfectly .
chart 4 – Parts assembly
Connect the driver to the stepper motor .
Because all components are installed on the 12 Cm board , So we need to use space as carefully as possible . Due to the stepper motor driver L6470 The position and size of the board and screw hole are the same as that of the surface of the stepping motor , I can screw the driver to the back of the stepping motor . By doing so , I can save a little space .
chart 5 – Temporarily remove the screws and install the drive board .
chart 6 – The drive plate on the back of the stepper motor
Use Arduino Circuit for driving two stepping motors
before , We only drive one stepper motor . This time, , We need to drive two stepper motors . Use a method called daisy chain ,L6470 It can control multiple stepping motors .
Chrysanthemum chain It's a kind of Wiring scheme , Among them, several devices are connected together in sequence or in a ring . In addition to the complete single circuit , A system that contains internal loops cannot be called a daisy chain .
And L6470 The circuits required to perform the daisy chain are as follows . Because there are many wires , Please be careful not to make mistakes when wiring .
chart 3 – Connect the circuit of two stepping motors
The difference from the circuit with only one time is , The first and second stepper motors now have a component that connects them . use L6470 After the data sheet is confirmed , The first stepper motor is connected to SDO, The second stepper motor is connected to SDI. Send and receive data through this part .
chart 4 – L6470 Sketch Map
Conclusion
After the circuit wiring is completed , I want to say it's time to start the programming part , However, the procedure for processing multiple stepping motors may be a little complicated , It may be wise to step back and learn more about stepper motor programming . If all goes well , The two stepper motors will be synchronized as in the following video .
How to make your own robot ( The first 2 part )
Device Plus The editorial team
2016 year 5 month 24 Japan
How to be in 2 Make your own robot on wheels , Use a Arduino Stepper motors for components and sensors …… The first 2 part
In the 1 In the part , We Use the library to drive the stepping motor . This time, , We will study stepper motor programming in more detail and learn how to control it , Problems encountered when dealing with stepper motors , And some solutions .
Electronic building formula
About time :90m
Parts needed
- Arduino UNO R3
- 42mm Stepper motor 12V x2
- L6470 Stepper Motor Driver Kit
- L6470/42x34mm Stepping motor screw set ( Japanese version )
- 5mm Universal mounting base ( A set of 2 individual )
- 006P 9V Battery holder
Stepper motor comments
chart 1 – Stepper motor and L6470
In this article, I will review how to control stepping motor by programming . It can be seen from the following characteristics , Compared with ordinary motor and servo motor , Stepper motor is unique in that it can control rotation .
- The motor : Rotate when powered on
- Servo motor : Corresponding to a signal in 0 To N Rotate within degrees
- Stepper motor : It can be controlled without signal limitation
Besides , When you actually control the motor, you send PWM The signal . in other words , If you will Arduino Directly connected to the stepper motor , Control will be difficult . So usually , For things like Arduino Such a microcontroller , You will want to control the stepping motor through the motor driver , This makes various types of control possible .( Information about handling common motor drives , see also #12.)
This time it was used L6470 Stepper motor driver is cheap and has on-board control / Oscillator circuit , Used to detect stepping motor 、DSP And communications I/F Over current . Basically , When you try to control the rotation or power of the motor or need precise movement , You need to choose a motor driver with the following functions and capabilities to complete your circuit .
[](http://www.rohm.com/web/global/search/parametric/-/search/Stepping Motor)
[ Stepper motor driver directory – ROHM](http://www.rohm.com/web/global/search/parametric/-/search/Stepping Motor)
Because I want a product that is easy to use and cheap , So what I use is L6470. however , Last and previous time , When I try to drive the stepper motor , I expect it to rotate . contrary , I only have noise and vibration , But the shaft doesn't rotate . I want to know if I have done anything to make it strange ?
Stepper motor “ Out of step ” The phenomenon
When using stepping motor , You often encounter out of step . In short , Out of step means that the actual motion of the stepping motor cannot keep up with the rotation control signal , The expected rotation position of the motor driver is out of alignment with the actual position of the stepping motor , As a result, synchronization is lost and the motor does not rotate .
There are many reasons for jumping out . Driving a stepper motor as described below usually causes it .
- Sudden acceleration or deceleration stepping motor
- The timing of sudden acceleration and deceleration brings the possibility that the signal is not synchronized with the motor . In these cases , First, gradually accelerate / Slowing down will eliminate this possibility .
- Insufficient torque
- If the motor does not have enough torque ( Rotating power ), Out of step may occur . under these circumstances , You must switch to a motor with the required torque .
- The driving voltage is low / unstable
- If the drive voltage is low / unstable , This may lead to out of step .L6470 Specifications 8V-45V, But in 8V Be careful when running under .
- The influence of vibration
- If vibration is applied to the motor , It may lead to out of step .
Generally speaking , When out of step occurs , All the above reasons are possible , But sudden acceleration or overspeed caused by insufficient torque is the most common reason . therefore , If your stepping motor fails , These reasons are worth investigating .
In addition, Yifa semiconductor sells L6470 Of , There are detailed instructions , You can also refer to it .
Program the stepping motor
Now? , Let's delve into the theme of this article , Stepper motor programming . To pass through L6470 from Arduino Control stepping motor , You must be right about l6470 Program to send control signals . The circuit is as follows .
chart 1 – Connect Arduino、L6470 And stepping motor circuit
Stepper motor control program flow
The following is the step motor program . We will now read the flow of this program .
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 | #include <Arduino.h>#include <SPI.h> //(1) Import for SPI transmission //(2) Define the stepper motor pin#define PIN_SPI_MOSI 11#define PIN_SPI_MISO 12#define PIN_SPI_SCK 13#define PIN_SPI_SS 10 void setup(){ delay(1000); Serial.begin(9600); //(3) Initialize the stepper motor pin pinMode(PIN_SPI_MOSI, OUTPUT); pinMode(PIN_SPI_MISO, INPUT); pinMode(PIN_SPI_SCK, OUTPUT); pinMode(PIN_SPI_SS, OUTPUT); digitalWrite(PIN_SPI_SS, HIGH); //(4) SPI signal to commence SPI transmission SPI.begin(); SPI.setDataMode(SPI_MODE3);// When SCK is high, send/receive data, when idle, set pin to HIGH SPI.setBitOrder(MSBFIRST);// Transmission from MSB //(5) L6470 settings L6470_setup();} //**********************************************//(6) SPI transmission method//void L6470_send(unsigned char value){ digitalWrite(PIN_SPI_SS, LOW); SPI.transfer(value); // Send control signal via SPI transmission digitalWrite(PIN_SPI_SS, HIGH); } //// (7) L6470 setup//void L6470_setup(){ // Device settings L6470_send(0x00); L6470_send(0x00); L6470_send(0x00); L6470_send(0x00); L6470_send(0xc0); //Set maximum revolution speed L6470_send(0x07);//register address L6470_send(0x20);//value(10bit),default 0x41 //Voltage setting when motor is idle L6470_send(0x09);//register address L6470_send(0xFF);//value(8bit),default 0x29 //Voltage setting when motor rotating at constant speed L6470_send(0x0a);//register address L6470_send(0xFF);//value(8bit),default 0x29 //Voltage setting when accelerating L6470_send(0x0b);//register address L6470_send(0xFF);//value(8bit),default 0x29 //Voltage setting when decelerating L6470_send(0x0c);//register address L6470_send(0xFF);//value(8bit),default 0x29 //full step, half step,1/4,1/8,…,1/128 step setting L6470_send(0x16);//register address L6470_send(0x00);//value(8bit} //// (8)Main process - loop()//**********************************************void loop(){ //360 degrees - Turn one complete revolution L6470_send(0x50);// Run(DIR,SPD),0x51:Forward,0x50:Reverse L6470_send(0x00); L6470_send(0x20);// Rotation speed settings L6470_send(0x00); delay(1604);// Turn 1 time every 1604ms L6470_send(0xB8);// Hard stop} |
---|---|
Control signals —— About SPI transmission
First ,L6470 and Arduino The control signals between are exchanged by calling SPI transmission ( Serial peripheral interface ) Method . such SPI Transmission is used in Arduinos and IC Chips and other microcontrollers exchange signals .
On the second line of the program (1) Of “#include SPI.h” Expression , I'm going to Arduino Upper use SPI transmission . When using the library , Please remember these “#include <***.h>” Expressions always exist .
Next , stay (2) in , I set up L6470 Pins used . ad locum , You can see the written MOSI and MISO. These are SPI The basic signal line used for transmission .
stay SPI In transit , The signal line consists of 3 There are four basic elements ( Use SS When the signal is 4 Elements ). Each signal line has a specific clock (SCK)、 The output signal (MOSI:Master Out Slave In) And input signals (MISO:Master In Slave Out). During actual transmission , The communication arrangement is Arduino Output standard clock signal (SCK), Then with L6470 Use it together In and Out(MISO and MOSI) The connection transmits data back and forth .
- SCK—— The serial clock
- MISO – Main in and out
- MOSI – The main out comes from the in
- SS – Slave selection
stay (3) in , Set the pin mode of the signal line used . Next , stay (4) in , Set the... To use SPI transmission mode . The device being connected determines the mode .
once SPI Transmission preparation is complete , stay (5) in , We can finally use SPI Transfer and start L6470 Set up . Actually send SPI The part that transmits the signal is (6) L6470_send() How to write a function .
It's going on L6470 When setting , Please set the required elements according to the specifications recorded in the data sheet and manual .
When you view the contents of the data table , You will see the following command address table . This time because we use 12026 The motor , So pass SPI The transfer sends the register address recorded in the table to initialization L6470.
As an example of how to use tables in programming :
123 | //Highest revolution speed settingL6470_send(0x07);//register addressL6470_send(0x20);//value(10bit),default0x41 |
---|---|
The above is the code . If we were “ Maximum speed ” View in the table of function row , The address is “0x07”, The length is “10” position , The initial value is “0x20”( With 12026 Model as an example ). adopt SPI Transmit the values in the transmission table , You can make various settings .
surface 1 L6470 Data sheet .
Once the initialization is complete , stay (8) Find the actual command to drive the stepping motor in the main process . You can see the various commands recorded in the data table again .
- Rotation command
0x51( Positive rotation )、0x50( reverse ) - stop it ( soft ) command 0xB0
In this example , Send forward or reverse rotation command , And then there was 20 Bit rotation speed command , Then there is the delay (1604). This makes it rotate during this time . If you change this speed value , It can accelerate or decelerate .
This is the use of Arduino adopt L6470 The process of driving the stepping motor . in addition , Corresponding to this , By changing some connection methods , It can control multiple stepping motors as introduced last time .
Let's try driving a two wheeled robot
Now we know the programming function flow of stepping motor , Let's finish 2 Wheel robots . I used in my last article 3D The printer completes the printing of wheels and body , The necessary components will now be installed on the body , So you can make your own robot completely .
chart 2 – All the parts needed to make your own robot are installed on your body
Installed Arduino、 Bread board and for stepping motor (2 Series ) Of 9V After battery , There is little room left …… Oh dear .
therefore , I didn't use it Arduino UNO, Instead, try to replace it with Arduino Pro Mini.
chart 3 – Use Arduino Pro Mini, Perfect !
chart 4 – It is installed neatly on the bread board
chart 5 – The wheel is firmly mounted on the shaft , So it won't slip
After installing all components , We can finally turn on the power and try to drive it .
Useful ! In the video , A step motor is connected 12V Adapter . When I connect 9V Battery time , They are a little too heavy , I noticed that the stepping motor didn't have enough torque . under these circumstances , If it's too heavy , As I described before , You can replace the motor itself , Reduce weight , Or further improve the power supply to make stable operation possible .
Conclusion
This time, , We use stepping motor to make your own robot on two wheels . Movement occurs in code . When you make your own robot , You can add other things , For example, install light sensors on each side , Make a robot that moves towards the brightest light , Or a robot moving towards sound , Even a robot that can be driven by a smart phone passes through the previously introduced ESP- WROOM -02 Use WIFI signal communication . Various applications are possible . I may try to introduce some improvements in subsequent Posts .
The next time , I think I'll make a device that uses magnetic sensors or other cool things .
边栏推荐
- 【DesignMode】装饰者模式(Decorator pattern)
- LeetCode 1598. Folder operation log collector
- Global and Chinese market of digital serial inverter 2022-2028: Research Report on technology, participants, trends, market size and share
- Opencv classic 100 questions
- 【DesignMode】适配器模式(adapter pattern)
- Global and Chinese market of valve institutions 2022-2028: Research Report on technology, participants, trends, market size and share
- Common API classes and exception systems
- Leetcode:20220213 week race (less bugs, top 10% 555)
- 2022-02-13 work record -- PHP parsing rich text
- Global and Chinese market of water heater expansion tank 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
How to use the flutter framework to develop and run small programs
Leetcode 450 deleting nodes in a binary search tree
Huawei equipment configuration ospf-bgp linkage
How to solve the problems caused by the import process of ecology9.0
Problems and solutions of converting date into specified string in date class
FPGA内部硬件结构与代码的关系
XML配置文件
Atcoder beginer contest 258 [competition record]
Spark AQE
notepad++正则表达式替换字符串
随机推荐
LeetCode 1189. Maximum number of "balloons"
数据分析思维分析方法和业务知识——分析方法(三)
权限问题:source .bash_profile permission denied
【线上小工具】开发过程中会用到的线上小工具合集
Atcoder beginer contest 254 [VP record]
FFMPEG关键结构体——AVFormatContext
MDK debug时设置数据实时更新
Tools to improve work efficiency: the idea of SQL batch generation tools
《编程之美》读书笔记
Arduino六足机器人
Spark AQE
7.5 simulation summary
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot system behavior analysis and project summary (4
Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
The relationship between FPGA internal hardware structure and code
[designmode] Decorator Pattern
Extracting profile data from profile measurement
Solve the problem of reading Chinese garbled code in sqlserver connection database
Determinant learning notes (I)
Leetcode 450 deleting nodes in a binary search tree