Giter Club home page Giter Club logo

rpiservo's Introduction

RPi Servo controller

Author : Brydon Gibson + [the internet]

Feel free to file pull requests/bug reports if you find anything wrong with this class.

This is a class to control a servo on a raspberry pi 3. It should work on a rpi2 but it is untested. Connect the signal pin (the white/light brown wire) to the GPIO pin sent to the constructor of this class. Pinouts for the RPi can be found online. Make sure to power the servo appropriately, most don't have reverso polarity protection and most cannot handle more than 5 volts.

A servo works by reading the length of a rectangular pulse, at 50Hz. A 2000us high pulse moves the servo all the way one way, and a 1000us pulse moves it all the way the other way. Due to rounding (PULSE_RATIO), the servo does not actually get a 2000us pulse at 180 degrees. Most servos don't actually move a full 180 degrees either. You can send most servos down to 900us and up to about 2100us, and they might move a little further. If the servo is shaking a lot, please shut it off, they have no temperature protection and might melt themselves.

Multithreading

This class was intended to be run in its own thread, and should be started as such. Example:

Servo myServo = new Servo("24");
new Thread(myServo).start();
myServo.increment_angle();
... etc

Be careful when adding things to this class, long prints or long operations on this thread (in the functions) will cause the servo to shake and be inaccurate (see PWM jitter). It is best to leave this thread as is and do most operations on another thread.

A note for passive applications

most servos will shut off when the signal pin is pulled low or floating (ie no signal), this is useful for saving power (and prolonging the life of the servo) if the servo is going to remain in the same position for a long period of time

rpiservo's People

Contributors

packocrayons avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.