AccelStepper with F407

Discussions about the STM32generic core
FiveO
Posts: 27
Joined: Mon Oct 16, 2017 6:41 am

AccelStepper with F407

Post by 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:

Code: Select all

#include <AccelStepper.h>

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

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

void loop()
{  
  stepper.setSpeed(1000);
   stepper.runSpeed();
}
I am using voltage shifter for driver(5v), grounds connected. Code worked with Arduino Mega.

FiveO
Posts: 27
Joined: Mon Oct 16, 2017 6:41 am

Re: AccelStepper with F407

Post by 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?

User avatar
BennehBoy
Posts: 503
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: AccelStepper with F407

Post by 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?
-------------------------------------
https://github.com/BennehBoy

stevestrong
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: AccelStepper with F407

Post by stevestrong » Wed Jan 24, 2018 10:23 am

Which library do you use? A link to it would be useful.


stevestrong
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: AccelStepper with F407

Post by stevestrong » Wed Jan 24, 2018 12:34 pm

I think you should set the mode of those pins to output:

Code: Select all

void setup()
{
  pinMode(PE14, OUTPUT);
  pinMode(PE15, OUTPUT);
  stepper.setMaxSpeed(2000);
}
or

Code: Select all

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

FiveO
Posts: 27
Joined: Mon Oct 16, 2017 6:41 am

Re: AccelStepper with F407

Post by 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
Posts: 2063
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: AccelStepper with F407

Post by stevestrong » Wed Jan 24, 2018 2:19 pm

You have used already the pins PE14,15 for the AccelStepper instance in your original code:

Code: Select all

AccelStepper stepper(1,PE14,PE15); // driver, step, dir
So how comes that for that you did not get the "pins not declared" error message?

FiveO
Posts: 27
Joined: Mon Oct 16, 2017 6:41 am

Re: AccelStepper with F407

Post by 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
Posts: 1684
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: AccelStepper with F407

Post by 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

Post Reply