Title: Fireduino and AccelStepper Stepper motors [Print This Page] Author: satolas Time: 6/9/2017 00:59 Title: Fireduino and AccelStepper Stepper motors Hello :-)
Specs :
- I have a Fireduino bought few month ago
- I use ArduinoIDE-1.8.0_for_Fireduino_1.3.1
- Windows 10 Pro N
- On a MacbookPro 2015 (15")
I 'm trying to drive stepper motors with the Fireduino.
Compared to an Arduino DUE the Fireduino is way faster for that task !!! really nice to see an "arduino like" board driving steppers motors so fast.
The problem :
So with that kind of very simple code it seems to work : Working code :
#define STEP_PIN 5
void setup() {
pinMode(STEP_PIN, OUTPUT);
}
void step(long stepDelay) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(stepDelay);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(stepDelay);
}
void loop() {
// rotate by 100 steps.
for (int i = 0; i < 100; i++) {
step(140); //140 seems to be the fastest rate for my motors. (ST5918L2008-A)
}
}
Copy the code
But when I try to use a code with the Accelstepper library, nothing seems to move anymore...
For exemple that one : Not working code :
It moves clockwise/anti-clockwise as expected with the Arduino Due and Arduino UNO.
But with the Fireduino nothing happens :-/
Is there any incompatibility beetween AccelStepper and the fireduino ?
Seems strange because the file AccelStepper.cpp seems to use a similar command to move the stepper motors as the first sketch that I gaved here :
AccelStepper.cpp (Just a sample that seems to do the "pulse" job for the stepper) : AccelStepper.cpp "step1" :
void AccelStepper::step1(long step)
{
(void)(step); // Unused
// _pin[0] is step, _pin[1] is direction
setOutputPins(_direction ? 0b10 : 0b00); // Set direction first else get rogue pulses
setOutputPins(_direction ? 0b11 : 0b01); // step HIGH
I don't really understand why the motors don't move at all with the same code on the Fireduino :-/
Thanks for your attention.
Regards,
satolas
PS : stepper.h (included with the arduino and Fireduino library don't work either)
Author: satolas Time: 6/9/2017 01:14 Last edited by satolas In 6/9/2017 01:16 Editor
:-)
By the way the sample from stepper.cpp
void Stepper::stepMotor(int thisStep)
{
if (this->pin_count == 2) {
switch (thisStep) {
case 0: // 01
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, HIGH);
break;
case 1: // 11
digitalWrite(motor_pin_1, HIGH);
digitalWrite(motor_pin_2, HIGH);
break;
case 2: // 10
digitalWrite(motor_pin_1, HIGH);
digitalWrite(motor_pin_2, LOW);
break;
case 3: // 00
digitalWrite(motor_pin_1, LOW);
digitalWrite(motor_pin_2, LOW);
break;
}
Copy the code
Also not working Author: satolas Time: 6/10/2017 20:58
Any idea ? :-/Author: satolas Time: 7/7/2017 02:52
Okay :-)
Just to don't let that post without solution :
kind of weird, but adding that does the trick:
pinMode(_pin[0], OUTPUT);
pinMode(_pin[1], OUTPUT);
We are just repeating the pinMode status to output. Then it happening something finally :-)
By the way on a DUE, the code without that two lines its working...so maybe developpement boards have their own sensibility at the end
so instead of :
void AccelStepper::step1(long step)
{
(void)(step); // Unused
// _pin[0] is step, _pin[1] is direction
setOutputPins(_direction ? 0b10 : 0b00); // Set direction first else get rogue pulses
setOutputPins(_direction ? 0b11 : 0b01); // step HIGH