forked from jbsmith96/spaceshark-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTinyStepper_28BYJ_48.h
executable file
·75 lines (64 loc) · 2.3 KB
/
TinyStepper_28BYJ_48.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ******************************************************************
// * *
// * Header file for TinyStepper_28BYJ_48.c *
// * *
// * Copyright (c) S. Reifel & Co, 2017 *
// * *
// ******************************************************************
#ifndef TinyStepper_28BYJ_48_h
#define TinyStepper_28BYJ_48_h
#include "Particle.h"
#include <stdlib.h>
//
// the TinyStepper_28BYJ_48 class
//
class TinyStepper_28BYJ_48
{
public:
//
// public functions
//
TinyStepper_28BYJ_48();
void connectToPins(byte in1PinNumber, byte in2PinNumber, byte in3PinNumber, byte in4PinNumber);
void setCurrentPositionInSteps(long currentPositionInSteps);
long getCurrentPositionInSteps();
void setupStop();
void setSpeedInStepsPerSecond(float speedInStepsPerSecond);
void setAccelerationInStepsPerSecondPerSecond(float accelerationInStepsPerSecondPerSecond);
void moveRelativeInSteps(long distanceToMoveInSteps);
void setupRelativeMoveInSteps(long distanceToMoveInSteps);
void moveToPositionInSteps(long absolutePositionToMoveToInSteps);
void setupMoveInSteps(long absolutePositionToMoveToInSteps);
bool motionComplete();
float getCurrentVelocityInStepsPerSecond();
bool processMovement(void);
void disableMotor();
private:
//
// private functions
//
void setNextFullStep(int direction);
//
// private member variables
//
byte in1Pin = 0;
byte in2Pin = 0;
byte in3Pin = 0;
byte in4Pin = 0;
float desiredSpeed_InStepsPerSecond;
float acceleration_InStepsPerSecondPerSecond;
long targetPosition_InSteps;
bool startNewMove;
float desiredStepPeriod_InUS;
long decelerationDistance_InSteps;
int direction_Scaler;
float ramp_InitialStepPeriod_InUS;
float ramp_NextStepPeriod_InUS;
unsigned long ramp_LastStepTime_InUS;
float acceleration_InStepsPerUSPerUS;
float currentStepPeriod_InUS;
long currentPosition_InSteps;
int stepPhase;
};
// ------------------------------------ End ---------------------------------
#endif