EasyDriver 4.4 from Sparkfun - How to use?
JBWolf
Posts: 405
Hello,
I decided to get one of the EasyDriver stepper controllers from sparkfun:
https://www.sparkfun.com/products/10267
This is the newest version and supports 3.3v pulse input, so I would like to control it with the propeller.
I have never worked with a driver like this and was hoping to get some direction on how to use and program for this driver.
Some questions that come to mind immediately...
For sending a step pulse... I'm assuming I can just turn the step pin high then delay 1ms then go low? Or does the delay need to be +/- that value? What is the minimum delay allowed between pulses (from end of one pulse to start of next)?
For changing direction... How does the dir pin work? I cannot find much info on this, How do I use it to set forward or reverse motion?
For microstepping... The product description says this can do up to 8x microstepping. What pin changes the microstep value, and how do I use it?
I couldnt find an object in the exchange for these drivers... so maybe I'll upload what I eventually create to help others learning.
I am comfortable enough with spin to write the code, just need guidelines on the pulses and general usage of this type of driver... especially the dir pin, I have no information on this at all and dont know where to begin.
Hoping to get a motor turning with this driver tonight or tomorrow.
Thanks,
J
I decided to get one of the EasyDriver stepper controllers from sparkfun:
https://www.sparkfun.com/products/10267
This is the newest version and supports 3.3v pulse input, so I would like to control it with the propeller.
I have never worked with a driver like this and was hoping to get some direction on how to use and program for this driver.
Some questions that come to mind immediately...
For sending a step pulse... I'm assuming I can just turn the step pin high then delay 1ms then go low? Or does the delay need to be +/- that value? What is the minimum delay allowed between pulses (from end of one pulse to start of next)?
For changing direction... How does the dir pin work? I cannot find much info on this, How do I use it to set forward or reverse motion?
For microstepping... The product description says this can do up to 8x microstepping. What pin changes the microstep value, and how do I use it?
I couldnt find an object in the exchange for these drivers... so maybe I'll upload what I eventually create to help others learning.
I am comfortable enough with spin to write the code, just need guidelines on the pulses and general usage of this type of driver... especially the dir pin, I have no information on this at all and dont know where to begin.
Hoping to get a motor turning with this driver tonight or tomorrow.
Thanks,
J
Comments
I really don't think the pulse length matters in this case. As long as you're using Spin for the pulse it should be long enough. I'm pretty sure just the rising edge of the pulse is all that matters to the driver.
The direction pin should be set either high or low. The stepper will turn one direction with the direction pin high and the opposite direction when the pin is low.
By just worrying about steps and direction, it's easier to control a stepper motor since the driver board takes care of sending the high/low pattern required by the stepper.
I know of an object for controlling three motors with this type of controller but it's intended for a CNC machine. You may be better off making your own program to control it. It's probably a good idea to add some ramping to the program to increase (and decrease) the steppers speed over time.
Here's a link to the CNC object.
Do you know how to do the ramping? If not, let me know and I'll see if I have an example to show you.
Definitely interested in the CNC code... I am a CNC operator and have been wanting to make my own small size cnc.
So for direction, lets say a high state = forward.... I dont have to keep it high all the time right? just before/during a pulse.
For microstepping, the description on the sparkfun page says it defaults to 8, which is what I will primarily want to use... but it would be nice to know how to change this for faster speeds.
Should I use resistors to limit the current from/to the prop/easydriver pins? not sure what the max input current of the easydriver or the avg output of the prop is... but I'm guessing 5ma for an input signal to the easy driver would be enough, so... 3.3v / 0.005a = 660ohms
I may have spoke too soon. While I have examples of ramping servo and motor speeds, ramping stepper speed is a bit different since one needs to change the pause between steps to change the speed. I couldn't find any examples of how to do this.
I think you're better off leaving the direction pin in the same state unless you want to change direction. If you're want the stepper to rotate forward then just keep the pin high.
The input pin on the EasyDriver will have a high impedance. You don't need resistors in this case. Very, very little current will flow (microamps).
I'm working on some test code for step and direction drivers. I plan to finish it tomorrow. I'll post a copy here as soon as I have it working.
You convert your scalar speed command value to a frequency. 0 = 0 Hz. One increment of speed value should make intuitive sense (one RPM, degrees/sec, or % of max speed, or some fixed point fraction thereof). Ideally you would have some adjustable parameters like number of steps per revolution and number of microsteps so you can come up with a motor shaft speed that is consistent in magnitude with your speed command value. You could also have parameters to do a gearbox and screw pitch conversion on the command side, so your ramping and final speeds are in linear format (inches per second, mm/s, etc).
You would ideally build this in modular blocks like most industrial drives do, as in one section is the ramp function generator that generates a speed from setpoint-actual value, another handles the feedback control loop, and another section converts the velocity command to step and direction.
You run through the control loop calculations at a specific fixed time interval (1 ms, 10ms, whatever), but your frequency generator would be free-running. The frequency generator would need to be written so as to switch to a new frequency at a transition point from low to high, or high to low, to avoid glitches. You want to get a complete pulse, not switch as soon as the speed command to it changes and possibly give a very tiny pulse which will be interpreted as a demand to suddenly go very, very fast for that instant.
You could do encoder simulation by just feeding back the step and direction internally and incrementing or decrementing a position register each step pulse, then scaling to your unit system. The speed control loop would generally be a Proportional-Integral type loop, with optional feedforward. The derivative portion of the traditional PID loop in motion control has proven again and again to be a terrible idea (terribly picky, prone to oscillation, super sensitive).
Thanks for the information whickers.
I don't think I was planning on having any feedback with the CNC machine. Don't many (most?) steppers in CNC routers run without encoders?
Most in CNC is relative. Since I have only one, most of my CNC's, a MaxNC 15 CL (closed loop) has position encoders on each servo. With the encoders its accuracy is about 2 or 3 thousandths of an inch. With your 12 bit magnetic encoders, the accuracy would be much greater, up to the limit of the servo motors. If you take one inch and divide it by 4096 you have greater than a quarter of a thousandth of an inch since the distance of one thread turn is less so let's say one turn of the screw is 1/16" travel, that's another order of magnitude in accuracy, better than 10 thousandths of an inch its about 2 hundredthousandths of an inch.
If precision PWM can drive a servo a little closer to that accuracy then you can both sense it and drive to its maximum accuracy. I don't know the maximum precision of a servo. But if more accuracy is desired, you can use a gear instead of a direct drive from the servo to the screw.
In theory the reason for having encoder feedback is precision. If you send a signal out to move a certain amount something might interrupt that command, whether a power surge or a little tougher material being chipped away or accumulated backlash slop and it might not actually get there without feedback to tell it to resume travel until the target is achieved.
I understand exactly what you mean by increasing accuracy because of the number of TPI on the lead screw.
Right now I am just working on a small project, the stepper is a very tiny one with 3.75deg steps... but after this project is done (hopefully by next week), I would like to get into more complicated stuff.
So this info is great.
I do not see a way to incorporate ramping with the easydriver with that type of method.
The only way I see it being possible is by adjusting the microstepping... going from 8 to 4 to 2 to 1 to increase acceleration while retaining maximum torque at beginning of motion.
Otherwise it would be like you say, just changing the amount of time delay between pulses.
Was alot easier than I had initially imagined.
I still have not found any information on how to change the microstepping rate... I would like to find this info.
Here is the code I produced:
I have some 8" lead screws I would like to test with.
Also, I have some of the small motors with miniature lead-screw attached that I harvested from a DVD player.
I would like to get one of these working but cannot find much specifics for these motors... it is a 4-pin stepper.
Does anyone have experience with one of these?
Okay, this is my attempt at a frequency generator. "par" would hold the address to the delay amount (in clock cycles). The variable after delay would be the total step counter which the PASM cog would write to each loop it preformed a step.
A zero delay would cause the frequency generator to pause.
A non-zero delay is shifted right one bit to divide by two. I figure I shouldn't need to worry about a single bit rounding error.
The delay value would be changed by the higher level code.
Is this close to the type of frequency generator you were talking about whicker?