epicycloid
Well-known member
@Ed Clark -- Just curious, which drivers are you using and for what size motors?
--Jon
--Jon
@Ed Clark -- Just curious, which drivers are you using and for what size motors?
--Jon
Variable speed set using Paul's encoder library (this was a challenge for me personally, so I know how hard it can be, e.g. increase / decrease speed based on knob rotation, extra credit for bumping up the speed increment if knob is rotated faster ;-)
Serial communication - this is the main area that causes huge problems in Accelstepper performance due to architectural delays. Serial output for anything from debug (println), to getting keyboard input. I don't know what user expectations are for serial usage while moving motors, but there are lots of questions that arise (and performance limitations especially using an Uno and motors, which TeensyStep circumvents for the most part)
If you describe what information / examples would be useful for you (and probably others) I can add a few chapters to the readme.
I have also another suggestion as it's not easy (at least for me) to implement automatic forth and back movements as required in many winding applications, for example as shown in my video: one motor runs while the other turns back and forth. There is a product called PTHAT which basically is a controller board for 4 steppers: one of the serial commands it accepts is called Set Auto Direction Change and does exactly what is needed for coil winders. But in my video I run the motors without any acceleration / deceleration otherwise I can't calculate the moment when to change direction: it would be great to enable acceleration / deceleration also in winding applications.
- Variable speed set using Paul's encoder library (this was a challenge for me personally, so I know how hard it can be, e.g. increase / decrease speed based on knob rotation, extra credit for bumping up the speed increment if knob is rotated faster ;-)
- Variable speed reading a pot on an analog pin (lots of beginners have issues with reading a pin occasionally, rather than every pass through loop(), simple interrupt based example would be fine too, but must be complete and commented)
I assume this is supposed to change the speed on the fly like a jog dial on a cnc? I.e. changing the speed of a synchronized movement should change the speed of all the motors such that they stay synchronized, correct? This might be an interesting feature which is not implemented currently. I'll try to find a solution for that
I'll be curious to see luni's reply, but your winding application is exactly what his library does perfectly...
if you want to decelerate the linear motor at the end of one layer, you also need to decelerate the rotation motor at the end of the layer to avoid a bad winding.
Variable speed ... simple interrupt based example would be fine
#include "Arduino.h"
#include "StepControl.h"
Stepper linMotor(1, 2);
Stepper rotMotor(2, 3);
StepControl<> RotationCtrl;
StepControl<> LinearCtrl;
void setup()
{
rotMotor
.setMaxSpeed(10000)
.setAcceleration(50000);
linMotor
.setMaxSpeed(5000)
.setAcceleration(500000);
int linSteps = 56400; // number of steps per layer (linear motor)
int rotSteps = 121000; // number of steps per layer (rotational motor)
int nrOfLayers = 5;
rotMotor.setTargetRel(rotSteps * nrOfLayers);
RotationCtrl.moveAsync(rotMotor);
for (int i = 0; i < nrOfLayers; i++)
{
linMotor.setTargetRel(linSteps);
LinearCtrl.move(linMotor);
linSteps = -linSteps;
}
}
void loop()
{
}
Would something simple like this not work?
#include "Arduino.h"
#include "StepControl.h"
constexpr int pinLinStp = 0;
constexpr int pinLinDir = 1;
constexpr int pinRotStp = 2;
constexpr int pinRotDir = 3;
Stepper linMotor(pinLinStp, pinLinDir);
Stepper rotMotor(pinRotStp, pinRotDir);
StepControl<> controller;
void setup()
{
rotMotor
.setMaxSpeed(10000)
.setAcceleration(50000);
linMotor
.setMaxSpeed(10000)
.setAcceleration(50000);
const int linSteps = 100; // number of steps per layer (linear motor)
const int rotSteps = 100; // number of steps per layer (rotational motor)
const int nrOfLayers = 5;
int oldDir = -1; // stores the current direction of the motor
linMotor.setTargetRel(linSteps * nrOfLayers);
rotMotor.setTargetRel(rotSteps * nrOfLayers);
controller.moveAsync(rotMotor, linMotor); //we want both motors run in sync
while (controller.isRunning())
{
int dir = (linMotor.getPosition() / linSteps) % 2;
if (oldDir != dir) // check if one layer is complete... and switch motor direction after the layer
{
oldDir = dir;
delayMicroseconds(10); // need to wait a bit to avoid switching during a step pulse
digitalWriteFast(pinLinDir, dir);
}
}
}
void loop()
{
}
...to hard switch the direction of the linear motor at a layer change to keep the constant pitch. If this is (as you wrote) not a problem you can easily mimic that AutoDirectionChange command you mentioned above
#include <StepControl.h>
Stepper motor(11, 5);
StepControl<> controller;
void setup() {
motor
.setAcceleration(5000)
.setMaxSpeed(7000); // set speed
controller.rotateAsync(motor);
delay(2000);
motor
.setPullInSpeed(7000) // set current speed as new pull in speed
.setMaxSpeed(14000); // set new speed
controller.rotateAsync(motor);
delay(2000);
controller.stop();
}
void loop() {}
3) Serial communication - this is the main area that causes huge problems in Accelstepper performance due to architectural delays. Serial output for anything from debug (println), to getting keyboard input. I don't know what user expectations are for serial usage while moving motors, but there are lots of questions that arise (and performance limitations especially using an Uno and motors, which TeensyStep circumvents for the most part).
... I also tried to change speed on the fly .... If the new speed is higher it works, but I can't get it to decelerate properly. I tried to re-set pull-in speed every time I changed speed but did not succeed...
Changing those parameter on the fly is currently not possible (I'm working on it, but this will take some time)