Home > other >  Introduction to the steering gear
Introduction to the steering gear

Time:02-27

1. The steering gear to

Steering gear is a single-chip machine control primer will learn module, and is also used in some of the robot joints as the steering gear control, learning and mastering the use of steering gear is our further understanding of SCM,

So we can't have been limited to use development board to learn, but some electronic modules to help us more insight into the single chip microcomputer, so you need to buy steering gear,

Small steering gear and steering gear control principle of the large almost the same, in consideration of the rational use of economic, we choose a small steering gear as a primer to learn and easy to use,

Common small steering gear model for 9 g steering gear, appearance in the following

But I think this type of steering gear is cheap and everyone is widely used, but this is far from the steering gear steering gear to use metal, so I still suggest that we buy with above size but the price is a bit more expensive metal steering gear as well, this tutorial USES the steering gear model as shown in the figure below

2. The steering gear control principle

This tutorial USES the steering gear for 9 g size, type of "MG90S" as an example module,

The role of the steering Angle of 0 ~ 180 degrees, which is the steering oar can arbitrarily in a certain Angle of death, because we use brute force is difficult to break off the power supply dynamic steering oar, only after steering gear power steering oar can arbitrarily, let's twist,

Steering gear has three lines, in addition to the power supply of two power cord and a signal lines, because we are using the 5 v voltage of the power steering gear, so its power can be directly to the MCU + 5 v &gnd, signal lines, it received a microcontroller IO port, the I/o port through output PWM control the Angle of the steering oar stay fixed on any position,

The PWM cycle of 20 ms, high level of time between 0.5 ~ 2.5 ms ms can control the steering oar Angle position,

0.5 -- -- -- -- -- -- -- -- -- ms 0 degrees,

1.0 ms -- -- -- -- -- -- -- -- -- 45 degrees,

1.5 ms -- -- -- -- -- -- -- -- -- 90 degrees Fahrenheit,

2.0 ms -- -- -- -- -- -- -- -- -- 135 degrees Fahrenheit,

2.5 ms -- -- -- -- -- -- -- -- -- 180 degrees Fahrenheit,

We put steering gear power cords and P1.7 signal wire connection, download the code, the steering oar after electricity will rotate to the position of a fixed Angle stay in that, we'd like to twist the steering oar is relatively hard,
3. Code
#include
#include //as shown in the sixth chapter 8 speak
#include //see chapter 8 of the 11 speak
Sbit PWMOUT=P1 ^ 7;//servo signal pin

Void main ()
{
LED_Init ();//initialize the LED hardware module
EA=1;//closed always interrupt switch
TIM0_Init (100, 9);//time 0.1 ms, 9 is fine tune the timing precision higher
while(1);
}

Void TIM0_IRQHandler () interrupt 1
{
The static u8 PWM=0;
TH0=T0RH;//reload the reload value
TL0=T0RL;

Pwm++;
If (pwm>=200) PWM=0;//PWM interval between 0 ~ 199 ms 0.1 change, cycle of 20 ms

If (pwm<10) PWMOUT=1;//high level in the PWM cycle of 20 ms duration of 1 ms, the duration of the low level is 19 ms, the position of the steering oar at 45 degrees to stay fixed
The else PWMOUT=0;


we draw waveform figure


Power cuts after we twist the steering oar to another Angle position, and then to electricity, to observe the experiment phenomenon of steering oar to understand the working principle of the small module,
  • Related