Control project for the Lift-arm. Works with ROS Melodic

Dependencies:   mbed Servo ros_lib_melodic ULN2003_StepperDriver Async_4pin_Stepper

src/motor.h

Committer:
krogedal
Date:
2021-05-27
Revision:
0:441289ea4e29

File content as of revision 0:441289ea4e29:

#ifndef KARBOT_MOTOR_H
#define KARBOT_MOTOR_H

/* Karbot motor class
 * Written by Simon Krogedal
 * 27/05/21
 * Team 9 4th Year project
 * 
 * for NUCLEO-F401RE
 * 
 */
 
 #include "mbed.h"
 
 class motor {
    
    private:
        PwmOut          output;     // PWM output pin
        DigitalOut      dir;        // direction pin
        
        double          T, dutCyc;  // Period and duty cycle variables
        bool            driving;    // flag on wheter the motor is driving or not
        
    public:
        // constructor takes 2 pins and the period
        motor(PinName pwm_pin, PinName dir_pin, double period);
        
        void drive(void);           // drives at set direction and duty cycle
        
        void stop(void);            // stops
        
        void setOut(double dc);     // set the output, number between -1 and 1
        
        double getPeriod(void);     // returns period
        
        double getDuty(void);       // returns dutycycle
};
 
 
 #endif