In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to talk to you about how raspberry pie controls the SG90 steering gear. Many people may not know much about it. In order to make you understand better, the editor summarized the following for you. I hope you can get something from this article.
There are three wires in SG90, the red line is connected to 5V power supply and the brown line is GND. The yellow line is the data control line, which is connected to the GPIO. Here we are the GPIO17 of BCM mode.
The pulse period of SG90 is 20 milliseconds (millisecond) instead of 20 microseconds (Microsecond). The difference between the two is 1000 times. That is to say, you can turn 50 times at most in 1 second, but considering that each rotation takes time, it is actually less than 50 times. PWM control signal cycle 20ms, pulse width 0.5ms-2.5ms corresponding to the angle of-90 to + 90 degrees, range of 180 degrees (about 3 degrees deviation), when the pulse width 1.5ms, the steering gear is at the neutral point (0 degrees), we directly use the PWM control provided by python's GPIO. The duty cycle of pulse width 0.5ms-2.5ms is 2.5%-12.5%. In theory, 10% of the space can provide 180-degree linear segmentation.
The following code shows that the steering gear keeps turning from 0 degrees to 180 degrees, and then back to 0 degrees.
[python] view plain copy
#! / usr/bin/env python
Import RPi.GPIO as GPIO
Import time
Import signal
Import atexit
Atexit.register (GPIO.cleanup)
GPIO.setmode (GPIO.BCM)
GPIO.setup (17, GPIO.OUT, initial=False)
P = GPIO.PWM (175.50) # 50HZ
P.start (0)
Time.sleep (2)
While (True):
For i in range (0Jet 181, Jol 10):
P.ChangeDutyCycle (2.5 + 10 * I / 180) # set the rotation angle
Time.sleep (0.02) # wait for the end of the 20ms cycle
P.ChangeDutyCycle (0) # return to zero signal
Time.sleep (0.2)
For i in range (181meme 0mai 10):
P.ChangeDutyCycle (2.5 + 10 * I / 180)
Time.sleep (0.02)
P.ChangeDutyCycle (0)
Time.sleep (0.2)
After reading the above, do you have any further understanding of how the raspberry pie controls the SG90 steering gear? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.