This is the prototype of my car, which is not yet completed. I have been stuck on the servo control part, but I finally got it done today. Next, I will talk about all the parts I paid attention to and share my experience with you:
1 The microcontroller, servo, and power supply share a common ground;
2 Use two voltage regulator chips for power supply to separate the power supply;
3 The servo signal end is not directly connected to the microcontroller IO port, so I connected a 10K resistor in series. That is, after this step, I can control my servo.
I have heard many people say that the signal end can be controlled by connecting it directly to the IO port, but I have never been able to do it. Today, I connected a 10K resistor in series and unexpectedly found that I can control the servo.
So I posted this to share with you, and at the same time thank those who helped me think about it, thank you~~
Those who need a clearer circuit can leave a message, if I see that there are many people who need it, I will upload it~~~
Based on the public's request for information, then I will post my reference information~ However, these are not the circuits of my car, they are just references, you can also refer to them, but my post is mainly to share with you the problem of servo control, because I found that many people will have this question, so I will control it and post this post to communicate with you, the following is the circuit diagram of the car I referred to and a simple program, as well as
a framework for my power supply~~
(The car is being improved...)
Source program:
#include
#define uint unsigned int
#define uchar unsigned char
sbit P1_0=P1^0; //PWM signal output terminal
void Init_t0(void); //Sub-function declaration
void main()
{
P1_0=0; //Set the initial PWM output to high level
Init_t0();
while(1); //wait for interrupt
}
void Init_t0(void)
{
TMOD=0x01; //Set timer 0 to work in mode 1 and then start the TR bit
TH0=(65536-1500)/256;
TL0=(65536-1500)%256; //1.5ms high level
EA=1;
ET0=1;
TR0=1;
}
/*******************Interrupt service routine***********************/
void PWM0() interrupt 1 //Timer 0 interrupt, generate square wave
{
if(P1_0==1) //If the previous level is 1, the next low level time is 18.5ms
{
TH0=(65536-18500)/256; // Tried t1=1500; t0=20000-t1; but the servo always squeaks. I guess: the calculation takes time.
TL0=(65536-18500)%256;
}
else //If the previous level is 0, the next high level is 1.5ms
{
TH0=(65536-1500)/256;
TL0=(65536-1500)%256;
}
P1_0=~P1_0;
}
Previous article:Successfully challenged 89C52 to drive WS2812
Next article:51 MCU outputs 3-way PWM to drive RGB LED source program
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- Anti-interference technology for industrial measurement and control systems
- Technical article: The magic of energy monitoring in DC systems
- Please give me some advice on the previous interview questions.
- cc2640 details display
- [RISC-V MCU CH32V103 Review] USB flash drive read and write test
- NI Special Month, enjoy up to 40% off on software and more!
- Help: About the ESP32 Anxinke integrated environment project import compilation error
- Various PCB onboard antennas and PCB design points
- There is no more comprehensive article about RF chips than this one! Worth saving!
- Supplement: Design of the lower computer for the computer room monitoring project