Skip to content

Commit caf000b

Browse files
ekozlenkocmaglie
authored andcommitted
Fixed unsigned var and version note
1 parent 8478167 commit caf000b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

libraries/Stepper/src/Stepper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Stepper.cpp - - Stepper library for Wiring/Arduino - Version 0.4
2+
Stepper.cpp - - Stepper library for Wiring/Arduino - Version 0.5
33
44
Original library (0.1) by Tom Igoe.
55
Two-wire modifications (0.2) by Sebastian Gassner
@@ -146,7 +146,7 @@ void Stepper::step(int steps_to_move)
146146
// decrement the number of steps, moving one step each time:
147147
while(steps_left > 0) {
148148
// move only if the appropriate delay has passed:
149-
if (micros() - this->last_step_time >= this->step_delay || micros() - this->last_step_time < 0) {
149+
if (micros() - this->last_step_time >= this->step_delay || micros() < this->last_step_time) {
150150
// get the timeStamp of when you stepped:
151151
this->last_step_time = micros();
152152
// increment or decrement the step number,

libraries/Stepper/src/Stepper.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/*
2-
Stepper.h - - Stepper library for Wiring/Arduino - Version 0.4
2+
Stepper.h - - Stepper library for Wiring/Arduino - Version 0.5
33
44
Original library (0.1) by Tom Igoe.
55
Two-wire modifications (0.2) by Sebastian Gassner
66
Combination version (0.3) by Tom Igoe and David Mellis
77
Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley
8+
High-speed stepping mod and timer rollover fix (0.5) by Eugene Kozlenko
89
910
Drives a unipolar or bipolar stepper motor using 2 wires or 4 wires
1011
@@ -18,7 +19,8 @@
1819
A slightly modified circuit around a Darlington transistor array or an L293 H-bridge
1920
connects to only 2 microcontroler pins, inverts the signals received,
2021
and delivers the 4 (2 plus 2 inverted ones) output signals required
21-
for driving a stepper motor.
22+
for driving a stepper motor. Similarly the Arduino motor shields 2 direction pins
23+
may be used.
2224
2325
The sequence of control signals for 4 control wires is as follows:
2426
@@ -79,7 +81,7 @@ class Stepper {
7981

8082
int direction; // Direction of rotation
8183
int speed; // Speed in RPMs
82-
unsigned long step_delay; // delay between steps, in ms, based on speed
84+
unsigned long step_delay; // delay between steps, in us, based on speed
8385
int number_of_steps; // total number of steps this motor can take
8486
int pin_count; // whether you're driving the motor with 2 or 4 pins
8587
int step_number; // which step the motor is on
@@ -90,7 +92,7 @@ class Stepper {
9092
int motor_pin_3;
9193
int motor_pin_4;
9294

93-
long last_step_time; // time stamp in ms of when the last step was taken
95+
unsigned long last_step_time; // time stamp in us of when the last step was taken
9496
};
9597

9698
#endif

0 commit comments

Comments
 (0)