Hello, I´m about to build an sidereal tracker for astro photography.
Problem in front: I can set my steps variable via the Keypad shield but the main steps are 3.714 steps/second.
I know there is a way to use the bresenham algorythm to solve this problem with the missing 0.286 steps, but I dont know how, when I´m changing the "speed", cause the difference is changing with it...
My settings are:
-LCD Keypad shield
-Arduino Uno
-Nema 11 (1.8°) with 100:1 gearbox
-A4988 in 1/16 step mode
The calculation:
200 Steps x 100 x 16 = 320000 steps/round
a sidereal day has 86160 seconds.
320000 steps/86160 seconds= 3,714 steps/second
Actuall sketch:
#include <AccelStepper.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int adc_key_val[5] ={50, 195, 380, 555, 790 };
int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int isRun;
double speeds = -241.6;
int maxspeed = 1200;
AccelStepper stepper1(1, 16, 15);
void setup() { // void means dont expect any return from this command
lcd.clear(); // clear the lcd
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
lcd.setCursor(0,0);
lcd.print(" Stopped "); // display stopped on the LCD
lcd.setCursor(0,1);
lcd.print("Speed "); // display the value of speed
lcd.print(speeds); // display the value of speeds
lcd.print(" ");
isRun = 0;
stepper1.setMaxSpeed(maxspeed); //1245
stepper1.setSpeed(speeds); //
}
void loop() {
adc_key_in = analogRead(0); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key >= 0) // if keypress is detected
{
if (key == 1) {
speeds += 0.1;
delay(100);
}
if (key == 2) {
speeds -= 0.1;
delay(100);
}
if (key == 0) {
speeds += 10;
delay(100);
}
if (key == 3) {
speeds -= 10;
delay(100);
}
if (speeds>maxspeed) {
speeds = maxspeed;
}
if (speeds<-maxspeed) {
speeds = -maxspeed;
}
if (key == 4) {
isRun = 1 - isRun;
lcd.setCursor(0,0);
if (isRun == 1) {
lcd.print("+++ Running +++ ");
} else {
lcd.print(" Stopped ");
}
delay(250);
}
lcd.setCursor(0, 1);
lcd.print("Speed ");
lcd.print(speeds);
lcd.print(" ");
stepper1.setSpeed(speeds);
delay(50);
}
if (isRun == 1) {
stepper1.runSpeed();
}
}
int get_key(unsigned int input)
{
int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
return k;
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}
Additional details are needed, and you many need to rethink the motor drive.
The 100:1 drive leads to 0.018 degrees of shaft rotation per full step or 0.009 degrees per half step. How will the shaft rotation be used to drive the camera platform? Is there an additional gear ratio to consider?
One major consideration is that microstepping does not produce accurate fractions of a step. Instead, microstepping is intended to help avoid motor vibrations and resonance effects at certain speeds.
Microstepping also dramatically reduces the torque increment per step, so unless your mechanism is very carefully constructed, the drive may skip steps.
You claim to need 3.714 steps per second, but there is no reason to move the platform every second. Choose a different time step that leads to an integral number of motor steps.
I´ll drive the camera "directly" without additional gear ratio from the shaft.
For this I´ll mill an mount.
Because of using a 300mm lens, I don´t want the motor to stop and cause any vibrations or backlash.
In my thoughts it would step often enough for a smooth following of the earth rotation.
Thats the reason for the 1/16 stepping.
There are versions with additional worm gears, but I don´t have the machines to build an accurate one, so I first wanted to try my own thoughts.
AccelStepper lets you set speed as a floating point number of steps per second, like:
stepper1.setSpeed(3.71402);
Which would = 361.002744 degrees per 24 hours. I think.
Of course the Arduino's time base oscillator is not accurate enough for long term timing, you need a real time clock (RTC) for that.
Does the accelstepper library round the steps up? Or how does it floating steps?
Not sure, I think it takes the steps per second that you enter, takes the reciprocal (1 / x) and multiplies that by 1 million to get the step interval in microSeconds. 1 / 3.71402 * 1000000 = 269250 microSeconds or 1 step every 0.269250 seconds. Keep in mind, Arduino uses float (32 bit) NOT double for FP math, so 6 significant digits (like 3.71402 or 37140.2) is all you get.
Good tip, JR. Motor may not hold steady at 13/16 of a step for 0.269250 seconds.
Microstepping is good for smooth motion but not for holding position between full steps.
I think I'll just test it out.
(the motor is on the way from China)
But some questions:
The motor doesn't stand still for a 'long' time or? Are 0.269250 seconds per step such a long time for holding the motor to lose steps?
About the current I maybe have to say something about my plans on powering it:
The Arduino will be powered directly from my power bank. From there I connected an DC/DC step up (5 to 12V) for the motor.
I connected an 7.5 degree motor for testing and the motor was turning. So I hope the Nema will work also
I'll let you know when I finished the mount for testing!
Are 0.269250 seconds per step such a long time for holding the motor to lose steps?
Yes. Microstepping is intended for smooth, continuous rotation.
However, more important is that there is very little torque to drive from one stationary microstep to the next. This is part of the reason why the microsteps are not accurate fractions of a full step.
outsider:
Good tip, JR. Motor may not hold steady at 13/16 of a step for 0.269250 seconds.
Microstepping is good for smooth motion but not for holding position between full steps.
I strongly disagree, microstepping is superior, use it and avoid most of the vibration / resonance
issues with no penalty in holding force.
jremington:
Microstepping also dramatically reduces the torque increment per step, so unless your mechanism is very carefully constructed, the drive may skip steps.
No, this is a complete myth. Microstepping reduces the chance of skipping due to midband resonances,
at low speeds there is no issue at all.
There is no "torque increment per step". At low speed there is holding torque and microstepping
keeps a pretty constant holding torque during slow speed motion, whereas full stepping will risk
jumps at the step points as the motor is 90 degrees away from its optimum torque point immediately
after the step.
Yes, there may be parts of the cycle with microstepping where the holding torque is a little less
than at a full step point, but this matters not at all as steps are skipped due to dynamic torque
or resonance issues long before holding torque is exceeed - go play with a motor and try it.
Provide measurements then please... I power a stepper and it gives a certain pull-out torque. I set it
microstepping slowly and it still provides that torque. I set it to full steps and it will skip it that kind
of torque load is applied.
All simple experiment to do with a stepper with a handle mounted on the shaft, for instance.