I need to run a NEMA 17 chineese stepper motor at a constant RPM (lets say 70 RPM) with an expansion board. What I have bought are these one. I need an instruction for that but I can not find it with the keywords I put. Could you please help.
I'd recommend the AccelStepper library, use setSpeed () and runSpeed () I think. It works in
terms of steps per second, so you'll have to figure that out. The A4988 like many stepper
controllers needs a step signal and direction signal, and for AccelStepper you configure it like:
When using AccelStepper library, the value for DRIVER = 1 and you are free to choose any digital pin of your Arduino (besides of TX and RX pins which should be reserved for communication purposes).
Example:
If you use pin 5 of your Arduino as "STEP Pin" and 6 as "DIR Pin", then you
connect Arduino pin5 with driver input "STEP" (sometimes it is called "CLK")
When using AccelStepper library, the value for DRIVER = 1
Always use DRIVER, not 1, as the first argument to AccelStepper, its a symbolic constant and its
value could change in different versions of the library, it might not even be an integer in the future.
Also '1' has no descriptive values whatsoever whereas 'DRIVER' implies a stepper driver.
I've already indicated how to code an AccelStepper correctly,
Thanks for your comments, I used rpt007 comments to learn and adjust the VREF and the other stuff, and I learnt some coding with Robins codes.
However, I want to use the shield for running the motor at constant speed. The reason that I said so is that in my workplace I can not find a breadboard (it is a chemical laboratory, not electrical ) and capacitors etc. I already ordered but it arrives after several days which is late for me.
So, with the mentioned shield and the rpt007 comments and other youtube stuff I made the motor to work. But now I need to run a GCODE that continiously drive my electromotor at a constant speed. Any idea on how to do that? What can be the code?
I am using the Universal Gcode sender to send the commands to grbl 0.9.
Always use DRIVER, not 1, as the first argument to AccelStepper, its a symbolic constant
Big learning for me - I always used "1" in my sketches; now that you kicked me to that "symbolic" point - whatever that means, as I am not a programmer by education, I will use it in the future.
I had (tried) studied the AccelStepper library but didn't pay attention to this point, mentioned in the very first sentences of the class description.
The library is a mighty one and I am happy that I got all my projects, were I use the library, are running smoothly (still with the "1"). When my customers will require to get new features in the application, I will change the "1"'s to "DRIVER", so I won't run into a problem one day, if the library would have changed to a non-integer then.
@zeedo65:
You said ".. at a constant speed" - what does that mean - do you want to "jump" the motor speed from "0" to "x" without acceleration (technically not feasible by the way) ??
But I suspect, this won't be the major point for the moment.
But now I need to run a GCODE that continiously drive my electromotor at a constant speed. Any idea on how to do that? What can be the code?
Would you pls give us a bit more information what you mean by "run a GCODE .." - only one GCode command and will this stay stable or will there be many GCode commands with different parameters and you expect the stepper motor to follow those instructions?
When grbl is on board of an Arduino - it is like a new firmware and the Arduino won't be able - at least up to my current knowledge - to execute other commands than those coming from a GCode sender.
That means, that you won't be able to use any library or line by line commands as in a "normal" Arduino environment. You will be "caught" in the grbl-firmware environment, which is not the worst scenario because it opens you a lot of options to run multiple steppers at different accelerations and directions and speed etc.
I plan to write my own simple Arduino software and have the G Code interpreted by my PC. That is, a lot of the work that's done within GRBL will happen on my PC.
So, if Robin has succeeded in doing this, you might find his solution more flexible than using the grbl firmware running on your Arduino.
On te other hand - you see, I am just guessing and assuming a lot. Why don't you explain a bit more in detail, what exactly your project is all about and then we can tell you, what direction to follow. Otherwise we guide you into a jungle which won't get you to the goal you are aiming at.
Following on from the reference in Reply #8 to my efforts, I am not sufficiently familar with GCode to know if there is a code to make a motor move continuously - or (if there is) if GRBL is designed to interpret it.
I don't think GRBL can interpret every Gcode instruction that a big commercial machine could.
GRBL is normally used for tasks which have a series of finite movements within the physical limits of a milling machine.
G-code is all finite line segments and arcs, nothing unbounded, since it is motion control.
However there is scope for things like spindle motor speed and switching it on and off which
are continuous. I cannot recall if GRBL has any support for that sort of thing.
I don't think GRBL can interpret every Gcode instruction that a big commercial machine could.
I think you can be stronger than that - it simply cannot at all do anything like a big commercial
machine - those are frankly astonishing in their power and sophistication and accuracy.
It'll do you a 3D printer or simple CNC machine though. Throw a more powerful process at
the task and you'll get more capabilities. LinuxCNC is based on the original MIT codebase for
CNC research IIRC, that'll get you a lot closer to higher end capabilities. There are other,
non-free software suites too that use the power of a full-blown processor.
But we still don't know the exact requirements from the OP.
I think only then we could give him some better advice, before we begin to think in bigger complexities.
I suspect the project challenge is much simpler, but I am only guessing as long we don't have better information what he really wants to achieve (another XY issue ??).
Thanks, I was a bit far these days from this project. Sorry, I just want to run a pump with a speed of 70 RPM using the GRBL. But, as you mentioned, I could not do that because the codes were not letting me to move the steppermotor continiously. Sorry, you are much expert in this field than me so your minds got far beyond my thoughts If you have any suggestions, I would be grateful.