Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of R5_StepperDrive by
StepperDrive.h
00001 #ifndef _STEPPER_DRIVE_ 00002 #define _STEPPER_DRIVE_ 00003 00004 #include "mbed.h" 00005 00006 #define Ustep 16 //microstepping setup: 1, 2, 4, 8, or 16 00007 00008 class StepperDrive{ 00009 public: 00010 StepperDrive(Serial &pc1, PinName in1, PinName in2, bool in3, PinName in4, PinName in5, bool in6, float in7, float in8, float in9 = 1000); 00011 //(serisl &, stepPinLeft, dirPinLeft, invertLeft, stepPinRight, dirPinRight, invertRight, wheelCircum, wheelSepar, periodUs) 00012 int move(float distance, float angle); 00013 bool isMoveDone(); 00014 void pauseMove(); 00015 void resumeMove(); 00016 00017 Serial &pc; 00018 int getRightSteps() { return rightSteps; } 00019 int getLeftSteps() { return leftSteps; } 00020 00021 private: 00022 Ticker pit; //periodic interrupt timer 00023 00024 void pitCallback(); 00025 00026 void stepRight(bool dir); 00027 void stepLeft(bool dir); 00028 00029 DigitalOut leftStep; 00030 DigitalOut leftDir; 00031 DigitalOut rightStep; 00032 DigitalOut rightDir; 00033 00034 float wheelCircum; //wheel circumference 00035 float wheelSepar; //distance between wheels 00036 bool invertLeft; //software wheel direction inversion 00037 bool invertRight; //software wheel direction inversion 00038 bool moveComplete; 00039 00040 int leftSteps; 00041 int rightSteps; 00042 float leftStepsPC; 00043 float rightStepsPC; 00044 float leftError; 00045 float rightError; 00046 int leftStepsPause; // for holding steps left during pause 00047 int rightStepsPause; // for holding steps right during pause 00048 }; 00049 00050 #endif
Generated on Wed Jul 27 2022 06:33:05 by
 1.7.2
 1.7.2 
    