An article analyzing 51 microcontroller PWM dual servo control

Publisher:春水碧于天Latest update time:2023-08-10 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  Introduction to PWM

  Pulse width modulation is a very effective technology that uses the digital output of a microprocessor to control analog circuits. It is widely used in many fields from measurement and communication to power control and conversion.


  Pulse width modulation is an analog control method that modulates the bias of the transistor base or MOS tube gate according to changes in the corresponding load to change the conduction time of the transistor or MOS tube, thereby achieving the output of the switching regulated power supply. Change. This method can keep the output voltage of the power supply constant when the working conditions change. It is a very effective technology for using the digital signal of the microprocessor to control the analog circuit.


  What is a steering gear

  The steering gear is a position (angle) servo driver, suitable for control systems that require the angle to continuously change and be maintained. The steering gear is a large deck machinery on the ship.

  This article mainly introduces the 51 microcontroller PWM dual servo control. Follow the editor to learn more about it.


  Detailed explanation of 51 microcontroller PWM dual servo control

  The steering gear used - Shenghui SG90 steering gear (standard version)

  

  The working principle of Shenghui SG90 steering gear

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  First, there is a reference voltage inside the steering gear. If we want to control the rotation of this servo. Then we have to give it a certain period of DC bias voltage through a certain signal line.

  Finally, the servo will internally compare the DC bias voltage with the internal reference voltage to obtain a voltage difference output. Finally, the positive and negative voltage difference is output to the motor driver chip to determine the forward and reverse rotation of the motor.

  After such a simple description, we roughly know how to control the forward and reverse rotation of the steering gear.

  Let's find out what kind of periodic DC bias voltage should be given to it?

  Let’s take a look at the concept of duty cycle (picture):

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  As shown above: duty cycle = t/T;

  To control the servo, we need a period T = 20ms. The high level small t is equal to such a square wave between 0.5ms-2.5ms.

  Why is this parameter?

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  Through the above basic conceptual knowledge, we have roughly understood the working principle of the steering gear. Next, let's take a look at how to use C51 microcontroller PWM to adjust and control it.

  for T = 20ms. We can count with timer 0 (mode 1). 0.1ms each time. If the count reaches 200, it means that a cycle has arrived and the count is cleared to 0.

  Replenish:

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  For t = 0.5ms—–2.5ms we can use global variables. Let the global variable be equal to 5-25, because a counting period of my servo is 0.1ms, so the 5-25 of the global variable is exactly 0.5ms-2.5ms

  With this correspondence, the program becomes simple:

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  An article analyzing 51 microcontroller PWM dual servo control (with program)

  An article analyzing 51 microcontroller PWM dual servo control (with program)


Reference address:An article analyzing 51 microcontroller PWM dual servo control

Previous article:Use 51 microcontroller and DS1302 clock chip to make a simple electronic clock
Next article:Design of RC measurement system based on 555 timer and microcontroller

Recommended ReadingLatest update time:2024-11-16 08:31

STM8S timer 1 implements PWM function
TIM1 consists of a 16-bit auto-reload counter driven by a programmable prescaler and can be used to output PWM waveforms. The PWM mode of TIM1 can generate a signal with a frequency determined by the TIM1_ARR register and a duty cycle determined by the TIM1_CCRi register. TIM1 consists of 4 independent capture/com
[Microcontroller]
STM8S timer 1 implements PWM function
The principle of using PWM output to drive a brushed DC motor
In addition to being used for motor driving, PWM (Pulse Width Modulation) is also widely used in power conversion of power supplies such as DC/DC converters and AC/DC converters, and is widely used in many fields. In principle, PWM is a method of sending the required power by turning pulses on and off. The size and
[Embedded]
The principle of using PWM output to drive a brushed DC motor
What are the control methods of PWM control?
The basic principle of PWM control (pulse width modulation) The control method is to control the on and off of the switching devices of the inverter circuit so that a series of pulses with equal amplitude are obtained at the output end, and these pulses are used to replace the sine wave or the required waveform
[Embedded]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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号