2014-05-25 17:20:00 -06:00
|
|
|
/*
|
|
|
|
* StepperControl.h
|
|
|
|
*
|
|
|
|
* Created on: 16 maj 2014
|
|
|
|
* Author: MattLech
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef STEPPERCONTROL_H_
|
|
|
|
#define STEPPERCONTROL_H_
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
#include "CurrentState.h"
|
2014-08-17 14:15:05 -06:00
|
|
|
#include "ParameterList.h"
|
2015-07-26 16:13:13 -06:00
|
|
|
#include "StepperControlAxis.h"
|
2015-10-29 16:50:09 -06:00
|
|
|
#include "StepperControlEncoder.h"
|
2014-05-25 17:20:00 -06:00
|
|
|
#include "pins.h"
|
2014-05-28 17:02:22 -06:00
|
|
|
#include "Config.h"
|
2014-05-25 17:20:00 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-10-02 15:43:39 -06:00
|
|
|
#include "Command.h"
|
2014-05-25 17:20:00 -06:00
|
|
|
|
|
|
|
class StepperControl {
|
|
|
|
public:
|
2015-08-01 16:22:07 -06:00
|
|
|
StepperControl();
|
|
|
|
StepperControl(StepperControl const&);
|
|
|
|
void operator=(StepperControl const&);
|
|
|
|
|
2014-05-25 17:20:00 -06:00
|
|
|
static StepperControl* getInstance();
|
2015-08-03 15:12:49 -06:00
|
|
|
//int moveAbsolute( long xDest, long yDest,long zDest,
|
|
|
|
// unsigned int maxStepsPerSecond,
|
|
|
|
// unsigned int maxAccelerationStepsPerSecond);
|
|
|
|
int moveToCoords( long xDest, long yDest, long zDest,
|
2014-08-07 15:05:30 -06:00
|
|
|
unsigned int xMaxSpd, unsigned int yMaxSpd, unsigned int zMaxSpd,
|
2016-10-02 15:43:39 -06:00
|
|
|
bool homeX, bool homeY, bool homeZ
|
|
|
|
);
|
2015-06-21 15:39:45 -06:00
|
|
|
|
|
|
|
void handleMovementInterrupt();
|
2014-09-21 14:42:44 -06:00
|
|
|
int calibrateAxis(int axis);
|
2015-06-14 15:08:57 -06:00
|
|
|
void initInterrupt();
|
2015-08-02 16:16:35 -06:00
|
|
|
void enableMotors();
|
|
|
|
void disableMotors();
|
2016-10-03 14:17:46 -06:00
|
|
|
bool motorsEnabled();
|
2015-08-02 16:16:35 -06:00
|
|
|
|
2015-11-02 14:15:49 -07:00
|
|
|
void test();
|
|
|
|
void test2();
|
|
|
|
|
2014-05-25 17:20:00 -06:00
|
|
|
private:
|
2015-08-01 16:22:07 -06:00
|
|
|
StepperControlAxis axisX;
|
|
|
|
StepperControlAxis axisY;
|
|
|
|
StepperControlAxis axisZ;
|
|
|
|
|
2015-11-02 14:15:49 -07:00
|
|
|
StepperControlEncoder encoderX;
|
|
|
|
StepperControlEncoder encoderY;
|
|
|
|
StepperControlEncoder encoderZ;
|
|
|
|
|
2016-01-03 14:28:06 -07:00
|
|
|
void checkAxisVsEncoder(StepperControlAxis* axis, StepperControlEncoder* encoder, float* missedSteps, long* lastPosition, float* encoderStepDecay, bool* encoderEnabled);
|
2016-02-03 15:15:51 -07:00
|
|
|
void checkAxisSubStatus(StepperControlAxis* axis, int* axisSubStatus);
|
2015-12-02 15:31:29 -07:00
|
|
|
|
2015-08-01 16:22:07 -06:00
|
|
|
bool axisActive[3];
|
2016-02-03 15:15:51 -07:00
|
|
|
int axisSubStep[3];
|
2015-08-01 16:22:07 -06:00
|
|
|
|
2015-08-07 15:30:24 -06:00
|
|
|
void loadMotorSettings();
|
2016-01-02 15:21:01 -07:00
|
|
|
void loadEncoderSettings();
|
2017-01-19 12:20:36 -07:00
|
|
|
bool intToBool(int value);
|
2016-01-02 15:21:01 -07:00
|
|
|
|
2015-08-01 16:22:07 -06:00
|
|
|
void reportPosition();
|
|
|
|
void storeEndStops();
|
|
|
|
void reportEndStops();
|
2016-02-06 10:23:24 -07:00
|
|
|
void reportStatus(StepperControlAxis* axis, int axisSubStatus);
|
|
|
|
void reportCalib(StepperControlAxis* axis, int calibStatus);
|
2015-08-01 16:22:07 -06:00
|
|
|
|
|
|
|
unsigned long getMaxLength(unsigned long lengths[3]);
|
|
|
|
bool endStopsReached();
|
|
|
|
|
2015-08-07 15:30:24 -06:00
|
|
|
bool homeIsUp[3];
|
|
|
|
long speedMax[3];
|
|
|
|
long speedMin[3];
|
|
|
|
long stepsAcc[3];
|
|
|
|
bool motorInv[3];
|
2016-12-03 13:58:27 -07:00
|
|
|
bool motor2Inv[3];
|
|
|
|
bool motor2Enbl[3];
|
2015-08-07 15:30:24 -06:00
|
|
|
bool endStInv[3];
|
2017-02-28 14:48:46 -07:00
|
|
|
bool endStEnbl[3];
|
2015-08-07 15:30:24 -06:00
|
|
|
long timeOut[3];
|
2015-11-11 15:09:15 -07:00
|
|
|
|
2015-12-31 08:01:40 -07:00
|
|
|
float motorConsMissedSteps[3];
|
|
|
|
long motorLastPosition[3];
|
2015-11-11 15:09:15 -07:00
|
|
|
|
2016-01-02 15:21:01 -07:00
|
|
|
int motorConsMissedStepsMax[3];
|
|
|
|
float motorConsMissedStepsDecay[3];
|
|
|
|
bool motorConsEncoderEnabled[3];
|
|
|
|
|
2016-10-03 14:17:46 -06:00
|
|
|
bool motorMotorsEnabled;
|
2014-05-25 17:20:00 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* STEPPERCONTROL_H_ */
|