This repository was archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathY_Stepper.ino
More file actions
69 lines (61 loc) · 1.37 KB
/
Y_Stepper.ino
File metadata and controls
69 lines (61 loc) · 1.37 KB
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
void stepY()
{
digitalWrite(yStepperStep,LOW);
delayMicroseconds(200);
digitalWrite(yStepperStep,HIGH);
delayMicroseconds(200);
}
//
//void step2Med()
//{
// digitalWrite(stepper2Step,LOW);
// delayMicroseconds(2000);
// digitalWrite(stepper2Step,HIGH);
// delayMicroseconds(4000);
//}
//
//void step2Fast()
//{
// digitalWrite(stepper2Step,LOW);
// delayMicroseconds(600);
// digitalWrite(stepper2Step,HIGH);
// delayMicroseconds(1200);
//}
int moveY(double distance)
{
/*
* Y Stepper
* HIGH = DOWN
* LOW = UP
*/
double mmPerPulse = 0.0025796;
double magnitude = fabs(distance);
digitalWrite(yStepperDir, (distance < 0)?HIGH:LOW);
long numPulses = long(round(magnitude/mmPerPulse));
if (numPulses == 0)
{
return 0; //If we aren't going to send pulses, we can leave
}
for (long i = 0;i < numPulses; i++)
{
// if(digitalRead(lsC)==HIGH || digitalRead(lsD)==HIGH)
// {
// digitalWrite(13,HIGH);
// return 1;
// }
// else if(digitalRead(pauseButton) == HIGH)
// {
// handlePauseButton();
// }
digitalWrite(yStepperStep, LOW);
delayMicroseconds(100);
digitalWrite(yStepperStep, HIGH);
delayMicroseconds(150);
if (!encodersEnabled)
{
localYPosition += mmPerPulse * distance/magnitude;
absoluteYPosition += mmPerPulse * distance/magnitude;
}
}
return 0;
}