A fork of a fine man's work. simplified. No microstepping etc, just a work in progress

Fork of BipoarStepperMotor by Harsha vardan

Committer:
InBrewJ
Date:
Tue Feb 03 03:41:10 2015 +0000
Revision:
5:f9404f00deda
Parent:
4:a3d8d60147dd
A bit of a restructure, motor position tracking is now in this class, not inside the main function. Now includes a "setMotorPosition" for if the stepper initialisation is skipped. The motor enable pin is now encapsulated within here too

Who changed what in which revision?

UserRevisionLine numberNew contents of line
XtaticO 0:4b3b9e047ce3 1 /*
Harshavardan61 1:d40368fd071e 2 ##############################################
InBrewJ 4:a3d8d60147dd 3 ##Original Program Created by Harshavardan61##
Harshavardan61 1:d40368fd071e 4 ##############################################
Harshavardan61 1:d40368fd071e 5 ---- harshavardan61@gmail.com -----
InBrewJ 4:a3d8d60147dd 6 Extended by Jason Brewer 2015
InBrewJ 4:a3d8d60147dd 7 to adapt to the stepper motor + linear actuator
InBrewJ 4:a3d8d60147dd 8 supplied by Selim Yilmaz
XtaticO 0:4b3b9e047ce3 9
InBrewJ 5:f9404f00deda 10 Now includes functional stepper pulses, a motor enable pin
InBrewJ 5:f9404f00deda 11 (motor and l293D were getting very warm if the enable pin was
InBrewJ 5:f9404f00deda 12 always HIGH)
InBrewJ 5:f9404f00deda 13
XtaticO 0:4b3b9e047ce3 14 */
XtaticO 0:4b3b9e047ce3 15 #ifndef MBED_SMOTOR_H
XtaticO 0:4b3b9e047ce3 16 #define MBED_SMOTOR_H
XtaticO 0:4b3b9e047ce3 17
XtaticO 0:4b3b9e047ce3 18 #include "mbed.h"
XtaticO 0:4b3b9e047ce3 19
XtaticO 0:4b3b9e047ce3 20 class sMotor {
XtaticO 0:4b3b9e047ce3 21 public:
XtaticO 0:4b3b9e047ce3 22
InBrewJ 5:f9404f00deda 23 sMotor(PinName A0, PinName A1, PinName A2, PinName A3, PinName motorEnable, const int maxSteps); //motor constructor
XtaticO 0:4b3b9e047ce3 24
InBrewJ 5:f9404f00deda 25 void setMotorPosition(int position); // for use ONLY if the stepper init is skipped
InBrewJ 5:f9404f00deda 26 int getMotorPosition(void){ return _motorPosition; };
XtaticO 0:4b3b9e047ce3 27 void step(int num_steps, int direction, int speed);
InBrewJ 5:f9404f00deda 28 void up(int num_steps);
InBrewJ 5:f9404f00deda 29 void down(int num_steps);
XtaticO 0:4b3b9e047ce3 30
XtaticO 0:4b3b9e047ce3 31
XtaticO 0:4b3b9e047ce3 32 private:
XtaticO 0:4b3b9e047ce3 33
XtaticO 0:4b3b9e047ce3 34 DigitalOut _A0;
XtaticO 0:4b3b9e047ce3 35 DigitalOut _A1;
XtaticO 0:4b3b9e047ce3 36 DigitalOut _A2;
XtaticO 0:4b3b9e047ce3 37 DigitalOut _A3;
InBrewJ 5:f9404f00deda 38 DigitalOut _motorEnable;
InBrewJ 4:a3d8d60147dd 39 int _motorPosition;
InBrewJ 4:a3d8d60147dd 40 int _maxSteps;
InBrewJ 5:f9404f00deda 41 int _motorSpeed;
XtaticO 0:4b3b9e047ce3 42
XtaticO 0:4b3b9e047ce3 43 };
XtaticO 0:4b3b9e047ce3 44
XtaticO 0:4b3b9e047ce3 45 #endif