PDA

View Full Version : L6470 Microstepper (128 step) sample Forth code



Peter Jakacki
10-18-2011, 09:18 AM
I've mentioned this L6470 chip (http://www.st.com/internet/analog/product/248592.jsp) a couple of times on this forum but this is the first time I am starting a thread about it. It's got to be the best stepper chip I've come across, and I've worked with quite a few. The last one was an A3985 microstepper driver which still needed external MOSFETs and current sense resistors etc. For steppers up to 3A rms this one is so compact in a 28 pin HTSSOP package, just needs a little copper to help spread the tiny amount of heat on heavy loads.

I will have some small Puppy style modules back soon if anyone wants to play with these chips, so get ready to rev your stepper motors.



fl
[ifdef L6470.fth
forget L6470.fth
]

: L6470.fth ;

\ L6470H Microstepper motion controller chip demo
\ (C) 2011 Peter Jakacki
\ Hardware: Propeller CPU
\ Software: PropForth 4.6
\
\ Handles 3A rms per winding. Uses SPI interface.

\ Define port allocations
\ Using Prop's EPROM I2C as clock and data to the L6470
\ Pullups on SDO (from L6470), BUSY, and FLAG as well as
\ precautionary pullups on CS and pulldown on RST
\
decimal
28 constant .SCL
29 constant .SDA

0 constant .SDI \ data from L6470
1 constant .BUSY \ busy flag - pullup with 10K
2 constant .CS1 \ Select master chip
3 constant .CS2 \ slave chip (or daisy chained)
4 constant .STCK1 \ step clock (optional, not used)
5 constant .STCK2
6 constant .FLAG \ pullup with 10K
7 constant .RST \ Chip standby/reset - pulled down with 10K



: !STEP
.RST dup pinout dup pinlo pinhi
.SCL pinout _sclh
.SDA pinout
.CS1 dup pinhi pinout
.RST1 dup pinlo pinout
.RST2 dup pinlo pinout
hex
;

variable response
hex
: TXRAW
_sclh
.CS1 pinlo
80 8 0
do
_scll
response @ 2* .SDI px? 1 and or response !
2dup and if _sdah else _sdal then
_sclh
2/
loop
2drop
.CS1 pinhi
;
: TX
begin .BUSY px? until
TXRAW
;

\ Made direction a variable to be added to the command so that it could
\ be "set and forget", no need to specify each time.
\
variable dir
: FWD 1 dir C! ;
: REV 0 dir C! ;
: +DIR dir C@ or ;


hex
: CMD TX dup 10 rshift TX dup 8 rshift TX ff and TX ;
: SYNCH 0 0 CMD ;

\ L6470 application commands - named similar as per programming manual
: NOP 0 TX ;
: REG! CMD ; \ Simply takes the address as a command and writes the data
: REG@ 0 swap 20 or CMD response @ ;

: RUN \ ( speed -- )
50 +DIR CMD ;

: MOVE \ ( steps -- )
40 +DIR CMD ;

: GoTo \ ( position -- ) Go to an absolute position
60 CMD ;

: GoToDIR \ ( position -- )
68 +DIR CMD ;

: GoUntil \ ( speed act -- )
3 lshift 82 or +DIR CMD ;

: ReleaseSW \ ( act -- )
3 lshift 92 or +DIR CMD ;

: GoHome 70 TX ;

: GoMark 78 TX ;

: ResetPos D8 TX ;

: ResetDevice C0 TX ;

: SoftStop B0 TX ; \ Stop after deceleration

: HardStop B8 TX ; \ Stop immediately

: SoftHiZ A0 TX ; \ Decelerate before bridge disconnection

: HardHiZ A8 TX ; \ Immediate bridge disconnection

: GetStatus 0 D0 CMD response @ 8 rshift ;

: MaxSpeed \ ( speed(10bits)
7 TX dup 8 rshift TX TX ;

\ Some console friendly aliases
: STOP SoftStop ;
: HOME GoHome ;
: GO GoTo ;

hex
: ShowStatus
dup 8000 and if ." Step Clock Mode" then
dup 4000 and 0= if cr ." Step Loss B" then
dup 2000 and 0= if cr ." Step Loss A" then
dup 1000 and 0= if cr ." Over Current" then
dup 0800 and 0= if cr ." Thermal Shutdown" then
dup 0400 and 0= if cr ." Thermal Warning" then
dup 0200 and 0= if cr ." Under voltage" then
dup 0100 and if ." Wrong command" then
dup 80 and if ." Command not performed" then
dup 60 and 5 rshift cr ." Motor Status =" .
dup 10 and cr ." Motor direction " if ." forward" else ." reverse" then
dup 8 and if cr ." Switch Event" then
dup 4 and if cr ." Switch Closed" then
dup 2 and 0= if cr ." Busy" then
dup 1 and if cr ." Bridge disconnected" then
cr drop
;

\ ********************* DEMO & DEBUG **********************

: L \ List the status of the chip for diagnostics
GetStatus ShowStatus
ina COG@ dup 2 and 0= if ." =busy " then 40 and 0= if ." =flag " then ;

: DEMO
!STEP \ Init Stepper chip
4000
begin
dup FWD MOVE
dup REV MOVE
10 -
dup 100 < if drop 4000 then
key?
until
;

: oldboot onboot ;
: onboot oldboot !STEP hex ;

lardom
12-24-2011, 02:39 PM
Peter, can we order L6470 modules from you?

idbruce
12-25-2011, 12:28 AM
Peter

It is nice to see another stepper driver in the forum :)

Bruce

hinv
12-25-2011, 12:00 PM
Got pictures?

28 Pins...for a stepper driver. Why so many?
When you say 128 microsteps, do you mean that for the typical stepper motor, you would get 128x200 possible positions per revolution? This sounds like way beyond the mechanical ability of a stepper.

Peter Jakacki
12-25-2011, 12:30 PM
Hi guys, I hope to have a website up early in the new year with a range of products for sale. I like to make these available at a reasonable price. I'm not trying to compete with anyone on specs or price but would you be happy to pay $29USD per module? I will have to check on shipping options. You can stack or parallel two modules as each has a master/slave solder jumper. Remember that the 6470 chip is a motor controller and driver so you can just issue commands to go here or there etc and it will handle the ramping and so on.

The footprint is standard for my range of Puppy modules with one connector devoted to high current and designed so that connections can be kept short. The underside of the PSM6470 is tinned and does not have a solder mask so I could attach a simple heatsink if I needed to (which I haven't). You can see one of the stepper motors that I run with this module, usually at 24 to 30V or so.

As soon as I can I will do a video of these in operation and show how easy they are to drive in software.

879548795587956

StephenMoore
12-25-2011, 06:20 PM
I would buy at 29 clams. ST has an eval board they sell for 63.

prof_braino
12-25-2011, 07:05 PM
The Reprap CNC uses four stepper drivers (X, Y, Z, and print head). We were thinking of using the work on Reprap as a starting point for other CNC, (milling, laser, etc)

Instead of single modules, would it be reasonable to make one board with four steppers?

Publison
12-26-2011, 12:29 AM
The Reprap CNC uses four stepper drivers (X, Y, Z, and print head). We were thinking of using the work on Reprap as a starting point for other CNC, (milling, laser, etc)

Instead of single modules, would it be reasonable to make one board with four steppers?

One could make a single control board with female sockets to accept Peter's boards without sacrificing any space, (well, maybe a couple of centimeters).

This would allow one to install only the number of driver boards need for the application, ( 1-5 boards for a 1-5 axis machine). And would allow for quick change of a defective stepper driver. With a high enough female adapter, a heat sink could also be implemented on the bottom of Peter's board.

idbruce
12-26-2011, 12:58 AM
Very nice.

Peter Jakacki
01-10-2012, 04:29 AM
I mentioned in one of my posts that I would get around to doing a video of this chip in action. I still haven't had a chance to hook it up to the big stuff but here's a sneak peek until then.

Youtube video (http://www.youtube.com/watch?feature=player_detailpage&v=9XALgBgqDdo)

How does an L298 compare with the L6470? Not at all, look at the left-hand photo, the L298 is huge, has a huge heatsink, still requires flyback diodes (which in this case are too small) and a stepper controller etc. It only drives the medium sized motor as seen in the video and not more than half-step. The right-hand photo shows a pair of L6203 DMOS drivers with two great big current sense resistors but still only half-step that drive the larger motor which is the same as the one driven by the L6470.

Also, the L298 is only a 2A driver, not 4A which is a total combined figure vs the L6470's rating of 3A rms per channel.


88405 88406

idbruce
01-10-2012, 11:59 AM
What do you reckon, pretty good?


Yeah, I reckon that is pretty nice. Well done.

Bruce

prof_braino
01-10-2012, 04:53 PM
So, how many pins from the prop does it take to run one of these? I think I'm counting 12 prop I/O pins consumed.

How many of these can one prop chip control?

photomankc
01-10-2012, 05:04 PM
So, how many pins from the prop does it take to run one of these? I think I'm counting 12 prop I/O pins consumed.

How many of these can one prop chip control?

It's SPI I see but I think some of the control lines are optional.

I would be very interested. I'm using a ChipKit Uno32 to give me much the same benefit running some steppers for a robot project, minus ramping between running speeds. I'd be really interested in this since it would almost be a drop in replacement except for SPI for what I'm doing and allow me to run some bigger NEMA-17s with even more torque. Could repurpose the Uno32 as more generic sensor controller. When I scoped out the chips to order them they were more expensive than I wanted to pay to get a small driver but $29 for a complete board would fall into the "I'll take 2" category.

MagIO2
01-10-2012, 07:30 PM
Hmmm .... if this is a complete controller doing the microstepping and ramping, how can you use 2 of them to run together in a perfect circle?

Publison
01-10-2012, 08:02 PM
Stunning layout and a great video Peter.

What's the current draw on the big motor?

Jim

MagIO2
01-11-2012, 06:42 AM
No replies to my question?! So, am I wrong saying that this driver does not work good for CNC setups - at least in the auto rampup/down mode? Or is there still the possibility to run it in single step mode? Guess I have to read the specs by myself ;o)

photomankc
01-11-2012, 09:25 PM
Well you're telling it how many steps to execute and what rate you want them executed at but it's going to determine the acceleration used and ultimately how fast the motor is actually going to go if there isn't enough room to ramp. Running an arc is going to take motion planning so you can keep the overall motion rate at X IPM by constantly ramping up and down in the two axis motors. It sure seems like a poor fit to that application on it's face. I don't see a way to just feed it step pulses.

Peter Jakacki
01-11-2012, 11:18 PM
No replies to my question?! So, am I wrong saying that this driver does not work good for CNC setups - at least in the auto rampup/down mode? Or is there still the possibility to run it in single step mode? Guess I have to read the specs by myself ;o)

Good point, I looked at the specs and I guess you would have to have a common external clock rather than the internal one plus you would need to load the two chips in parallel which I can do with my setup except for the external clock which I left off in this particular design. There is always the step clock input to manually control it I guess. I will jumper a couple of prototypes to use an external clock and have a go at synchronizing two motors to draw a circle, should be fun.

There are several registers which control the acceleration and deceleration profile so the chip doesn't try to do it's own thing, it will behave as you tell it.
Here's a link to a pdf article (http://www.eetasia.com/STATIC/PDF/201009/EEOL_2010SEP15_POW_EMS_TA_01.pdf?SOURCES=DOWNLOAD7 ).

BTW, I thought I sent this message off yesterday but when I checked this morning it wasn't so, the forum seems to have a timeout these days where you need to reload the page.

Your submission could not be processed because you have logged in since the previous page was loaded.

Please reload the window.

MagIO2
01-12-2012, 07:27 AM
Yep ... going to be fun ... and it already starts with straight lines. Suppose you want to mill a diagonal line where delta x = 1000 steps and delta y = 200 steps. If you simply tell 2 drivers to go to these positions you definitely won't get a straight line!
You really need to know exactly how the ramping works and calculate/set the according parameters beforehand. And the speed settings need to be calculated as well. Otherwise driver y is done long before driver x.
Hmmm ... external clock ... maybe this really helps. You drive x with clk and you drive y with clk * delta y / delta x. Then both drivers should reach the end of the movement in the same time. But the ramping parameters need to be calculated.

In special cases you also have to calculate the max. speed. If the number of steps for both is different and the number of steps of one driver is not enough to ramp up to full speed you also have to limit the other drivers max. speed ....

For circular or any other free form movement you really need some kind of single step-mode. Maybe you can tweak the min speed being the max speed and then send goto-commands step per step. But then a simple direction/step-driver is much easier.

All in all I think this driver suits much better to a PCB drilling machine than to a CNC mill, because there you don't care how you got to a point - take the shortest way is fine there!

Peter Jakacki
01-12-2012, 07:42 AM
To think that having these operations being directed by an external micro does not change matters at all, the variables still need to be taken into account. There is nothing magical or mysterious about the internal operation, it's documented and is configured through the SPI registers. Even if this chip were operated in it's totally dumb mode and using an external step clock with direction etc being set via SPI I still think it is a very good chip for these reasons if not more:

1) up to 128-step microstepping built-in with it's own current sensing (no resistors)
2) very compact and efficient 3A drivers
3) built-in protection with feedback to the controlling micro (over-temperature, stalled, over-current, etc)

@MagIO2 I've worked with a lot of different chips and discrete designs so I don't understand what your beef is with this chip, it's clearly superior to you name it.

MagIO2
01-12-2012, 10:30 AM
I do not doubt that you have superior experience with steppers. But what you show in the video is simply driving one stepper and that it perfectly works there. But prof_braino mentioned to use 3 of this drivers to run a CNC ( the reprap to be precise ).

I have to admit that I don't have experience with CNC so far ... only some plans to build one by myself somewhen in future. That's why I get attracted by those kind of threads. I could of course take all things I read as granted, but I prefere to think. And thinking often raises questions for example about this automatic ramping (which you mentioned in one of your first posts). I simply see the chance that it could be hard to let 2 (for a 2D mill setup) or more (for 2.5D mill) drivers work together in a way that you can mill -lets start with the simplest- a straight line in any possible direction.

To get a straight line in a 2D setup your ramping has to be synchronized over 2 drivers working with different speed values. A 2.5D mill adds another driver which needs to run synchronously. You have to take into account that the ramping might not reach the max-speed if the number of steps is to little for one driver whilst all other drivers would reach the max speed. This would definitely not end up in a straight line!

I did not have the time to read the full spec of the chip so far, so I did not know in my previous post if something like a "dumb mode" exists.

I think I raised valid questions and it's not about having a beef with this chip, I just want to have an idea if this can be solved with that driver in which way or not at all. The "All in all I think ...." sentence is only true for the knowledge I had at this time and hopefully it changes within this thread ;o)

And ... I would also be willing to buy some of those babys to find out, so please don't feel offended!

pedward
01-12-2012, 07:44 PM
From a CNC perspective (I've done a lot of this, including retrofits, programming, and repair), the motion controller is built in to the control, not the motor controller. The ramping is done by the motion controller and the motor driver is "dumb". This is so the motion controller can do accel and decel based on part features. I agree that accell/decel in the driver chip is only of use in 1 axis systems unless you have encoder feedback. Obviously encoder feedback is the part that most are trying to avoid with the use of a stepper in the first place.

Peter Jakacki
01-13-2012, 02:09 PM
Just a very brief reply while have the opportunity. Bear in mind that I showed a very simple demo of the chip, it is very basic and will have to do until I hook-up a larger system. Having motion control built-in is never a disadvantage as long as you also have manual control which you so have with this chip. Also I not sure why you think acc/dec features are a problem with multi-axis systems because it's not as if the acc/dec is not precisely known, set, and controlled. The chip even senses if steps have been missed based upon the BEMF which BTW is also compensated for. Anyway I can only tell you what I know and a multi-axis system implementation will tell all. If someone wants to play with these modules on a multi-axis system and share the experience then I would be happy to supply the modules no charge to that one. Prof? MagIO2?

idbruce
01-13-2012, 03:14 PM
@Peter

My name was not mentioned there, but I have a machine all designed, blanks cut, and ready to be drilled. This will be the PCB drilling machine which I have referred to several times on the forum. This is not the old driller, but a new design, which I intend to market on my web site. If the offer is open to me as well, I would like to review your product and post my opinion and findings, and if I am happy with them, I would seriously consider supplying them with my driller until I get around to making my own drivers.

Bruce

prof_braino
01-13-2012, 03:21 PM
If someone wants to play with these modules on a multi-axis system and share the experience then I would be happy to supply the modules no charge to that one. Prof? MagIO2?

Yes, please! Actually, I would send them off to Sal, he is the master. First I will send him the link to the datasheet, and he will decide if this is part of the schedule. I'm pretty sure this an pololu A4988 would be good baseline for CNC stepper control. BUT this won't be on the release list until summer, I think, since we are taking so long with 5.0 release.

If you would be interesting in send a set of 4 to Sal, I would be willing to buy another set of 4 so I can do testing. But let me run it by him first.

pedward
01-13-2012, 07:14 PM
I won't belabor the point, but I feel an explanation (if for the other viewers) is in order.

Let's say you want to draw a circle. The points of the circle are obviously calculated from sin/cosine. When you draw a quadrant of a circle, both axes are constantly changing acceleration in relation to each other. When you start the arc, one axis is moving slowest and the other fastest, the become equal when you reach the 45 degree point, then the acceleration reverses and the profile is repeated in reverse.

If your stepper driver is controlling acceleration and you have no control over destination and time, you cannot accurately control a multi-axis system without having realtime control over the motor position.

Let's consider how an older commercial closed loop system might work:

Servo A and Servo B have encoder feedback and velocity inputs. The controller has to modulate the velocity input to control the position of the motor and speed up or slow down the motor based on encoder feedback. This is realtime closed loop control.

Standard open loop stepper control is a bit simpler:

begin loop
is motor X step position in correct place
yes: skip
no: step motor
is motor Y step position in correct place
yes: skip
no: step motor

Run that loop a few k times per second and you have synchronous open loop stepper control. Each axis runs in lockstep with the others, no movements happen outside of that loop.

MagIO2
01-13-2012, 09:35 PM
@Peter: Thanks for that offer, but as I said I have plans to build my own CNC - which might happen sooner, but most propable it's going to happen later. So it's better for you to pick someone else.

pedward has now the right explaination for the concerns I had in the beginning. You NEED to control acceleration in a multi-axis setup to be able to have accurate free-form movements. That's why I said the ramping-mode of those drivers is usefull in PCB drilling setups, but not in CNC milling setups.
In milling setups it might be interesting to test whether the ramping mode might be usefull in some sense - that's the fun-part we talked about at the beginning ;o) Of course for positioning the mill it can be used. Maybe for straight lines it also makes sense?

What's your timeline? When do you plan to offer those babies for selling?

photomankc
01-18-2012, 04:57 PM
I'm also quite interested in your timeline. As I said, the main stumbling block I have now for StepperBot is that I can't ramp between speeds, I can ramp up and down from start to stop but I can't go from one speed to another without 'slam-and-hope' or stopping. This would be perfect since it takes the load of calculating accel out of the picture for my application which will work fine and the current capacity means I can possibly use some of the 80 to 100oz/in NEMA17's I have seen out there.

Peter Jakacki
01-19-2012, 01:02 AM
@Prof & Bruce - Please msg or email me with a delivery address if you would like to sample a set of four stepper modules. I will supply them with the matching low-profile sockets. I haven't had much time to spend on these steppers but I have found since the video was taken that I had forgotten to lift the lid on the maximum speed, there's quite a difference but I will record some acc/dec profiles later and post these.

idbruce
01-19-2012, 01:25 AM
@Peter

Thanks Peter.

Building my new PCB Driller is my next order of business after I finish my exposure box samples. As I mentioned, the blanks for the machine are all cut and the main thing left is drilling and tapping the pieces. I will have to do some research just to find all the specs for these drivers, but I should be able to find them.

"I ain't hiding from nobody, nobodys hiding from me" - Lynyrd Skynyrd(Call Me The Breeze)
Just in case someone wants to hear a nice live version :) http://www.liveleak.com/view?i=f30_1317204020

Since it is already on my patent information that I posted here and on my web site, my address isn't a secret.

Bruce Drummond
144 North Michigan Avenue
Hobart, Indiana 46342

Anyhow, I will give them a good testing. They should be a nice fit for the new machine :)

Thanks again Peter

Bruce

photomankc
02-22-2012, 04:44 PM
Is this still going anywhere? I cant produce the pads needed to use the 0.65mm leads on these guys reliably so I'd either have to send the PCBs out to be made or buy them pre-made. Since I also rarely get it right the first time that's probably going to cost too much to be practical. My bot could definately benefit from these if you still plan to make them.

prof_braino
02-23-2012, 10:06 PM
We are still finishing the propforth release, so peter will hold off sending us samples till the next release is out. Sal is planning a set of CNC extensions as the next step in the project, so this is definitely still on the list.

Peter Jakacki
03-21-2012, 06:56 AM
I have only just been getting back to this stepper board and running some tests on a 91mm NEMA34 (34HY1801) motor @24V. It seems with the mass of an drive roller attached I can run this at up to 2400rpm. I have a particular job where I need to ramp from normal process speed up to as high a speed as possible for half a second or so.

Just wondering what kind of speeds are achievable with other steppers and motors? Has anyone done any tests in this regard?

Tubular
03-21-2012, 07:27 AM
I think you're into brushless servo kind of territory, assuming the normal process speed is slow.

That said a DOL started 2 pole induction motor would hit 2900 rpm pretty quickly, but I assume you need accurate positioning too.

What kind of drive roller diameter? What kind of power is that stepper, 60 watts or so?

Peter Jakacki
03-21-2012, 07:51 AM
I've got a 60mm diameter roller on the end of it which drives a 300mm long belt and there's another NEMA34 on the other side and normally the motors are running at the exact same speed. The winding is 1.2 ohms and rated at 2.8A but the average measured running current total for each motor is normally around 0.5A.

Peter Jakacki
03-22-2012, 02:47 PM
I have done a lot of tests now and have concluded that with a nominal 24DC supply that I can run this motor reliably up to 2000 RPM and I have pushed it to over 2500 RPM but it's that weak a feather could stop it. There are a lot of registers in the L6470 that aren't explained very well but I think I have enough of a handle on it for now. Here's a short video (http://www.youtube.com/watch?v=MOhjx7oEM4A) if you are interested.


http://www.youtube.com/watch?v=MOhjx7oEM4A

90883

photomankc
03-22-2012, 06:35 PM
Love the sound... you can hear how smooth it is. Yes this would be a very nice addition to my bot. NEMA34s really don't like to go fast. On the low end they have really great torque but they drop like cliffs as the RPMs increase. I'll bet you could get a NEMA 23 that had more torque at the higher RPMs.

I'll be anxious to see these come out. My bot is limited to 8 microsteps just because the controller can't provide more PPS while also figuring accel. With these I'm free to let the chip do the work and let the controller handle the I2C command interface without concern for stepping on the toes of the pulse generation.

I'm over here, patiently waiting (drums fingers!) :)

prof_braino
03-23-2012, 03:00 AM
I have four NEMA34 for the next rig I build. Will these be OK if we want to go fast to move to a new position, but only need torque when we want to move slow (ie with the tool engaged)?

I think I remember something about dynamically adjusting voltage or current depending on speed or load. Doe the L6470 support this?
Sal said it shouldn't be a problem for the software, I think he's building this into the stepper functions.

Peter Jakacki
03-23-2012, 04:01 AM
Prof: There are a lot of things that the chip does automatically although it does rely on what you load into the registers but it can also be run under external control quite easily. There are a couple of ways of doing this and my module brings out the discrete step clock pin also. So it's possible to setup the direction, current, etc over SPI and then issue individual step clocks from the Prop if you really want.

BTW, since I'm back in the stepper saddle I will organize to send off the sample modules to you as well as to others who have been waiting :)

Peter Jakacki
03-26-2012, 05:23 AM
Wow! I've pushed my NEMA34 up to 3400 RPM and beyond. The L6470 can be set to switch to full-step mode automatically above a set threshold and so I am running the motor in full-step mode at this speed. Sure is fast for a big motor. I will try a smaller motor next to see how fast I can push it.

idbruce
03-26-2012, 10:09 AM
Peter



Wow! I've pushed my NEMA34 up to 3400 RPM and beyond. The L6470 can be set to switch to full-step mode automatically above a set threshold and so I am running the motor in full-step mode at this speed. Sure is fast for a big motor. I will try a smaller motor next to see how fast I can push it.


For the last 24 hours, I have been reexamining some of my old schematics and reviewing the characteristics of both the L6470 and the L6208. During this time, I have been weighing the value of speed (full/half step) versus accuracy (microstep), and then it dawned on me about this threshold. As you know, the L6208 is intended for half/full step operation, whereas the L6470 is intended for microstepping operation, however I am now contemplating putting D/A converters on VREF_A and VREF_B of the L6208 to achieve somewhat of a programmable resolution (microstepping thru full stepping). I would assume this is similar to what you are referring to on the L6470.

Bruce

Peter Jakacki
03-26-2012, 02:49 PM
I'm familiar with the L6208 and other variants etc and I don't think that there is anything that they can do that the L6470 can't. Look, if you don't use all the features and just run the L6470 in dumb full/half step mode with an external step clock you are still far better off IMO than using the L6208 in this dumb mode. Once you start using any degree of current control or micro-stepping then you are already in front as it's all built-in, you don't even need external current sense resistors. BTW, the stepping modes can be set from full-step, half-step etc to 128 microsteps. These chips run as cool as cucumbers.

Anyway, I found a bug with this auto full-step switching as it appears it doesn't actually switch to full-step but another microstep mode instead. However I am awaiting some feedback from ST about this.

idbruce
03-26-2012, 03:01 PM
Peter

I was contemplating ordering some L6470 samples from ST, I just have not done that yet. As for now, I already have several of the L6208s laying around, and a lot of the layout has been done, so I am pretty much just finishing up what I have and I will experiment a little. The main reason I am doing this now is so that I have a real world example for my exposure box thread. I am sure I will order some of the L6470s and experiment with those as well in the future. I just don't have the time available to start it all from scratch.

I am sure the L6470 is a much better chip.

Bruce

Peter Jakacki
03-26-2012, 03:11 PM
Bruce, that reminds me that I was going to send you a couple of samples, so sorry about the delay since I haven't been playing with these devices for quite a few weeks a I get distracted. I will send two control boards off to you tomorrow.

idbruce
03-26-2012, 03:14 PM
Peter

There is no rush. I have not had the time to devote to the PCB driller as I intended, and I don't imagine that I will get to it for at least a couple more weeks.

Bruce

idbruce
03-28-2012, 10:03 PM
Peter

I just received three of the L6470HTR. Talk about small, these things are tiny :) How do you manage to work with them? WOW :)

Peter Jakacki
03-29-2012, 12:56 AM
Didn't you see the photos, the tiny chip .... on the tiny pcb ..... on the BIG BAD stepper motor. You know that I just use a dedicated toaster oven for making up my prototypes and with a little solder paste all this tiny SMD stuff is a pushover.

Since I'm back on this thread I have included some updated Forth code. Most of this code is for interacting with the steppers and viewing results.


fl
[ifdef L6470.fth
forget L6470.fth
]

: L6470.fth ;
{
************************************************** ***********
L6470H Microstepper motion controller chip demo

March 2012 Peter Jakacki

Hardware: Propeller CPU (P1109 PuppySolo CPU module)
L6470 Stepper controller (PSM6470 MicroStepper module)
P1121 Motor Controller motherboard
Software: PropForth 4.6

Handles 3A rms per winding. Uses SPI interface.

Define port allocations
Using Prop's EPROM I2C as clock and data to the L6470
Pullups on SDO (from L6470), BUSY, and FLAG as well as
precautionary pullups on CS and pulldown on RST
************************************************** ***********
}
decimal
28 constant .SCL
29 constant .SDA

0 constant .SDI \ data from L6470
1 constant .BUSY \ busy flag - pullup with 10K
2 constant .CS1 \ Select master chip
3 constant .CS2 \ slave chip (or daisy chained)
4 constant .STCK1 \ step clock (optional, not used)
5 constant .STCK2
6 constant .FLAG \ pullup with 10K
7 constant .RST \ Chip standby/reset - pulled down with 10K

15 constant .SENSOR2
14 constant .SENSOR1 \ NORMALLY LOW


0 constant OFF
-1 constant ON

variable response
variable unit
hex
: SELECT unit ! ;
: CS unit @ ;
: MASTER .CS1 SELECT ;
: SLAVE .CS2 SELECT ;
: TXRAW
_sclh
CS pinout CS pinlo
80 8 0
do
_scll
response @ 2* .SDI px? 1 and or response !
2dup and if _sdah else _sdal then
_sclh
2/
loop
2drop
CS pinin ;

: WAIT begin .BUSY px? until ;

: TX WAIT TXRAW ;

\ Made direction a variable to be added to the command so that it could
\ be "set and forget", no need to specify each time.
\
variable dir
: FWD 1 dir C! ;
: REV 0 dir C! ;
: +DIR dir C@ or ; \ adds direction into the command


decimal

\ this little table holds the bit size of each register so that read and writes of longs can be automatically formatted
variable regsize -4 allot
00 c, 22 c, 09 c, 22 c,
20 c, 12 c, 12 c, 10 c,
13 c, 08 c, 08 c, 08 c,
08 c, 14 c, 08 c, 08 c,
08 c, 04 c, 05 c, 04 c,
07 c, 10 c, 08 c, 08 c,
16 c, 16 c, 00 c, 00 c,

hex

\ Writing to a register is a SetParam command with the register address as the PARAM field
\ Up to 3 bytes of data are needed but unfortunately the byte order varies depending upon the register's size
\ So a lookup is performed in the regsize table and the data arranged accordingly

: REG! \ ( dat reg -- )
0 response !
dup 1F and regsize + C@ \ determine bit size of the register ( dat reg size )
dup 9 < if drop else \ 8 bits or less ? ( dat reg )
10 > if TXRAW dup 10 rshift then \ 16 bits or more ? then send: reg bits16..24
TXRAW dup 8 rshift then \ 9 to 15 bits send: cmd bits8..15
TXRAW TXRAW \ this is either CMD+DAT or trailing
;

\ Modify register address into a GetParam command and send null data while the TXRAW routine reads the response
: REG@ \ ( reg -- data )
0 swap 20 or REG! \ issue corresponding bytes
response @ \ pickup response assembled by TXRAW
;

hex
\ Getstatus does not wait if the L6470 is busy but performs a non-invasive status read
: GetStatus \ ( -- status ) \ if no response is received (no chip) then return with 0 as status
D0 TXRAW 0 TXRAW 0 TXRAW 0 TXRAW response @ 8 rshift dup FFFFFF = if drop 0 then ;


\
: CMD \ ( dat cmd -- )
TX dup 10 rshift TX dup 8 rshift TX ff and TX
GetStatus drop ;

\ : SYNCH 0 0 CMD ;

\ L6470 application commands - named similar as per programming manual
: NOP 0 TX ; \ also useful to cause application to wait until controller is ready

: RUN \ ( speed -- )
50 +DIR CMD ;
: MOVE \ ( steps -- )
40 +DIR CMD ;
: GoTo \ ( position -- ) Go to an absolute position
60 CMD ;
: GoToDIR \ ( position -- )
68 +DIR CMD ;
: GoUntil \ ( speed act -- )
3 lshift 82 or +DIR CMD ;
: ReleaseSW \ ( act -- )
3 lshift 92 or +DIR CMD ;
: GoHome 70 TX ;
: GoMark 78 TX ;
: ResetPos D8 TX ;
: ResetDevice C0 TX ;
: SoftStop B0 TX ; \ Stop after deceleration
: HardStop B8 TX ; \ Stop immediately
: SoftHiZ A0 TX ; \ Decelerate before bridge disconnection
: HardHiZ A8 TX ; \ Immediate bridge disconnection

\ Register names - mainly for convenience and readability
\ Keep these names to less than 8 characters to maintain an order NFA
01 constant @POS
02 constant @EPOS
03 constant @MARK
04 constant @SPEED \ current speed
05 constant @ACC \ acceleration
06 constant @DEC \ deceleration
07 constant @MAX \ max speed
08 constant @MIN \ min speed
09 constant @HOLD \ hold current
0A constant @RUN \ run current * adjust this for slower speeds - while running
0B constant @STACC \ accel starting current
0C constant @STDEC \ dec staring current
0D constant @INTSPD \ Intersect speed
0E constant @ACCSS \ Acceleration start slope
0F constant @ACCFS \ Acceleration final slope
10 constant @DECDS \ Deceleration final slope
11 constant @THERM \ Thermal compensation factor
12 constant @ADC \ 5 bits of ADC reading supply voltage
13 constant @OCD \ overcurrent threshold
14 constant @STALL \ stall threshold
15 constant @FSSPD \ full step speed threshold
16 constant @STEPMD \ controls number of microsteps or none
17 constant @ALARMS \ alarm mask
18 constant @CONFIG \ PWM and clock control etc
19 constant @STATUS


\ Some console friendly aliases
: STOP SoftStop GetStatus drop ; \ Stop and also read the status to clear any errors
: HALT B8 TXRAW ; \ Stop immediately, override any operation
: DISC SoftHiZ ; \ Disconnect the bridge - also needed before certain commands can be written
: HOME GoHome ;
: GO GoTo ;

hex
: CONFIG! STOP DISC @CONFIG REG! ;
: PWMDIV \ ( 1..7 --)
1- 0 max 07 and 6 min 0D lshift @CONFIG REG@ 1FFF and or CONFIG! ;
: PWMDEC \ ( 0..7 -- ) multiply the PWM freq from 0.625 to 2 in 0.125 increments
7 and 0A lshift @CONFIG REG@ E3FF and or CONFIG! ;
: SLEW \ ( 0..3 -- ) adjust the slew rate as 180,180,290,530
3 and @CONFIG REG@ FCFF and or CONFIG! ;

: VSCOMP \ ( on/off -- )
if 20 else 0 then @CONFIG REG@ 20 invert and or CONFIG! ;


decimal

\ Initialization table values to suit motor and application
\ Multiple tables can be setup for various motors and the table pointer
\ passed to the INIT routine if necessary. Just this one at present.
\ This is a 34HY1801 Nema34
\
variable inits -4 allot \ variables points to start of table
decimal \ some motor properties in same table but not part of L6470 registers
\ first 5 values are not loaded into registers but represent motor constants
200 w, \ steps/rev
231 w, \ rpmcon
0 w,
0 w,
0 w,
\ REG 5
400 w, \ Acceleration
400 w, \ Deceleration
452 w, \ Maximum speed (for sm7)
0 w, \ Minimum
20 w, \ Holding current
32 w, \ Run current
64 w, \ Acceleration starting current
32 w, \ Deceleration starting current
1032 w, \ Intersect speed
128 w, \ Start slope
19 w, \ Acceleration final slope
64 w, \ Deceleration final slope
0 w, \ Thermal compensation
0 w, \ ADC (read only)
15 w, \ Over-current threshold
127 w, \ Stall Threshold (set to max)
550 w, \ Full step speed (changes from microstep)
7 w, \ Step mode
hex
FF w, \ Alarm enables
1E80 w, \ Config \ 2e88
0 w, 0 w, 0 w, \ reserved


: INIT@ 2* inits + W@ ;

hex
: !REGS HALT DISC 19 5 do i INIT@ i REG! loop ;

variable status
: INIT
.RST dup pinout dup pinlo pinhi \ Hardware reset - pulse line low
_sclo _sclh _sdao \ Use I2C lines as outputs for clock and data in (L6470)
.CS2 dup pinhi pinout \ chip selects
.CS1 dup pinhi pinout
SLAVE !REGS GetStatus status 2+ W!
MASTER !REGS GetStatus status W!
;
1

hex

: STEPS \ ( steps -- )
@STEPMD REG@ lshift 3FFFFF min MOVE ;

: TURNS \ ( turns -- )
0 INIT@ * STEPS ;

: READY? \ ( -- rdyflg )
GetStatus 2 and ;

: BUSY? \ ( -- bsyflg )
READY? 0= ;

decimal
: RPM \ ( rpm -- ) Run motor at speed to match rpms
1 INIT@ * RUN ;

hex
\ Rough conversion from ADC reading to voltage (pretty close)
: VOLTS @ADC REG@ 9 * 2/ 2/ 2/ ;

\ Simply for console diagnostics to see the status register conditions
: ShowStatus
dup if
dup 8000 and if cr ." Step Clock Mode" then
dup 4000 and 0= if cr ." Step Loss B" then
dup 2000 and 0= if cr ." Step Loss A" then
dup 1000 and 0= if cr ." Over Current" then
dup 0800 and 0= if cr ." Thermal Shutdown" then
dup 0400 and 0= if cr ." Thermal Warning" then
dup 0200 and 0= if cr ." Under voltage" then
dup 0100 and if cr ." Wrong command" then
dup 80 and if cr ." Command not performed" then
\
cr ." Speed = " @SPEED REG@ 1 INIT@ / . ." RPM"
dup 60 and 5 rshift
dup 0= if ." stopped" then
dup 1 = if ." accelerating" then
dup 2 = if ." decelerating" then
3 = if ." constant" then
dup 10 and if ." forward" else ." reverse" then
dup 8 and if cr ." Switch Event" then
dup 4 and if cr ." Switch Closed" then
dup 2 and 0= if cr ." Busy" then
dup 1 and if cr ." Bridge disconnected" then
cr ." Steps/full step = " @STEPMD REG@ 1 swap lshift .
cr ." Input Voltage = " VOLTS decimal . ." V"
else
." - No device "
then
drop
;


\ ********************* DEMO & DEBUG **********************
\
\ Short diagnostic functions which simplify keyboard entry

\ List Registers ( in current number base )

\ Use the name for the register as provided in the compiled constant names (tricky)
' @POS _forthpfa>nfa constant regstr
: .NAME 1- 4 lshift regstr + dup C@ 0F and swap 1+ over .str 0A swap - spaces ;

hex
: LR
." REG NAME MASTER SLAVE DEFAULT "
\ 01: 0020571A 00000000 000000E7
1A 1 do cr i .byte 3A emit space i .NAME
MASTER i REG@ .long space SLAVE i REG@ .long
4 spaces i INIT@ .long loop cr MASTER ;

\ List the status of the chips
: L \ List the status of the chip(s) for diagnostics
\ busy and flag pins are common
ina COG@ dup 2 and 0= if ." =busy " then 40 and 0= if ." =flag " then
SLAVE GetStatus dup if cr ." SLAVE " dup ShowStatus then drop
MASTER GetStatus dup if cr ." MASTER " dup ShowStatus then drop
cr
;

\ Stop both motors
: S SLAVE STOP MASTER STOP ;

\ set step mode 0..7 (up the max on full step)
: SM DISC dup @STEPMD REG! if 1C0 else 2FF then @MAX REG! ;

\ write config register
: CFG DISC @CONFIG REG! ;
\ Set RUN current
: RC @RUN REG! ; \ SET RUN CURRENT



\ Some extra test functions
decimal
\ spin the motor back and forth at max speed
: DEMO
begin FWD 2000 RPM 3000 ms REV 2000 RPM 3000 ms key? until STOP ;

lardom
03-29-2012, 04:07 AM
Peter, when you apply solder paste for the Q44 are you saying it's easy? I bought three smt Props and solder paste but I hesitate because I assume I'll get it wrong a few times.

Peter Jakacki
03-29-2012, 04:28 AM
I have threatened to do a video to show how easy it is, so I will see about doing one now. However you will find that rather than being ultra-careful I just run a bead of paste across the middle of the pads so that it spans the pads. When I place the Prop or the L6470 I smudge it in a little then when it goes into the preheated toaster oven set at max it takes around 3 minutes for the solder to start to reflow. I leave mine in for about 4 minutes and sometimes 5 if it looks like it needs it as the toaster elements are a bit rough with temperature regulation. However I have never really had any real problems and sometimes I might have to clean up a few bridges either with the end of a flat iron tip or if that doesn't work then a splodge of flux then the iron again. Very rarely do I need the solder wick. Rather than placing the pcb on the rack in the oven I place it on aluminum foil thats been folded up into about four or more layers to act as a tray. When you remove this tray from the oven using a flat piece of metal as a pizza shovel then you find that the foil cools down very quickly plus it also cushions the pcbs a bit from vibration. I have been using the solid tray that comes with the oven lately and as long as I'm careful not to knock it then it seems to work well too.

The pcbs you see in the photos in this thread have been made this way.

There's probably lot's of little things I forget to mention so a video should clear it up a bit.

prof_braino
03-29-2012, 03:15 PM
Since I'm back on this thread I have included some updated Forth code. Most of this code is for interacting with the steppers and viewing results.

Great stuff, thanks for sharing!

Can I ask questions about your code? Mostly little stuff to establish common formatting and use conventions. Forth code is easy, the thought process behind it is what throws me. :)
Is there a coding standard you follow, I would like to look at what being used as a "Propforth coding standard" starts to evolve.

For example, what does the period represent? That the label is a prop I/O pin? Usually I see period prefixed to a label to indicate that a value will displayed on the screen (like period pops and displays the top stack item), have you seen that before?

Also fetch and store words: I see that you append @ to labels for constants, is there some generalization we can make when we see these in your code?

My thought is that at some point we might do a group review of code that we wish to add to the extensions or change in the kernel, so we make thing more clear and easier to follow. With out getting too cumbersome, I'd like to start on a "style guide" if we can make some consensus. (Sal continues to write code "stream of consciousness" until we establish a standard to which we can compare).

Thanks!

Peter Jakacki
03-29-2012, 04:05 PM
I wouldn't take any of my stuff as any kind of standard, it just works for me. The periods that are prepended to the constants are a bit of a carry over from assembler I think where I couldn't do much with symbol names but just enough to give me a hint that it is a pin constant although it could be confused with the Forth print function. However my variables are lower case to separate them from actual application code which is either upper-case or CamelCase as I do_detest_the_annoying_underscore. There are many times when I have a variable called for instance "sample" and the word that uses the variable with the same name except capitalized in some fashion such as "SAMPLE". Long names are descriptive and "nice" I guess but being more succinct is far more desirable and also a lot easier to remember and to type into the terminal. That's also why I have aliases for some words to make it easier to type with one hand while the other holds a probe etc.

Now as for the @ symbol prepended to the constants well that's to signify an address of some kind like saying "AT this address" so @ACC is the address of the acceleration register. The @ after a word is always read as FETCH of course. I'm also not adverse to placing a long line of code if it makes sense to.

I aim for readability (at least for me) but stack manipulation gets in the way of that but then again, where would Forth be without the stack? Interestingly I normally implement a separate stack for the loop parameters in my Forths rather than using the return stack. That way I can factor out code and still reference the loop parameters without touching the return stack (always a recipe for disaster I find).

Forth on the Prop is very useful but also very cumbersome compared to more conventional processors so I don't mind if things aren't all that standard, plus I never did like any of the Forth standards formulated by committees, they are too full of compromises and/or they try to put everyone's ingredients into the same pot. I also can't get over the fact that although Forth's real strength is in real-time and embedded systems the focus in the standards seem to be bloated and PC-centric.

prof_braino
03-31-2012, 04:17 PM
I'll save talk of "coding standards" until we start peer reviewing extensions to add to the main archive, if that ever comes about.

Not to get too much further off topic (I could move this to another thread if you wish) is your third stack along the lines of vannorman and koopman?
http://www.ece.cmu.edu/~koopman/forth/rochester_90b.pdf
Sal and I talked about this for goofy stuff like float and software multitasking, and Sal advised to "not go nuts" until we go the kernel working.

dli
04-02-2012, 10:50 AM
Hello,

I am using 'Trinamic' chipset (TMC428 & TMC249).
And I want to design a new 'Microstepper'.

The L6470 specifications are very good.
And the price and size of this solution is a 'winner'.

Before purchasing the evaluation board, I am wondering if this chip can also control a basic 'brush DC Motor'
With the internal H bridge, it could easily drive 2 brush DC Motor or 1 super brush DC Motor.
But in the specification I cannot find this information.

If you already have the evaluation board, Could you tell me if this feature is possible ?

I don't use brush DC motor very often, but it could be a plus.

Regards,

dli

Peter Jakacki
04-02-2012, 01:25 PM
While the L6470 is IMO a very good microstepper controller and driver I doubt very much that it would be a good solution for DC motors. The only way to directly control what the outputs will do is to write directly to the electrical position register EL_POS and even then I don't think it's a great solution. So it's no wonder you didn't find it in the specification because it's not specified or designed to wash dishes or drive DC motors. But all that depends upon what degree of "plus" you are after. I will probably try some DC motors just for the fun of it and who knows???

dli
04-02-2012, 02:51 PM
Ok thank you for the answer.

I did not expect the L6470 to drive brush DC motors.
But it was a possibility.

I noticed the L6460 chip.
It is a dual solution Microstepper/brush DC motors.
But there is a 1/16 limitation on the Microstepper side.

Anyway I also found a Texas Instrument solution:
DRV8412 (or32) + F28035 microcontroller.
It is a chipset solution and I need to add some external components to get a current feedback.
The price of this solution is x2 the one with L6470 (the pcb size is also bigger).

Regards.
dli

chazs
06-14-2012, 08:08 PM
Hi ,
Been a while since this tread has had activity - has there been any further developments on the task of demonstrating the use of l6470s in a cnc capacity ?
thanks
chaz

Peter Jakacki
06-15-2012, 03:13 PM
Here's some updated code I use for this chip on my P1121 dual stepper pcb with the PuppySolo. This is loaded just like any other PropForth extension by pasting the text into a terminal (at 230400 baud) and then backing up the compiled code with the "saveforth" command. After that I just load my simple application on top of that without having to touch the driver again. This is more than a driver though as it is setup for diagnostics and formatting results.

I have a couple of P1121 sets here that I am sending Tubular and possibly a set to Prof Braino so they can play with these on their CNC machines and report back.
93522

EDIT: I can setup a unit hooked-up to a couple of motors running PropForth and connect via Bluetooth back to an XPORT module (or maybe a Spinneret) that would be accessible via TELNET and also have a webcam running. While viewing the webcam stream someone could TELNET and start typing commands and even enter code if they want. If you want to telnet the best Windows terminal to use IMO is TeraTerm (via Sourceforge). Let me know if you are interested and I will set it all up over the weekend, maybe with something interesting attached to the motors. What's the best way of getting the TELNET data so others can see it? I guess maybe just plant a monitor in the webcam view?



fl

[ifdef L6470
forget L6470
]

: L6470 ." L6470 MicroStepper V1.1 120602" ;

{
L6470 Microstepper driver module - load in before application code and issue "saveforth" to lock into PropForth
2012 Peter Jakacki
Using: PropForth 5.2 (beta)
Compiled including diagnostics etc takes around 3.3kB
Implemented on PuppySolo - working configuraton uses two L6470 modules
.BUSY and .FLAG lines are monitored (and used) but are superfluous as status register can be read
Step clock STCK lines could be useful for CNC modes where steps have to be synchronized
.RST is probably not needed either but is a quick way to reset all stepper drivers.
}

decimal

0 constant .MISO \ MISO data from L6470 - multiple outputs are commoned with 220R in each output.
1 constant .BUSY \ busy flag - pullup with 10K
2 constant .CS1 \ Select master chip
3 constant .CS2 \ slave chip (or daisy chained)
4 constant .STCK1 \ step clock (optional, not used here)
5 constant .STCK2
6 constant .FLAG \ pullup with 10K
7 constant .RST \ Chip standby/reset - pulled down with 10K

28 constant .SCK \ SCL is shared with SCK
29 constant .MOSI \ SDA is shared with MOSI


0 constant OFF \ I like to be able to say OFF VALVE and sensible stuff like that
-1 constant ON

variable response \ holds the last response
wvariable unit \ remember which unit was selected (MASTER or SLAVE)
hex
: !PIN dup pinhi pinout ;

: SELECT unit W! ;
: CS unit W@ ;
: MASTER .CS1 SELECT ;
: SLAVE .CS2 SELECT ;

\ Transmit serial data to L6470 - couold benefit from some PASM eventually
: TXRAW \ ( data -- ) \ Sequence: CS LO + 8x(SCL LO + RD + WR + SCL HI) + CS HI 80us/bit
_sclh
CS pinout CS pinlo
80 8 0 \ Start with mask = MSB = 80 and loop 8 times from 0 to 7
do
_scll \ clock low then read MISO data
response L@ 2* .MISO px? 1 and or response L!
\ dup both data and mask and test bit and set MOSI
2dup and if _sdah else _sdal then
_sclh \ clock the data into the L6470 on low-to-high
2/ \ shift mask right
loop
2drop \ discard the data and mask (yeah, us Forthers get down and dirty and do our own garbage collection!)
CS pinin \ Let the CS float high (allowing other cogs to take control perhaps)
;

\ This could just do a readstatus register instead (using TXRAW)
: WAIT begin .BUSY px? until ;

: TX WAIT TXRAW ;

\ Made direction a variable to be added to the command so that it could
\ be "set and forget", no need to specify each time.
\
wvariable dir
: FWD 1 dir C! ;
: REV 0 dir C! ;
: +DIR dir C@ or ; \ adds direction into the command


decimal

\ this little table holds the bit size of each register so that read and writes of longs can be automatically formatted
variable regsize -4 allot
00 c, 22 c, 09 c, 22 c,
20 c, 12 c, 12 c, 10 c,
13 c, 08 c, 08 c, 08 c,
08 c, 14 c, 08 c, 08 c,
08 c, 04 c, 05 c, 04 c,
07 c, 10 c, 08 c, 08 c,
16 c, 16 c, 00 c, 00 c,

hex

\ Writing to a register is a SetParam command with the register address as the PARAM field
\ Up to 3 bytes of data are needed but unfortunately the byte order varies depending upon the register's size
\ So a lookup is performed in the regsize table and the data arranged accordingly

: REG! \ ( dat reg -- )
0 response L!
dup 1F and regsize + C@ \ determine bit size of the register ( dat reg size )
dup 9 < if drop else \ 8 bits or less ? ( dat reg )
10 > if TXRAW dup 10 rshift then \ 16 bits or more ? then send: reg bits16..24
TXRAW dup 8 rshift then \ 9 to 15 bits send: cmd bits8..15
TXRAW TXRAW \ this is either CMD+DAT or trailing
;

\ Modify register address into a GetParam command and send null data while the TXRAW routine reads the response
: REG@ \ ( reg -- data )
0 swap 20 or REG! \ issue corresponding bytes
response L@ \ pickup response assembled by TXRAW
;

hex
\ Getstatus does not wait if the L6470 is busy but performs a non-invasive status read
: GetStatus \ ( -- status ) \ if no response is received (no chip) then return with 0 as status
D0 TXRAW 0 TXRAW 0 TXRAW 0 TXRAW response L@ 8 rshift dup FFFFFF = if drop 0 then ;


\ Sends a command to the L6470
: CMD \ ( dat cmd -- ) \ Send "cmd" then 3 bytes of data high byte first
TX dup 10 rshift TX dup 8 rshift TX FF and TX
GetStatus drop ;


\ L6470 application commands - named similar as per programming manual

: NOP 0 TX ; \ also useful to cause application to wait until controller is ready

: RUN \ ( speed -- )
50 +DIR CMD ;

\ Manual step clock command
: STEPCK 58 +DIR TX ;
\ Issue step clocks - make sure L6470 is in STEPCK mode
: XSTEP .STCK1 dup pinhi pinlo ;
: XSTEPS swap 0 do XSTEP dup 0 do loop loop drop ;


: MOVE \ ( steps -- ) \ automatically accels and decels
40 +DIR CMD ;
: GoTo \ ( position -- ) Go to an absolute position
60 CMD ;
: GoToDIR \ ( position -- )
68 +DIR CMD ;
: GoUntil \ ( speed act -- ) \ not used here as it uses a homing switch
3 lshift 82 or +DIR CMD ;
: ReleaseSW \ ( act -- )
3 lshift 92 or +DIR CMD ;
: GoHome 70 TX ;
: GoMark 78 TX ;
: ResetPos D8 TX ;
: ResetDevice C0 TX ;
: SoftStop B0 TX ; \ Stop after deceleration
: HardStop B8 TX ; \ Stop immediately
: SoftHiZ A0 TX ; \ Decelerate before bridge disconnection
: HardHiZ A8 TX ; \ Immediate bridge disconnection

\ Register names - mainly for convenience and readability
\ Keep these names to less than 8 characters to maintain an indexed NFA used by LR for diagnostics
00 constant @REGS
01 constant @POS
02 constant @EPOS
03 constant @MARK
04 constant @SPEED \ current speed
05 constant @ACC \ acceleration
06 constant @DEC \ deceleration
07 constant @MAX \ max speed
08 constant @MIN \ min speed
09 constant @HOLD \ hold current
0A constant @RUN \ run current * adjust this for slower speeds - while running
0B constant @STACC \ accel starting current
0C constant @STDEC \ dec staring current
0D constant @INTSPD \ Intersect speed
0E constant @STSLP \ start slope - BEMF compensation curve
0F constant @ACCFS \ Acceleration final slope
10 constant @DECDS \ Deceleration final slope
11 constant @THERM \ Thermal compensation factor
12 constant @ADC \ 5 bits of ADC reading supply voltage
13 constant @OCD \ overcurrent threshold
14 constant @STALL \ stall threshold
15 constant @FSSPD \ full step speed threshold
16 constant @STEPMD \ controls number of microsteps or none
17 constant @ALARMS \ alarm mask
18 constant @CONFIG \ PWM and clock control etc
19 constant @STATUS

decimal
\ Initialization table values to suit motor and application
\ Multiple tables can be setup for various motors and the table pointer
\ passed to the INIT routine if necessary. Just this one at present.
\ This is a 34HY1801 Nema34 in general-purpose mode
\
variable inits -4 allot \ variables points to start of table
decimal \ some motor properties in same table but not part of L6470 registers
\ first 5 values are not loaded into registers but represent motor constants
200 w, \ steps/rev
13334 w, \ rpmmul
60 w, \ rpmdiv
0 w,
0 w,
\ REG 5
600 w, \ @ACC Acceleration
400 w, \ @DEC Deceleration
452 w, \ @MAX Maximum speed (for sm7)
0 w, \ @MIN Minimum
20 w, \ @HOLD Holding current
50 w, \ @RUN Run current
100 w, \ @STACC Acceleration starting current
50 w, \ @STDEC Deceleration starting current
1032 w, \ @INTSPD Intersect speed
80 w, \ @STSLP Start slope
40 w, \ @ACCFS Acceleration final slope
\ register 10
64 w, \ @DECFS Deceleration final slope
0 w, \ @THERM Thermal compensation
0 w, \ @ADC ADC (read only)
15 w, \ @OCD Over-current threshold
127 w, \ @STALL Stall Threshold (set to max)
550 w, \ @FSSPD Full step speed (changes from microstep)
7 w, \ @STEPMD Step mode
hex
FF w, \ @ALARMS Alarm enables
\ 18
1EA0 w, \ @CONFIG Config \ 2e88
0 w, 0 w, 0 w, \ reserved

variable @inits \ pointer to init table

: INIT@ 2* @inits L@ + W@ ;

hex
\ Some console friendly aliases
: STOP SoftStop GetStatus drop ; \ Stop and also read the status to clear any errors
: HALT B8 TXRAW ; \ Stop immediately, override any operation, don't wait
: DISC SoftHiZ ; \ Disconnect the bridge - also needed before certain commands can be written
: HOME GoHome ;
: GO GoTo ;

: CONFIG! STOP DISC @CONFIG REG! ;

: PWMDIV \ ( 1..7 --)
1- 0 max 07 and 6 min 0D lshift @CONFIG REG@ 1FFF and or CONFIG! ;

: PWMDEC \ ( 0..7 -- ) multiply the PWM freq from 0.625 to 2 in 0.125 increments
7 and 0A lshift @CONFIG REG@ E3FF and or CONFIG! ;

: SLEW \ ( 0..3 -- ) adjust the slew rate as 180,180,290,530
3 and @CONFIG REG@ FCFF and or CONFIG! ;

: VSCOMP \ ( on/off -- )
if 20 else 0 then @CONFIG REG@ 20 invert and or CONFIG! ;

: LSCOMP \ ( rpm -- ) 300RPM = 4194
d292 min STOP d8388 d600 */ d4096 + @MIN REG! ;

\ Initialize L6470 registers using init table values
: !REGS HALT DISC 19 5 do i INIT@ i REG! loop ;

variable status
\ Initialize L6470 chips using parameter table address supplied (0=default)
: !L6470 \ ( tbl -- ) Initialize the L6470 stepper chip using the table supplied ( or default = 0)
dup 0= if drop inits then @inits L!

.RST dup pinout dup pinlo pinhi \ Hardware reset - pulse line low
_sclo _sclh _sdao \ Use I2C lines as outputs for clock and data in (L6470)
.CS2 !PIN \ chip selects
.CS1 !PIN
.STCK1 !PIN
.STCK2 !PIN
SLAVE !REGS GetStatus status 2+ W!
MASTER !REGS GetStatus status W!
;

\ Move motor n steps in last selected direction
: STEPS \ ( steps -- )
@STEPMD REG@ lshift h3FFFFF min MOVE ;

\ Using the steps/turn data in the init table, step the motor n turns
: TURNS \ ( turns -- )
0 INIT@ * STEPS ;

: READY? \ ( -- rdyflg )
GetStatus 2 and ;

: BUSY? \ ( -- bsyflg )
READY? 0= ;

: RPM \ ( rpm -- ) Run motor at speed to match rpms
d13334 d60 */ RUN ;


\ ********************* DIAGNOSTICS **************************
hex
\ Rough conversion from ADC reading to voltage (pretty close)
: VOLTS @ADC REG@ 9 * 2/ 2/ 2/ ;

\ Little extension to help analyse the bit in a number (TOS) then select next bit
variable bit
: BIT? dup bit L@ and bit L@ 2/ bit L! ;

\ Simply for console diagnostics to see the status register conditions
: ShowStatus
dup if 8000 bit L!
BIT? if cr ." Step Clock Mode" then
BIT? 0= if cr ." Step Loss B" then
BIT? 0= if cr ." Step Loss A" then
BIT? 0= if cr ." Over Current" then
BIT? 0= if cr ." Thermal Shutdown" then
BIT? 0= if cr ." Thermal Warning" then
BIT? 0= if cr ." Under voltage" then
BIT? if cr ." Wrong command" then
BIT? if cr ." Command not performed" then
\
cr ." Speed = " @SPEED REG@ 2 INIT@ 1 INIT@ */ . ." RPM"
dup 60 and 5 rshift
dup 0= if ." stopped" then
dup 1 = if ." accelerating" then
dup 2 = if ." decelerating" then
3 = if ." constant" then

\ 10 bit L!
BIT? if ." forward" else ." reverse" then
BIT? if cr ." Switch Event" then
BIT? if cr ." Switch Closed" then
BIT? 0= if cr ." Busy" then
BIT? if cr ." Bridge disconnected" then
cr ." Steps/full step = " @STEPMD REG@ 1 swap lshift .
cr ." Input Voltage = " VOLTS decimal . ." V"
else
." - No device "
then
drop
;


\ ********************* DEMO & DEBUG **********************
\
\ Short diagnostic functions which simplify keyboard entry - especially via bluetooth smartphones !

\ List Registers ( in current number base )

\ Use the name for the register as provided in the compiled constant names (tricky)
' @POS _forthpfa>nfa constant regstr
: .NAME 1- 4 lshift regstr + dup C@ 0F and swap 1+ over .str 0A swap - spaces ;

hex
\ List names and contents of registers of both MASTER and SLAVE as well as their default values
: LR
." REG NAME MASTER SLAVE DEFAULT "
\ 01: 0020571A 00000000 000000E7
1A 1 do cr i .byte 3A emit space i .NAME
MASTER i REG@ .long space SLAVE i REG@ .long
4 spaces i INIT@ .long loop cr MASTER ;


\ List the status of the chips
: L \ List the status of the chip(s) for diagnostics
\ busy and flag pins are common
ina COG@ dup 2 and 0= if ." =busy " then 40 and 0= if ." =flag " then
SLAVE GetStatus dup if cr ." --------SLAVE-------- " dup ShowStatus then drop
cr MASTER GetStatus dup if cr ." --------MASTER-------- " dup ShowStatus then drop
cr ;

\ Stop both motors - very useful when testing
: S CS SLAVE STOP MASTER STOP SELECT ;

\ set step mode 0..7 (up the max on full step) example: 4 SM ( sets step mode to 4 = 16 )
: SM DISC dup @STEPMD REG! if 1C0 else 2FF then @MAX REG! ;

\ write config register as in: 2EA8 CFG!
: CFG! DISC @CONFIG REG! ;

\ Set RUN current as in: 30 RC
: RC @RUN REG! ; \ SET RUN CURRENT

Tubular
06-16-2012, 12:39 AM
That's awesome Peter, look forward to having a play soon. If/when you need them back just let me know.

Regarding the webcam demo, for a long time I've wanted to do something similar. I think it would really work well even just with a monitor in the corner. I have a canon vc-c1 camera with pan, tilt and 26x zoom, autofocus, great picture (its the same optics used in camcorders I think). Puts out composite video, and is controlled using RS232 stream. If this is any use I'm happy to send it up. Or I could set it up down here with the modules you send down.

Agreed re TeraTerm it's an outstanding little program especially at high baud rates. Hard to believe its been around for as long as it has, still keeps working great.

Peter Jakacki
06-16-2012, 02:58 AM
Hi Tubular, I will send you two sets so you can work with 4 axis control and if you hook them up via telnet and webcam that would be great too. I will still have a go at setting my end up though as it will be running PropForth so it will be very easy for anyone to start to make things happen from the first few seconds, just type away. I will tie in the webcam to a webpage that has some instructions and examples and links etc.

Anyone have any ideas how best to echo a telnet session onto the same webpage? The fallback is setting up a monitor in the webcam view.

prof_braino
06-16-2012, 10:08 PM
I have a couple of P1121 sets here that I am sending Tubular and possibly a set to Prof Braino so they can play with these on their CNC machines and report back.

I'd be happy to do some work on these. If you send out a second pair, I will forward them to Sal.

Peter Jakacki
10-05-2012, 03:11 PM
Since I've been using these chips I thought I'd give the forum some feedback. There seems to be a lack of documentation in regard to interaction of the many parameters so this can be a little challenging sometimes because when you think you know what you are doing it doesn't work. Anyway for you CNC guys there is no reason why you can't use the chips in "manual" step clock mode as the chip has a lot of fine features and is amazingly small for what it does. This is a "cool" chip, you've seen that the only heatsinking I've been using is the thermal vias to the copper on the opposite side of the pcb.

I've only just recently been using them in this manual mode where I issue the step clock pulses and all other parameters are done over SPI and I have been very impressed with the results. Now I find that ST have released the L6474 which is a dumbed down version in the same package, same pinout etc and half the price almost. The difference with the L6474 is that it "only" does 16 microsteps but it also has a separate DIR pin in place of the SW pin so you can set it up via SPI and just use these two pins most of the time. Since my SPI routines are fast I'm finding it's no problem to set the direction and current via SPI and just use the step clock.

I have posted code here and also on my Tachyon pages.

Oh, and for anyone who might be waiting on some of these modules sorry but please give me a nudge, I've been way too distracted to catch-up and ship these modules off. I do have plenty of stock so if anyone wants to purchase them I am happy to sell the L6470 modules to forum members for $29 USD each + $10 airmail.

Greg Nuspel
10-16-2012, 11:45 PM
Peter I'd love to buy three where do I send the money?

Peter Jakacki
10-17-2012, 12:27 AM
Peter I'd love to buy three where do I send the money?
Like many people of this forum we love to play but with juggling many jobs and projects at the same time and "real work" some little things don't get the attention they need. I finally finally got around to getting a batch of these made as I mentioned so just email me with your details and I will get back to you with a PayPal invoice including shipping costs (normally $10 by airmail).
Ditto for anyone who has been waiting in the past and if you are still interested.

idbruce
10-27-2012, 12:18 PM
Hey Peter

Here is some information that may interest you. If you are already aware of it, then sorry:

http://forums.parallax.com/showthread.php?143371-STMicroelectronics-Introduces-A-New-Stepper-Driver-The-L6480.-Oh-Yea-Baby!!!!

Bruce

idbruce
11-22-2012, 03:25 AM
Peter

What is the smallest step angle you have tested these drivers wit?

Bruce

Peter Jakacki
11-22-2012, 06:50 AM
Peter

What is the smallest step angle you have tested these drivers wit?

Bruce
I normally use the microstep for smooth stepping but the only real way to try this I guess is to setup some sort of linear actuator. I do have some inkjet printer mechanisms I could try it out on. BTW, I've ordered the only high-current L6480 eval board I've seen available from any supplier and that was from Mouser, should be here Monday!. Eight week lead-time now.

TonyD
11-22-2012, 10:47 AM
...
Oh, and for anyone who might be waiting on some of these modules sorry but please give me a nudge, I've been way too distracted to catch-up and ship these modules off. I do have plenty of stock so if anyone wants to purchase them I am happy to sell the L6470 modules to forum members for $29 USD each + $10 airmail.

Hi Peter, have you any L6470 modules left or just blank PCB's which would be better for me?

idbruce
11-22-2012, 11:39 AM
Peter

I won't give you too hard a time :), because I know you know this and you must have had something else on your mind :) Perhaps a woman. Yep, that would explain it :)

I normally use stepper motors with a 1.8 degree step angle (200 full steps per revolution), but I am currently thinking of a rotary actuator application, in which the distance between the angles become larger as the diameter grows. For instance, with the combination of a Gecko G251X and a stepper motor having a 1.8 degree step angle, I get a resolution of 2000 uSteps per revolution ( 0.18 degree step angle). Now if I mount a 5" diameter disc to a stepper motor with a 2000 uStep resolution, as the step angles extend outward from the center of the motor shaft to the outer circumferance of the disc, I will get a distance of 0.0078539816339744825" between angles as measured around the circumference. Of course this distance is too large for high accuracy applications, so I need to break this distance down as economically as possible, and there are several ways to accomplish this.

Use a stepper motor with higher resolution (e.g. 0.9 degree step angle, 0.45 degree step angle, etc...)
Use a stepper driver with higher resolution
Gear reduction
Pulley reduction
Or a combination of the above
Lin Engineering makes a stepper with a 0.45 degree step angle, and ebay has several available with a shaft attachment (http://www.ebay.com/itm/Lin-Engineering-5704-High-Accuracy-High-Torque-Stepper-Motor-CUI-Encoder-/160913429393?pt=LH_DefaultDomain_0&hash=item2577301391&ssPageName=RSS:B:SHOP:US:101). If I use one of these motors in combination with the G251X, I will get a resolution of 8000 uSteps per revolution, as compared to the 2000 uSteps when using a stepper motor with a 1.8 degree step angle. This type of setup would give me a distance of 0.001963495408493620625" between angles as measured around the circumference. Of course, this is now much more accurate than the 0.0078539816339744825" that I previously stated. However, when rounded, that is still 0.002" between angles, and that is still a bit to large for me.

As you might have guessed, the idea of pulley or gear reduction doesn't quite appeal to me, because then the mechanical aspect of my project gets more complicated.

Now let's look at a combination of a 1.8 degree step angle along with a L6470 stepper driver in comparison, with the same 5" diameter disc. Since the L6470 has the potential of 128 uSteps per full step, this equates to 25,600 uSteps in conjunction with a stepper motor having a 1.8 degree step angle. When applying this to the 5" diameter circle, this gives a distance of 0.0006135923151542564453125" between angles as measured around the circumference. Well now..... that certainly is in the realm of acceptability. However, if I remember correctly, these stepper drivers are a bit more difficult to control, then simply setting the direction and sending a pulse.

Is FORTH the only driver you have available, or do you also have SPIN code?

I think you will do well with the L6480, because of the operating amperage and voltage, but I also think it will have to be easy to setup and run. I know there are a lot of options available, but I think if you could get the chip to operate in a basic fashion with simple direction, enable, and step, I believe it would sell much easier than trying to provide all the options, which make it more complicated to use. Just my opinion.

I will have to take a look at your documentation again to see how your drivers would work out for me.

Bruce

Peter Jakacki
11-22-2012, 12:50 PM
Hi Peter, have you any L6470 modules left or just blank PCB's which would be better for me?
I have both ready to go, just let me know which and just PM me your details, I can send them off tomorrow.

Peter Jakacki
11-22-2012, 01:03 PM
Peter


Now let's look at a combination of a 1.8 degree step angle along with a L6470 stepper driver in comparison, with the same 5" diameter disc. Since the L6470 has the potential of 128 uSteps per full step, this equates to 25,600 uSteps in conjunction with a stepper motor having a 1.8 degree step angle. When applying this to the 5" diameter circle, this gives a distance of 0.0006135923151542564453125" between angles as measured around the circumference. Well now..... that certainly is in the realm of acceptability. However, if I remember correctly, these stepper drivers are a bit more difficult to control, then simply setting the direction and sending a pulse.

Is FORTH the only driver you have available, or do you also have SPIN code?

I think you will do well with the L6480, because of the operating amperage and voltage, but I also think it will have to be easy to setup and run. I know there are a lot of options available, but I think if you could get the chip to operate in a basic fashion with simple direction, enable, and step, I believe it would sell much easier than trying to provide all the options, which make it more complicated to use. Just my opinion.

I will have to take a look at your documentation again to see how your drivers would work out for me.

Bruce

There's no problem running this in step clock mode where the Prop supplies the step clock and any other parameters including direction are sent via SPI. There's nothing really complicated about that and I am using that mode in one of my designs. A lot of the Forth code I did is made up of useful references and diagnostic words which may not be of any use in a running program but sure is useful in getting it running. Some of the other register settings are for over-current and step modes and frequencies etc whereas there are quite a few registers just to set the optional self-stepping modes for acceleration etc.

So you can just view it as a simple chip if you like but with lots of extra little "dip switches" and "trim pots" accessible via SPI.

Since I'm sending off some stuff tomorrow how about I send you a board to play with.

TonyD
11-23-2012, 11:05 AM
I have both ready to go, just let me know which and just PM me your details, I can send them off tomorrow.
Hi Peter, I've PM you.

Monotoba
01-03-2013, 02:40 PM
Has anyone here used the ST L6474?

I am working up a 6 axis stepper controller board design using it. I plan on building the board to operate in two modes. A basic mode that will allow Mach3 to apply the step and direction signals to the L6474 and a more advanced mode that will allow control over USB.

I have considered incorporating MODBUS as well. I am not sure if MODBUS works well for stepper motor control or not. It seem to slow to me... However, it would be very useful for other I/O devices. Anyone have an opinion on using MODBUS for stepper motor control on multi-axis CNC machines?

Thanks for the feedback

propellifly
07-11-2013, 09:24 PM
@Peter I've picked up an EVAL6470PD kit from ST so I can evaluate it for a low-cost stepper controller board. I am currently not using my propeller chip and am using an mbed board since I am more familiar with it. Figured I should first learn how to operate the L6470 first. :)

In any case, I started with simple functions to read and write 8, 16, and 24 bit parameters from/to the L6470, and as far as I can tell my functions are working properly. For example, I started by resetting the chip, confirming that the FLAG output is asserted, then sent GetStatus and confirmed that this clears the FLAG output. Likewise, I read the default values for parameters like ACC, KVAL_RUN, and ABS_POS after reset and they matched up.

Feeling pretty good with my progress, I started to move my motor (Lin Engineering 4218L-01-11) and that's where things fell apart. I know my motor works fine because I have hooked it up to two other motion controllers and they had no problems driving the mechanical system (and in fact right now I've disconnected the load). I got paranoid and even tried swapping A1/A2 and B1/B2 and all permutations within those pairs, and got the same result.

The issue is that I'm getting an overcurrent error, regardless of my setting for OCD_TH. The motor can handle 2A and I've even set the L6470 to 6A, and I still get an OCD error. I am using the RUN command, and have tried very low values for ACC and SPD, to no avail.

I was hoping that you or any others on this forum with L6470 experience could offer me some debugging tips or strategies? Thank you!

Peter Jakacki
07-12-2013, 06:01 AM
@Peter I've picked up an EVAL6470PD kit from ST so I can evaluate it for a low-cost stepper controller board. I am currently not using my propeller chip and am using an mbed board since I am more familiar with it. Figured I should first learn how to operate the L6470 first. :)

In any case, I started with simple functions to read and write 8, 16, and 24 bit parameters from/to the L6470, and as far as I can tell my functions are working properly. For example, I started by resetting the chip, confirming that the FLAG output is asserted, then sent GetStatus and confirmed that this clears the FLAG output. Likewise, I read the default values for parameters like ACC, KVAL_RUN, and ABS_POS after reset and they matched up.

Feeling pretty good with my progress, I started to move my motor (Lin Engineering 4218L-01-11) and that's where things fell apart. I know my motor works fine because I have hooked it up to two other motion controllers and they had no problems driving the mechanical system (and in fact right now I've disconnected the load). I got paranoid and even tried swapping A1/A2 and B1/B2 and all permutations within those pairs, and got the same result.

The issue is that I'm getting an overcurrent error, regardless of my setting for OCD_TH. The motor can handle 2A and I've even set the L6470 to 6A, and I still get an OCD error. I am using the RUN command, and have tried very low values for ACC and SPD, to no avail.

I was hoping that you or any others on this forum with L6470 experience could offer me some debugging tips or strategies? Thank you!

Well I manage to match the motor by interacting with it through Tachyon. Have you tried tweaking the PWM frequency itself? I just sit at the console and change a parameter and test it out interactively otherwise you are stuck in a guess-edit-compile-download&wonder cycle.

D.P
07-12-2013, 05:38 PM
If you join the Tachyon thread, grab your prop, download the latest Tachyon and bring up a terminal you can work this this chip as if you had an in circuit debugger and much more. I just got a very flakey touch screen async driver working doing exactly what Peter described. Beware FORTH-ish programming ahead, very addicting.

propellifly
07-15-2013, 05:34 PM
I haven't tried to mess with the PWM frequency. Thanks for the tip -- I just wasn't sure where to start. I'll give that a shot!

propellifly
07-15-2013, 05:35 PM
If you join the Tachyon thread, grab your prop, download the latest Tachyon and bring up a terminal you can work this this chip as if you had an in circuit debugger and much more. I just got a very flakey touch screen async driver working doing exactly what Peter described. Beware FORTH-ish programming ahead, very addicting.

I'll check it out soon! Need to find my quickstart board. :) I remember really liking FORTH in school for debugging hardware, but it's been a very long time for me.

propellifly
07-17-2013, 06:12 PM
Well I manage to match the motor by interacting with it through Tachyon. Have you tried tweaking the PWM frequency itself? I just sit at the console and change a parameter and test it out interactively otherwise you are stuck in a guess-edit-compile-download&wonder cycle.

Peter, on my board I am running two loops -- the outer one increments F_PWM_INT from 0 to 7, and the inner increments F_PWM_DEC from 0 to 7. I get a status of 0x4E03 (lost steps and OCD) regardless of the setting. Is there a chance that my board is just bad? Can you recommend anything else to try when I modify the PWM frequency?

EDIT -- I have just tried to use the Move(DIR, N_STEP) command and it seems to get the motor going. I have also tried using the step input pin, and when I do that I get a status of 0x8E03 (stall + OCD) after the first step. This just doesn't seem right -- why would I get those errors from pulsing the step input line?

rylangrayston
07-29-2013, 08:05 AM
// there has been alot of discussion as to where or not you can use the L6470 driver
// for milling machines and many other purposes where 2 or more motors
// need to be synchronized as well as have dynamically assigned speeds.
// the problem is there is no clear/actual way to change the speed register wile the motor
//is running, some have suggested to just use the L6470 in step at a time mode
// but I feel this is a waste of allot of great features ie stall detection.
// So without further adue here is a solution ( sorry this is code from an arduion
but it shuld get the point across)


void loop()
{
// 200 steps is one revolution on a 1.8 deg/step motor.
dSPIN_Move(FWD, 40);
while (digitalRead(dSPIN_BUSYN) == LOW); // wait Until the movement completes, the
dSPIN_SetParam(dSPIN_MAX_SPEED, MaxSpdCalc(max_speed_rise));
max_speed_rise += acceleration_rate;
if (max_speed_rise > 100){
acceleration_rate = -1;

}
if (max_speed_rise < 1){
acceleration_rate = 1;
delay (1000);
}

}


if you run this you will see that the stepper s acceleration
//is nice and smooth while still being controlled dynamicaly ( wile the motor is
// running ) It is a very simple work around ...

In truth the motors speed is changing inbetween move commands,

but this is happening so often that it is very smooth!


// now the comes the part thats not done yet ... daisy chaining,
// using the method dynamic speed method combined with daisy chaining
// one more thing ... load all the bits but one on the daisy chain while the
// motor is finishing the previous command then using an interrupt as soon as
// the L6470 busy pins are all low load the last bit in the daisy ..
// this should reduce any delays that could cause motor noise!


again this code is from an arduino but I hope it is helpful here ..

Shoot me a message if you improve on it, or the methods iv spoken of.

Some links to my project related to this post

https://github.com/Rylangrayston/arduino-blend/tree/Daisy-L6470

http://www.blenderartists.org/forum/showthread.php?298691-working-blender-motion-control-camera-rig!-Suzans-Dolly

http://rylangrayston.github.io/arduino-blend/