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

Dependencies:   mbed Servo ros_lib_melodic ULN2003_StepperDriver Async_4pin_Stepper

Revision:
0:441289ea4e29
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/motor.h	Thu May 27 18:36:23 2021 +0000
@@ -0,0 +1,40 @@
+#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
\ No newline at end of file