GithubHelp home page GithubHelp logo

ltoscano / motor_control Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 1988kramer/motor_control

0.0 1.0 0.0 31 KB

Classes for control of a differential drive robot using PID control of DC motors

C++ 92.61% C 7.39%

motor_control's Introduction

README

Set of C++ classes for speed and position control of DC motors using quadrature 
encoders and an Arduino or similar microcontroller.

An instance of Motor provides control of the direction and voltage to a single 
DC motor by means of a motor driver such as a TB6612FNG. The constructor for 
Motor takes 3 ints as arguments: the numbers of the 2 digital pins used to 
control the motor’s direction and the number of the PWM pin used to control 
the voltage to the motor. 

An instance of Encoder reads the output of a single quadrature encoder. The 
constructor takes 3 ints and a long as parameters: the numbers of the 2 digital 
pins connected to the encoder’s outputs, the time interval used for speed 
measurements in microseconds, and the number of encoder ticks per revolution of 
the motor’s output shaft. Encoder.updateCount() must be called with an interrupt
on encoder pin A; see the example sketch for detail.

As instance of SpeedControl provides PID speed control of a single DC motor. 
The constructor takes a pointer to an instance of Motor and a pointer to an 
instance of Encoder as parameters. Uses default PID gain values of 1.0 unless 
gains are set using the SpeedControl.setGains() function. If position control 
is not required, SpeedControl can be used on its own. In this case 
SpeedControl.adjustPWM() should be called using a timer interrupt with a 
period equal to the time interval used by the Encoder object.

An instance of PositionControl provides approximate position control and 
PID speed control for a DC motor. The constructor takes a pointer to an 
instance of SpeedControl as a parameter. PositionControl.adjustPWM() should 
be called using a timer interrupt with a period equal to the time interval 
used by the Encoder object. If PositionControl is used, the 
SpeedControl.adjustPWM() method should not be used.

motor_control's People

Contributors

1988kramer avatar

Watchers

James Cloos 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.