In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Most people don't understand the knowledge points of this article, so Xiaobian summarizes the following contents for everyone. The content is detailed, the steps are clear, and it has certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article.
The steering gear has three main advantages:
First, compact size, easy to install; second, large output torque, good stability; third, simple control, easy to interface with digital systems.
SG90 servo is used in this tutorial, personal feeling performance is general, but more stable and durable, DIY experimental equipment is still relatively good.
Basic introduction of steering gear
Steering gear, also known as servo motor, is an electromechanical structure with closed-loop control system. Steering gear is mainly composed of shell, circuit board, coreless motor, gear and position detector. Its working principle is that the controller sends PWM (pulse width modulation) signal to the steering gear, which is processed by 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 judge whether it has reached the set position. Generally, the steering gear can only rotate 180 degrees. (Tpyboard). com)
Steering gear wiring
The steering gear has 3 wires, brown for ground, red for power positive, orange for signal wire, but different brands of steering gear, the color of the wire may be different.
Control Principle of Steering Gear
The angle of steering gear rotation is achieved by adjusting the duty cycle of PWM (Pulse Width Modulation) signal.
duty cycle
1. The percentage of time that a high level occupies in a cycle.
2. The ratio of the duration of a positive pulse to the total pulse period. For example, a pulse train with a positive pulse width of 1μs and a signal period of 10μs has 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 standard PWM (pulse width modulation) signal has a fixed period of 20ms (50Hz), and theoretically the pulse width distribution should be between 1ms and 2ms, but in fact the pulse width can be between 0.5 ms and 2.5 ms, and the pulse width corresponds to the steering angle of 0°~180°. (Tpyboard). com)
Python language driving steering gear method
In fact, all of these are to introduce you to the use of Python language to control the rotation angle of the steering gear, and the same as ordinary single-chip microcomputer, are required to use different widths of pulses to control the rotation angle. To put it bluntly, all we need to do is use Python language to output pulse signals of different widths to the signal lines. Now the general servo pulse width is between 0.5ms and 2.5ms, which can be calculated. 0.5MS-2.5MS can be controlled to rotate to 180 degrees in these two milliseconds. In this way, the pulse time of one degree rotation is about 2 milliseconds/180 degrees =0.011 milliseconds/degree. The rest is to write a pulse signal, and I believe that everyone is familiar with the program of writing pulse signals. However, there are some millisecond delay pulses in the servo, which in Python language if you want to use the delay() function to delay, it is difficult to do every angle can be turned, even difficult to do to most of the angle. So, you need to find a delay function that is more accurate than the millisecond delay as the timing delay function of the pulse. I'm using the function time.sleep(i) and I suggest setting i in this function between 0.0000 and 0.0035. It can't be said that it can be rotated to every angle exactly, but 90% of the angles can be rotated. If you want to make the steering gear cycle swing, you must remember to add appropriate delay, because the program can run quickly, but the steering gear rotation also takes a little time. The steering gear must take much longer to turn than it does to run through the program. (Tpyboard). com)
experimental purposes
Control the steering gear rotation through X direction of acceleration sensor, so that steering gear rotates with TPYBoard rotation
experimental materials
TPYBoard v10x development board 1 piece
SG90 1 steering gear
Some Dupont Lines
experimental circuit diagram
The circuit diagram here is very simple, just need to connect VCC and GN to the servo (this is the most basic, many power and ground on this development board can be used). Then connect the signal line of the servo to any GPIO port (later in the program to output pulses in this GPIO, I used X1, there are many other GPIO ports can be used). That's it. Wiring schematic diagram:
import pybimport timefrom pyb import Pinxlights = (pyb.LED(2), pyb.LED(3))ylights = (pyb.LED(1), pyb.LED(4))M0 = Pin('X1', Pin.OUT_PP)accel = pyb.Accel()i=0.0001j=0.0000while True: x = accel.x() print("x=") print(x) Y=x+20 M0.high() time.sleep(i*Y) M0.low() time.sleep(i*Y) pyb.delay(12) if x > 0: xlights[0].on() xlights[1].off() elif x < 0: xlights[1].on() xlights[0].off() else: xlights[0].off() xlights[1].off() The above is about the content of this article, I believe everyone has a certain understanding, I hope the content shared by Xiaobian is helpful to everyone, if you want to know more related knowledge content, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.