Lil' Blackbox

Coding => v1.0 - v1.1 => Topic started by: Rx7man on July 16, 2015, 09:06:04 AM

Title: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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

Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter 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
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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 (http://forum.arduino.cc/index.php?topic=337465.new#new)
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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?
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on July 25, 2015, 01:41:53 PM
Tearing my hair out with this blasted thing.. just doesn't want to work!
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter 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 ?
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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).
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter 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.
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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?
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter 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

// Reset command
void MCP::reset()
{

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



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
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter on July 27, 2015, 08:01:19 AM
Well that's good
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man 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
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter on July 27, 2015, 10:10:31 PM
contact manufacturer at that point... lame

thou if i remember reading through, you need to reset the device after setting configs to it ?
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on July 28, 2015, 12:41:13 AM
Damn this is frustrating.. dealing with this thing for a week now and it's still not right... If you pull the reset pin low it's pretty much like a cold boot.. it loses it's brains when you do that, and then you have to reinitialize it. 

I think there might be something screwy in the output bridges of the chip, but how am I going to be able to tell.. it seems to work kinda right up to 100pps, and then it basically just hums.. it's still got nowhere near the torque it should have, because with 86 oz-in it ought to be impossible to stall it by pinching that smooth shaft.
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter on July 28, 2015, 08:51:49 AM
Hum' maybe it was the MCP chip... lol

What's that adjustment screw near the cap do ?
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on July 28, 2015, 06:01:50 PM
it is a voltage divider for the 3.3V 5 bit ADC
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on July 28, 2015, 11:21:00 PM
OK, I have a little bit better performance out of it now, but still can't get the RPM I ought to be able to get... it starts to lose serious power around 300 pps, and by 600 pps it doesn't turn at all.. I have a bunch of code work to clean up and I'll see if I spot the problem... I really don't like they way Phi Robotics set up their names, it was WAY too easy to confuse register addresses with the values that were supposed to be in them, and that caused a lot of errors in logic.. fixing that now so that

what used to be SMARTLYNX_ACC is now SMARTLYNX_REG_ACC for the register address and SMARTLYNX_VAL_ACC for the value in it
Title: Re: Smartlynx stepper motor code (SPI)
Post by: punisher454 on September 06, 2015, 01:19:18 AM
 The motor in the servo is a brushless DC motor (BLDC), NOT a  Stepper. I'm surprised that a stepper driver tricked it into turning at all.

There are 3 hall sensors and they are are for electronic commutation. The hall sensor position sequence can be re-used by the control software to track shaft position sort of like a low resolution shaft encoder.  In the commutation sequence there are six valid hall sensor combinations.
  There are two methods of controlling a BLDC, hall sensors and back EMF. The hall sensor method is the one to use for a servo motor since the back-emf sensing method is for continuous rotation applications, and sucks for fine positioning.

  I developed a PCB a few years ago that would replace the original and only contained the traces to connect the motor leads and hall sensors, plus an extra hall sensor under one of the gears for indexing. I was in the process of designing a stand alone controller and had gotten control of the servo motor, but didnt get much farther at the time.   

Hope that helps. I was just checking to see if anybody had developed a controller yet recently and stumbled across this site. It looks like this community is making some real nice progress, and nice to see its open source. I'll try to find a way to share what I figured out about driving the motor, the motor commutation code was real simple. It was the GLCD touchscreen menu system that took up most of my code space on an Atmega88 AVR (before the Arduino boards were so popular and inexpensive).

I'm currently building a twin turbo 454 for my 54GMC hot rod pickup, and have a couple HE351VE's I plan to use. Plus I'm working on my fathers Corvair with a transverse mounted 3800SC that we are planning to remove the Eaton supercharger and run an HE351VE ( I need to get that one done in a few months).  I'm really glad I found this group, I was about to start digging through my old code, but you guys are way farther ahead than I ever was (other than direct motor control, which is where I started).

Hope that helps, and I'll try to find my old actuator board schematic and post it soon.
Marvin 
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on September 09, 2015, 01:43:55 AM
What I'm working on IS a stepper motor, and the smartlynx controller is designed for it... it's my own offshoot of the LILBB project.

a TT 454 ought to be pretty impressive!
Title: Re: Smartlynx stepper motor code (SPI)
Post by: punisher454 on September 09, 2015, 02:30:09 AM
 Oh cool, I've been reading these threads for the last few days but must have missed the part about using a stepper in place of the stock BLDC.
  My own effort towards VGT control bypassed the CAN interface totally and connected the motor and hall sensors directly to my own controller. I achieved motor control but didnt get much farther due to family life and school (2 year cnc machinist program). Now things have settled down and I decided to re-explore VGT control again, and have been pleasantly surprised to find this group.

The 454 twin turbo project is a little stalled right now, I have an LQ4 build and retrofit for my 99 suburban project going on right now thats been taking up a lot of my spare time. Also I am doing a CNC conversion on a milling machine that I need functional really soon, its a big project which I hope to have done before the holiday season. After those two then its on to the 54 and VGT's.
 
  I sold the 454 for the pickup to my brother last month for his 67 firebird and he immediately put a Weiand blower on it. Crazy fast, but it would have been much better with the turbo's. I have two more 454 blocks left and will start building one for the Twin VGT's, probably sometime next spring. The truck is a '54 built from a combination of Chevy and GMC parts I had left over from other projects. Its riding on a 2wd S-10 frame with a 9" and 4-link setup. Induction is 2 HE351VE's into a modified Weiand Tunnel-Ram that has 16 injectors (2 per port). I plan to add an air-to-water intercooler setup, but I dont have that yet.

  I expect that the LILBB running on a gas engine will require several changes, but it looks like this controller is a good starting point to work from.  I think I'll set up a test unit on my work bench and get up to speed real soon. Has anyone run this controller on a gas engine yet? 

I've been programming AVR uC's for a decade using Bascom (which has worked very well for me) but just a few months ago I started acquiring some Arduino's and have started studying Arduino flavored C, seems kinda weird but there's a gigantic knowledge base and people tend to share a lot. Makes learning and troubleshooting so much easier. I've avoided C for years, but now I guess I need to just buckle down and learn it.

Cant wait to get started.
Marvin
Title: Re: Smartlynx stepper motor code (SPI)
Post by: hakcenter on September 09, 2015, 04:29:02 PM
Guy running it on his 4g63 turbo dsm. Didn't want full rpm from the turbo for whatever reason. Working out pretty good from the thread.
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on September 10, 2015, 08:59:06 PM
My project with the stepper motor is unrelated to the turbo control..

I am going to try and get my buddy to put a HE351 in his bridgeported '93 Rx7.. He's making about 550 rwhp right now, and if he could get more oomph off the line that would probably do more for his ET's than more top end power.

I want it in my truck with a 6 speed tranny for towing... I would also like to see if I can stuff a 64mm wheel onto it
Title: Re: Smartlynx stepper motor code (SPI)
Post by: Rx7man on October 08, 2015, 02:11:15 PM
Well, if I can help it, I am going to avoid any STmicro products.. ZERO tech support.. it's been 2 months since I started a ticket with them, I've updated it a couple times, and still nothing.  it's pissing me off in a big way.