-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrotator_stepper.h
95 lines (77 loc) · 2.62 KB
/
rotator_stepper.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//------------------------------------------------------
#if defined(FEATURE_STEPPER_MOTOR)
void service_stepper_motor_pulse_pins(){
service_stepper_motor_pulse_pins_count++;
static unsigned int az_stepper_pin_transition_counter = 0;
static byte az_stepper_pin_last_state = LOW;
if (az_stepper_freq_count > 0){
az_stepper_pin_transition_counter++;
if (az_stepper_pin_transition_counter >= az_stepper_freq_count){
if (az_stepper_pin_last_state == LOW){
digitalWrite(az_stepper_motor_pulse,HIGH);
az_stepper_pin_last_state = HIGH;
} else {
digitalWrite(az_stepper_motor_pulse,LOW);
az_stepper_pin_last_state = LOW;
}
az_stepper_pin_transition_counter = 0;
}
} else {
az_stepper_pin_transition_counter = 0;
}
#ifdef FEATURE_ELEVATION_CONTROL
static unsigned int el_stepper_pin_transition_counter = 0;
static byte el_stepper_pin_last_state = LOW;
if (el_stepper_freq_count > 0){
el_stepper_pin_transition_counter++;
if (el_stepper_pin_transition_counter >= el_stepper_freq_count){
if (el_stepper_pin_last_state == LOW){
digitalWrite(el_stepper_motor_pulse,HIGH);
el_stepper_pin_last_state = HIGH;
} else {
digitalWrite(el_stepper_motor_pulse,LOW);
el_stepper_pin_last_state = LOW;
}
el_stepper_pin_transition_counter = 0;
}
} else {
el_stepper_pin_transition_counter = 0;
}
#endif //FEATURE_ELEVATION_CONTROL
}
#endif //defined(FEATURE_STEPPER_MOTOR)
//------------------------------------------------------
#ifdef FEATURE_STEPPER_MOTOR
void set_az_stepper_freq(unsigned int frequency){
if (frequency > 0) {
az_stepper_freq_count = 2000 / frequency;
} else {
az_stepper_freq_count = 0;
}
#ifdef DEBUG_STEPPER
debug.print("set_az_stepper_freq: ");
debug.print(frequency);
debug.print(" az_stepper_freq_count:");
debug.print(az_stepper_freq_count);
debug.println("");
#endif //DEBUG_STEPPER
}
#endif //FEATURE_STEPPER_MOTOR
//------------------------------------------------------
#if defined(FEATURE_ELEVATION_CONTROL) && defined(FEATURE_STEPPER_MOTOR)
void set_el_stepper_freq(unsigned int frequency){
if (frequency > 0) {
el_stepper_freq_count = 2000 / frequency;
} else {
el_stepper_freq_count = 0;
}
#ifdef DEBUG_STEPPER
debug.print("set_el_stepper_freq: ");
debug.print(frequency);
debug.print(" el_stepper_freq_count:");
debug.print(el_stepper_freq_count);
debug.println("");
#endif //DEBUG_STEPPER
}
#endif //defined(FEATURE_ELEVATION_CONTROL) && defined(FEATURE_STEPPER_MOTOR)
//------------------------------------------------------