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.
Dependents: HIDTympDeviceWithPIDController
motorControl.h
00001 /* 00002 ############################################ 00003 ## Motor Control v0.1 Library ## 00004 ## created by Peter Ilsoee ## 00005 ############################################ 00006 ---- piniels@gmail.com ----- 00007 This library was made for 4-Phase Stepper Motors for A4980 SPI device from Allegro 00008 I don't take any resposability for the damage caused to your equipment. 00009 00010 */ 00011 #ifndef MOTOR_CONTROL_H 00012 #define MOTOR_CONTROL_H 00013 00014 #include "mbed.h" 00015 #include "A4980ControlRegi.h" 00016 00017 class motorControl { 00018 public: 00019 00020 motorControl(int numberOfSteps, PinName step, PinName dir, PinName ms1, PinName ms0, PinName enable, PinName reset, PinName diag); //motor constructor 00021 void step(int num_steps, int direction, int speed); 00022 00023 void initSpi(); 00024 int setConfigRegi0(t_config_control_regi_0 value); 00025 int setConfigRegi1(t_config_control_regi_1 value); 00026 int setRunRegi(t_run_regi value); 00027 int getStepCount(); 00028 void setStepCount(int value); 00029 void setMicroSteps(int value); 00030 int getMicroSteps(); 00031 t_config_control_regi_0 getConfigRegi0(); 00032 t_config_control_regi_1 getConfigRegi1(); 00033 t_run_regi getRunRegi(); 00034 void runStepperAtSpeed(bool startStop, int whatSpeed, int direction); 00035 void runStepperAtSpeedWithSPI(bool startStop, int whatSpeed, int direction); 00036 void goToZeroPosition(int whatSpeed); 00037 void openCloseValve(bool openTrue); 00038 /** Call back member for timer tick 00039 * 00040 */ 00041 void runMotor(void); 00042 void doRamp(int numberOfRampsteps,float endDelay); 00043 float calculateStepDelay(int whatSpeed); 00044 void step(int num_steps, int delay, bool direction); 00045 00046 private: 00047 int _Number_OF_STEPS; 00048 int _Step_Counter; 00049 bool _Bool_Direction; 00050 PwmOut _STEP; 00051 DigitalOut _DIR; 00052 DigitalOut _MS1; 00053 DigitalOut _MS0; 00054 DigitalOut _ENABLE; 00055 DigitalOut _RESET; 00056 DigitalIn _DIAG; 00057 float step_delay; 00058 t_config_control_regi_0 _REGI_0; 00059 t_config_control_regi_1 _REGI_1; 00060 t_run_regi _REGI_RUN; 00061 00062 00063 00064 00065 }; 00066 00067 #endif
Generated on Fri Jul 15 2022 02:00:16 by
1.7.2