AccelStepper with F407

FiveO
Tue Jan 23, 2018 10:43 am
Hi

Today I wanted to try AccelStepper library with F407. Stepper is not moving! Do I need declare pins to PWM or what?

I am using PWM pins PE14(for steps) and PE15(for dir).

Simple code example:#include <AccelStepper.h>

AccelStepper stepper(1,PE14,PE15); // driver, step, dir

void setup()
{
stepper.setMaxSpeed(2000);
}

void loop()
{
stepper.setSpeed(1000);
stepper.runSpeed();
}


FiveO
Wed Jan 24, 2018 9:41 am
I tried other pins(PB0,PB1), still not moving. Next I tried with STM32F103C8 and MapleMini F103CB on STM32GENERIC – working!

So why it is not working on F407VE?


BennehBoy
Wed Jan 24, 2018 10:22 am
It’s a less mature core, incompatibilities should be expected.

Perhaps try SteveStrongs fork of Roger’s core which has better F4 support?


stevestrong
Wed Jan 24, 2018 10:23 am
Which library do you use? A link to it would be useful.


stevestrong
Wed Jan 24, 2018 12:34 pm
I think you should set the mode of those pins to output:
void setup()
{
pinMode(PE14, OUTPUT);
pinMode(PE15, OUTPUT);
stepper.setMaxSpeed(2000);
}

FiveO
Wed Jan 24, 2018 1:27 pm
to BennehBoy: I will try it tomorrow.

to stevestrong:
First didn’t change a thing.

Second solution – pins not declared in this scope. I tried this with stepper.enableOutputs(); :
int stepPin = PE14;
int dirPin = PE15;
AccelStepper stepper(1, stepPin, dirPin); // step, dir

Same story, pins not declared?


stevestrong
Wed Jan 24, 2018 2:19 pm
You have used already the pins PE14,15 for the AccelStepper instance in your original code:
AccelStepper stepper(1,PE14,PE15); // driver, step, dir

FiveO
Wed Jan 24, 2018 3:06 pm
Sorry :D My mistake. I had chosen wrong board.

It compiles ok with first and second example, but stepper won’t run.


zmemw16
Wed Jan 24, 2018 3:38 pm
how are you downloading to target ? if st-link or jtag, pretty sure the low bits of PB and a couple in PA get messed with.

use disableDebugPorts(); // in setup
use enableDebugPorts(); // in the code that terminates execution maybe on a button press … … …

if its HAL you may need to check which mode debug is set to ? i use CubeMX and then in the sys device i select the debug mode, generate code & report to see the values and masks etc

usual questions btw
os, version, arduino version, which core, from where & when, download method & target is f407ve ?

stephen


FiveO
Wed Jan 24, 2018 5:38 pm
[zmemw16 – Wed Jan 24, 2018 3:38 pm] –
how are you downloading to target ? if st-link or jtag, pretty sure the low bits of PB and a couple in PA get messed with.

use disableDebugPorts(); // in setup
use enableDebugPorts(); // in the code that terminates execution maybe on a button press … … …

if its HAL you may need to check which mode debug is set to ? i use CubeMX and then in the sys device i select the debug mode, generate code & report to see the values and masks etc

usual questions btw
os, version, arduino version, which core, from where & when, download method & target is f407ve ?

stephen

Downloading with ST-Link V2. On f103 it works. Other thing like relays, i2c ,serial with bluetooth works normal on f407 after ST-Link.

That debug and HAL is new to me. For now I’l skip that part.

Win10, Arduino 1.8.5, STM32Generic, Today, ST-Link v2, STM32F407VE.
Same way and code works with F103 bluebill and Arduino Mega.


FiveO
Fri Jan 26, 2018 10:17 am
Ok. I tested my stepper with this code:
void setup() {
pinMode(PE14, OUTPUT); // Direction
pinMode(PE15, OUTPUT); // Step
digitalWrite(PE14, LOW); // Direction
digitalWrite(PE15, LOW); // Step
}

void loop() {
digitalWrite(PE15, HIGH);
delay(1);
digitalWrite(PE15, LOW);
delay(1);
}


Leave a Reply

Your email address will not be published. Required fields are marked *