Smartlynx stepper motor code (SPI)

  • 25 Replies
  • 2130 Views
*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Smartlynx stepper motor code (SPI)
« on: July 16, 2015, 09:06:04 AM »
OK, so I got the smartlynx stepper motor controller.. I need some help getting the arduino to talk to it, and setting up the wiring

Here's a link to the documentation
http://www.robotshop.com/media/files/zip/documentation-h-elc-mdr-stp-2.zip
it has a little pseudocode in there, I'm just not sure where to start with it


I've never done anything with SPI before...  I have the connector for the smartlynx side of it, but I'm going to have to hack an end off it and fiddle with the rest of it (if I ever make a board I'll put a dedicated header on it)


In other news I've pretty much got the hardware part of the AFC done.. stepper motor is mounted, I have a few little adjustments to make to it yet, but it's looking OK

'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Smartlynx stepper motor code (SPI)
« Reply #1 on: July 17, 2015, 12:55:25 PM »
If I get time this weekend I'll take a look at it, never made my own arduino library before, but it is SPI so you might be able to take a gander at the canbus library and sort of figure things out.. both are SPI

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #2 on: July 17, 2015, 09:08:45 PM »
alright, cool... Once I have a little example of how it works I can understand it and modify it to whatever I need
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #3 on: July 22, 2015, 01:29:34 PM »
OK, I got to working on the code, but I have a problem.. they didn't include one of the functions for writing, so I kinda had to guess, and I'm not having any luck with it...

rather than post everything again, I'll post a link to the unhelpful Arduino forums SPI -> L6470 (smartlynx) stepper motor driver
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #4 on: July 23, 2015, 11:06:03 PM »
OK, I got some code back from PhiRobotics.. it's for Atmel Studio, and I can't figure it out..

I've included the file that they sent me, perhaps you can have a gander at it?
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #5 on: July 25, 2015, 01:41:53 PM »
Tearing my hair out with this blasted thing.. just doesn't want to work!
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Smartlynx stepper motor code (SPI)
« Reply #6 on: July 25, 2015, 01:57:12 PM »
Don't hit it with a hammer, I'll try looking at this stuff

What is this in ms vb ?

Hum, saw the regular c and h, they look pretty complete IMHO ? Is communication not working or its not doing stuff ?

Pinouts for the Canbus SPI
digital i/o reference:
AREF = 16
RX = 0

14 GND
13 SCK
12 MISO
11 MOSI
10 CS

INT can goto 2 if you want an interrupt wakeup or something /shrug

https://www.arduino.cc/en/Reference/SPI
Pinout is different maybe the GPIO thing ?

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #7 on: July 25, 2015, 04:03:12 PM »
Only thing that happens is the FLAG LED comes on after it gets reset.. I can't get any data back from it, and I don't know if the data I'm sending makes it there...

I'm using the ICSP header, so I have MISO, MOSI, SCK, 5V, GND on that, CS, RESET, FLAG, Busy/Sync, STCK I have broken out and can use jumpers to wherever.. currently they're all on PortB (I updated the code where it referenced portJ).
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Smartlynx stepper motor code (SPI)
« Reply #8 on: July 25, 2015, 04:37:05 PM »
Why not use all the portB i/o's and abandon the icsp header ? Can you upload a picture of how you have it all together ?

Sometimes it is the simple stuff. I usually break things out on a bread board. When connecting bare wires, I use a male-male jumper wire and just wrap the wire around the loose male end, instead of trying to stuff it in, cause usually it never connects.

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #9 on: July 25, 2015, 06:06:10 PM »
I have a sparkfun breadboard that I soldered female headers on to connect to the ICSP header.. I then split my 10 wire ribbon and passed it through the solder holes from the top, and made the connections on the bottom (soldered.. but that only needed 5 of the 10 wires.. so 2 hole spacings away from where I ran the wire through, I put a male header and connected the rest of them to it

I have some good male to female jumpers that I run from that header to whatever IO pin I want
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #10 on: July 26, 2015, 08:52:34 PM »
OK, I'm back to fiddling with this thing..

Looking at the code.. does MISO need to be a input pullup?.. I'm just trying to figure out why I never get any data back..

For a test.. what would happen if you jumpered MOSI to MISO?... would you get your data back?
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Smartlynx stepper motor code (SPI)
« Reply #11 on: July 26, 2015, 10:48:58 PM »
What is your code ? I should probably comb over the library you have a bit more, are you using any of arduino SPI library ?

ie: SPI reset looks like this in the canbus library
Code: [Select]
// Reset command
void MCP::reset()
{

  digitalWrite(CS,LOW);
  SPI.transfer(RESET);
  digitalWrite(CS,HIGH);
}

Code: [Select]
void MCP::begin(int mode, int CANspeed)
{
SPI.begin();//SPI communication begin

reset();//Set MCP into Config mode by soft reset. Note MCP2515 is in Config mode by default at power up.

bitRate(CANspeed);//Set CAN bit rate

setMode(mode);//Set CAN mode

}

I'm not sure about the mosi's as much of the canbus library uses the slave low to high.. etc

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #12 on: July 26, 2015, 10:55:09 PM »
OK... I GOT THE COMS WORKING.. and the motor is buzzing..

I moved everything off the ICSP header and moved it to the MEGA pins 50-54  with jumper wires.. seems to have done the trick, will troubleshoot why this changed it later...

working on getting it to actually turn now.. tried flipping my phases backwards.. no dice yet, checking statuses and working from there
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM

*

Online hakcenter

  • developer
  • Hero Member
  • *****
  • 623
    • 1998 12v Ram
Re: Smartlynx stepper motor code (SPI)
« Reply #13 on: July 27, 2015, 08:01:19 AM »
Well that's good

*

Offline Rx7man

  • Crazy guy
  • Hero Member
  • *****
  • 908
  • Jack of all trades
    • '94 Dodge dually
Re: Smartlynx stepper motor code (SPI)
« Reply #14 on: July 27, 2015, 10:07:42 PM »
Now if I could only get that motor to run the way it should.. it's *really* weak... it's supposed to be 85 oz-in, and it's a tenth of that if you're lucky... no amount of flipping wires is helping, my power supply delivers 2 amps, which should be sufficient with a decent cap (the voltage is steady at 12.25V anyhow).. I've fiddled with all the config registers on the 6470, setting all the voltages to max, and all the currents to max as well, so I don't know what else there is.. Changing step mode from full step to a finer resolution doesn't improve anything either
'94 dodge, Colt Cam, head worked, NV5600, 3.55's, SB clutch, Ford manual hubs w. hawk brakes, custom flatdeck, custom aluminum bumper, cab off restoration, totally new engine, Mahle pistons @19:1..HE351VE with 67mm turbine and 67x95mm compressor
440hp/1000 ft lb @ 2400 RPM