Playing with the mBuino, considering to attach a stepper motor with the Sparkfun autodriver. Found some nice code on the mbed.org and it could turn out really nicely. But having doubts about connecting it, not sure which pins to use for the 6 wires…??
#include "mbed.h"
#include "L6470SDC.h"
L6470SDC l6470(USBTX, USBRX, SPI_MOSI, SPI_MISO, SPI_SCK, D10);
int main() {
//initialize
l6470.init();
//set maximum speed
l6470.setMaximumSpeed(1, l6470.calcMaxSpd(100));
//run 300step/s,clockwise
l6470.run(1, l6470.calcSpd(300), true);
wait(5.0);
... and more
With the risk of being completely off-track, here is my initial plan:
USBTX is P0.18
USBRX is P0.19
SPI_MOSI is P0.21
SPI_MISO is P0.22
SPI_SCK is P0.15
D10 is P0.11 (or another free pin)
And here my skills are not sufficient. I dont understand why the USBTX/RX pins are allocated, but not used?? And I dont see the chip select anywhere??
The list for the MCU controller communication input on the board is:
On the autodriver —> mBuino
3-5V —> 3V3
OSCIN —> ???
SCK —> P0.15
GND —> GND
OSCIN —> ???
MOSI —> P0.21
MISO —> P0.22
So, I did some reading on the drivers source-code. And now I understand - the serial connection is for debugging information that is printed directly to that connection, so it can be output to a screen when debugging.
I was not in mbed thinking mode, where all debugging goes through the serial connection with printf. ???
Everytime I take a detour into Arduino or mbed world I start appreciating NETMF so much more.
Anyway, will let you know if I get the stepper to behave!
STATUS: Serious uphill battle, only led blinking is workin. :wall:
I have attached the Sparkfun module according to your guidance, supplying 12V for motor and 5v to chip on module. Attached the SPI wires to mBuino, and 5V supply to that as well.
Can I have your hawkeyes look at my test-setup and see if I have done some beginner mistakes…?
My primary suspect is a really lousy driver, mbed is really difficult to find the good drivers… I am using this one: [url]L6470_lib - L6470 use library | Mbed
I use a 12V good quality power supply with a barrel plug connected to DFRobot breadboard power-converter, which supplies 3V and 5V. I have soldered wires directly to the barrel (blue and white on picture to get access to the 12V).
These are the wires: From breadboard:
12V → V+ at Stepper module
5V to mBuino 5V
5V to 5V at Stepper module
GND → GND at mBuino
GND → GND at Stepper module power-supply side
GND → GND at Stepper module chip-side
@ njbuch - As I sit back and ponder over my own experiences with those exact boards, I can only laugh at how many times I’ve pulled my hair out trying to figure out why it’s not working only to realize that yet again I forgot to pull reset high. I can think of 3 instances where that has happened. SparkFun should have added a pull up resistor.
@ Mr. John Smith - I avoided pulling my hair out thanks to you
The biggest realisation to me though is the fact that mbed development is quick to get started with, but really soon you realise that you need better tools.