TMCStepper
TMCStepper copied to clipboard
Change Speed
Hi, first of all sorry, i usually code in python, this is a little new to me. I have the issue that i want to drive a stepper with a rather high speed (200RPM) and change the speed acording to an AnalogRead. Is there a function in your libaray ment for this? Pseudocode: driver.driveSpeed(analogRead(A1); I searched the documentation but found nothing.
Thanks for your help!
Hello,
You are in the wrong place, this library isn't to drive a stepper, it is to help setting up trinamic based hardware stepper driver.
-
To control your stepper you need an other library like Accelstepper which define speed, max speed etc .... -->Note that those speed numbers are in step/s. Usually stepper are hardwarely 200 Full step /rotation.
-
Take also care that most of the time stepper drivers are setted up with a microstepping ex: 1/4, 1/8, 1/16 microstep etc... which subdivide Steps. So you have to compensate by the inverse. --> Microtepping is setted in hardware with jumper on the driver, or by software like TMCstepper allows.
-
As all of those are constant you can put everything in a constant to convert in RPM. With a 1/4 microstepping This constant will be something like rpm= 200x4/60 which is your StepperHarwardwareStepping x InvertedMicrostepping / 60s.
@zelli42
If you are using the tmc5160 you can make use of the internal motion controller: driver.XTARGET(200); // would move the motor to position 200 if you are using: driver.RAMPMODE(0); // Set internal pulse generator ramping mode in the setup.
Check the TMC5160 datasheet for more commands.