Announcement

Collapse
No announcement yet.

Controlling a Servo...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Controlling a Servo...

    I'm trying to figure out how to control a small servo.

    I've got everything connected and I'm able to get HS3 to move the servo arm to move using HS3 but I don't know how to adjust the distance/direction the arm travels. Currently the arm moves only a tiny amount and in only one direction.

    I've tried raising the pulse duration in RaspberryIO Config with no change in the way it works.

    How do I get the servo to move farther?

    Thanks.

    #2
    Specifications on servos vary, but generally servos move by receiving a pulse at a consistent frequency, but with varying duty cycles. This signal control is known as pulse-width modulation (PWM). The pulses and their width (in the tens of millisecond range) control the degree of rotation of the servo. (see diagram and this: https://electronics.stackexchange.co...ith-pwm-signal)

    The pulse on the RaspberryIO is designed as a one-shot momentary contact, so it's effective as an automatic off a short duration after an on command, but while the pulse width can be set, it doesn't repeat in a way necessary to act as PWM. Unfortunately, this means you're not going to be able to directly control the servo from HS3 using RPIO.

    The twitch you're seeing is the servo reacting to the one pulse, but PWM would need something like 50-100 per second with reasonably precise control and consistency on when the pulse starts as well as how long it is. If it isn't consistent, the servo will jiggle or make noise. HS3 and RPIO are not designed for that kind of control application.

    Setting aside the HS3/RPIO part, the RaspberryPi can have software control the IO pins to emulate PWM signals, but that is not a feature enabled by RPIO. If you got that working independently, it might be possible to build an API interface so you can send a web-command via the network to a Rpi to tell it what you want the PWM to be, and as a result how the servo should be positioned. Even software PWM on the RPi is not an ideal servo controller, but it works for the most part. The best solution is to use a dedicated servo controller board, then find a way to run that with the RPi or more directly from HS3.

    The only way I can think of to get HS3 to control a servo using RPIO, would be to use the GPIO pins that HS3/RPIO can control simply as flags that signal a PWM program running on a RPi to send out the right signal to move to a preset position. I don't know that you can have both a native program running on the RPi and RPIO software both controlling the GPIO pins, even if they're not attempting to control the same pins. It depends how both pieces of software are written, and the RPi's isolation of GPIO pin control.

    The bottom line is, if you've got a servo control program on RPi using PWM, you'd be better off with an API that let's it know what servo position you want, and talk to that using web commands sent by HS3 without the need for RPIO.

    Comment


      #3
      Wow dzee thanks for the comprehensive answer. I've spent the last 24 hours or so trying control the servo directly through the Pi but I've reached the end of my programming experience. Even without this feature I'm pretty excited to dig into this plugin and put it to use in my home.

      Thanks again.

      **fingers crossed for this ability being added to RPiIO.**

      Comment


        #4
        Other microcontrollers handle servos nicely. I have done this with ESP8266. The ESP32 has actual hardware PWM channels. I use Tasmota firmware installed on the ESP controllers. and interface to HS with mcsMQTT plugin. These devices are dirt-cheap and interface via WiFi. There is a related thread at https://forums.homeseer.com/forum/ro...-servo-control where I describe the servo interface to HS with these devices.

        Comment


          #5
          Ironzey, I just got back to this post and saw your last comment. One thing we didn't discuss is what it is that you're interested in controlling with the servo. Is it something fairly light weight and easy to move, or something that would require more torque, like for example, a water valve?

          Comment


            #6
            Originally posted by dzee View Post
            Ironzey, I just got back to this post and saw your last comment. One thing we didn't discuss is what it is that you're interested in controlling with the servo. Is it something fairly light weight and easy to move, or something that would require more torque, like for example, a water valve?
            Lightweight I just want to raise a little flag that says mail. I had some 9g servos laying around and thought I could use them for this.

            Comment

            Working...
            X