[Micropython]TPYBoard v10x drive servo tutorial

 

The last post briefly introduced the small experiment of TPYBoard plug-in programming. Today, I tried to test whether it can control the steering gear. I operated it myself. The biggest disadvantage of plug-in programming compared to typing code is that the efficiency is reduced. It's because I'm not proficient, but for those who are just getting started, it's much easier. Next is the experiment of controlling the steering gear. 1. Specific requirements

    The servo is controlled by the change of the X-axis value in the acceleration sensor on the TPYBoardv10x development board, so that the servo rotates with the rotation of the TPYBoard development board.

2. Required devices

    A TYBoard development board

    One USB data cable

    one steering gear

    Several Dupont lines

3. Basic introduction of steering gear

    The composition and parameters of the steering gear

    A steering gear, also known as a servo motor, is an electromechanical structure with a closed-loop control system. The steering gear is mainly composed of a casing, a circuit board, a coreless motor, a gear and a position detector. Its working principle is that the controller sends a PWM (pulse width modulation) signal to the steering gear, which is processed by the IC on the circuit board to calculate the rotation direction, and then drives the coreless motor to rotate, and transmits the power to the swing arm through the reduction gear. At the same time, the position detector (potentiometer) returns the position signal to determine whether the set position has been reached. Generally, the steering gear can only rotate 180 degrees.

 

    Servo wiring

    The servo has 3 wires, brown is the ground, red is the power positive, and orange is the signal wire, but the colors of the wires may be different for different brands of servos.

    The control principle of the steering gear

    The angle of rotation of the steering gear is achieved by adjusting the duty cycle of the PWM (pulse width modulation) signal.

Ø Duty cycle

        1. Refers to the time ratio of the high level in one cycle.

        2. The ratio of the duration of the positive pulse to the total period of the pulse. For example: a positive pulse width of 1 μs and a pulse train with a signal period of 10 μs have a duty cycle of 0.1. That is: the width of the pulse divided by the period of the pulse is called the duty cycle. The period of the standard PWM (Pulse Width Modulation) signal is fixed at 20ms (50Hz). In theory, the pulse width distribution should be between 1ms and 2ms. However, in fact, the pulse width can be between 0.5ms and 2.5ms. The rotation angle of 0°~180° corresponds.

 

3. The main process of production

    Video effect link: [media=x,500,375]http://v.youku.com/v_show/id_XMTY1MzE5ODIyOA==.html[/media]
4. Production process

Graphic code:

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324933086&siteId=291194637
Recommended