Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

Arduino controlled focussing


Gina

Recommended Posts

The little, cheap 28BYJ-48 stepper motors with 64:1 gearbox need something like a 5:1 reduction for a 1:1 focuser drive but where you already have a 10:1 or 11:1 focuser knob you can drive that with a 1:1 approx. belt drive.  These are usually 5v though there is a 12v version (probably more expensive).  The ULN2003 can drive either 5v or 12v with the appropriate supply voltage.  I have 12v and 5v power to my pier  - obtained from a modified exPC PSU - to my pier top equipment.  12v powers dew heaters etc. and 5v for USB hub, Arduino and stepper motors.

Link to comment
Share on other sites

  • Replies 180
  • Created
  • Last Reply

Don't forget that a properly driven stepper can be held in between the physical steps with a precision of either 1/8th step or 1/16th step depending on driver technology. The driver I used (A3967) can do 1/8th. That way you do not have to resort to physical gear reduction.

/per

Link to comment
Share on other sites

Don't forget that a properly driven stepper can be held in between the physical steps with a precision of either 1/8th step or 1/16th step depending on driver technology. The driver I used (A3967) can do 1/8th. That way you do not have to resort to physical gear reduction.

/per

Thanks, knowing that I dug deeper into the code and found that I could set the microstep value and using a different command could get my stepper to move in 3200 steps per revolution.

As a driver i use the easydriver board that has the option for microstepping

I should have gone for that board instead of the Adafruit Motorshield (v2) as there are more examples of the easydriver board in use. Have the same motor as you and now I've amended my code I can get 3200 steps per motor revolution.

Getting there slowly, next to sort out the connection to the focuser and what brackets, belts and pulleys needed. You're a bit ahead of me so I'll watch here for progress  - good luck.

Link to comment
Share on other sites

Just a short note on using micro-stepping... When you do, the driver will have the windings of the motor activated all the time. The driver stage of your driver circuit (H-bridge) will have to be able to take the power dissipation. When you single step a stepper you do not have to hold the windings active.

/per 

Link to comment
Share on other sites

Just a short note on using micro-stepping... When you do, the driver will have the windings of the motor activated all the time. The driver stage of your driver circuit (H-bridge) will have to be able to take the power dissipation. When you single step a stepper you do not have to hold the windings active.

/per 

I noticed that. I put a motor release after each set of microsteps for now until I can safely let the motor hold. Was thinking of having an option to lock/release the motor or a timeout (allowing for a physical lock to be made on the focuser).

Link to comment
Share on other sites

For this motor that i have https://www.sparkfun.com/products/9238 what kind of ratio would you suggest. Based on your previous post, for my focuser which i pressume is similar to your MN190 (single speed focuser with 40mm knob diameter) i need a 40mm gear to drive the focuser and a 8mm driver gear. correct?

 

If you're using toothed pulleys like these:

http://www.motionco.co.uk/timing-pulleys-timing-pulleys-aluminium-c-25_35_48.html

the reduction factor is based on the number of teeth: so a 60-tooth and 20-tooth would give you 1:3, for example.  I would be cautious about choosing a very small diameter motor pinion.  This motor has a 5mm diameter shaft and you will have to widen the bore of the pinion (usually 3mm in small pinions) to match.   This is quite tricky, especially if the pinion is already only 8mm outside diameter!

 

I would suggest that you choose 20T and 60T, a 1:3 reduction, unless you have a very fast scope that needs extremely fine focus adjustment.  The 20T pinion has a few mm more diameter so when you bore it out to match the motor shaft, there is a little more material left!  

 

I have two scopes with Arduino focusers using similar motors to the one you describe, except they are 0.9 degree 400 step, driven by EasyDriver controllers. My focuser has about the same mm travel per turn as yours. I found that 1:3 gives plenty of driving - and holding - torque.  It's important you have enough reduction to get the step size well below the 'critical focus zone' for your scope.   I find that 1:1200 total reduction (400 steps then 1:3 belt reduction) gives fine enough resolution for my scope at f/5.3.  You could achieve the same step-resolution at 1:3 reduction just by half-stepping.  If your scope is not so fast f/ratio, you don't need such fine resolution. Critical focus zone for a f/8 scope is 2x bigger than for a f/5.6 scope.

 

I would also caution against using very small (like 1/8th) micro-stepping.  I believe that step motor torque is reduced in micro-stepping mode so it's not a good substitute for belt reduction which increases torque, of course.  Also, I think that the positional accuracy of very small micro-steps is not so accurate as full or half steps.

 

Adrian

Link to comment
Share on other sites

I'm about to order my Arduino now and have a quick question, which one?

I was going to get a nano for the small form factor but it's about 1/3rd more expensive than the shield compatible ones.  So should I just get the nano or get an Uno/Leonardo for development and testing then get a nano or pro mini later for the final product when I'm more concerned with the space.

Link to comment
Share on other sites

Why are you concerned about space - are you intending to mount the electronics on the scope?

I'ts not necessary to do that.  I used a Uno and built a separate control box containing Uno and EasyDriver that is remote from the focuser.  I run a 4-core cable from the motor down to the control box where it connects via a 4-pin locking line socket and chassis plug (Maplin). 

focuser_control.jpg

This means only one cable going up the scope that plugs into the box, and it allows me to use the control box with different focusers/ scopes if I want to.

I know that one reason for mounting the electronics close to the motor is to allow a short permanent wired connection from EasyDriver to the motor  ..... to avoid the risk of inadvertently hot-wiring the motor, i.e. connecting/ disconnecting the motor while power is still on to the EasyDriver (blows the main chip!).  But using a screw-locking connector reduces that risk, and I also mounted a small red LED close to the socket on the control box to remind me that power is still on in case I'm ever tempted to undo the connector before switching off.  

Adrian  

Link to comment
Share on other sites

Why are you concerned about space - are you intending to mount the electronics on the scope?

More it's just smaller takes up less room where ever it goes, but if it's easy to run some multi core then I'll get the cheaper one.  Just reading up on Uno Vs Leonardo now as there's a small difference in spec and price.

Link to comment
Share on other sites

  • 3 weeks later...

I am trying to create a code for my arduino focuser and i would like to ask a few questions. The main problem i face right now is with the delay for when the motor is on. By experimantaion with the following code i found that with a delay of about 1-200 miliseconds i get a slow step which is good for fine tuning the focus and with the delayMicroseconds set to about 500 i get the fast movement needed for large focuser movements. I could use the delayMicroseconds(1000) for getting a milisecond but from my readings the delayMicroseconds function will produce an accurate delay up to 16383. How could i go around this for large values? A solution would be to use a switch and programm the arduino to change the delay to delayMicroSeconds.

My second question is about the sleep pin on the sparkfun easydriver board. I read (and experimented with example codes) that it "turns off" the motor in order to save power but a few days ago i also read that the enable pin also does this. Which on of the two should i use, the documentaion is sparce about the function of the easydriver board and the datasheet isn't much helpfull.

This is the code i am exprimenting with and it is not the final code by any means. Any suggestions are welcomed

const int DIR = 8;
const int STEP = 9;
const int SLEEP = 10;
const int IN = 2;
const int OUT = 3;

void setup() {                

  pinMode(DIR, OUTPUT);     
  pinMode(STEP, OUTPUT);
 // pinMode(SLEEP, OUTPUT);
  pinMode(IN, INPUT);
  pinMode(OUT, INPUT);
 
  digitalWrite(DIR, LOW);     
  digitalWrite(STEP, LOW);
//  digitalWrite(SLEEP, LOW); //set power off to motor
  digitalWrite(IN, LOW);
  digitalWrite(OUT, LOW);

}


void loop() {

//check to see if both switches are off, if so then power off motor after 10 sec delay
// if (digitalRead(IN) == LOW && digitalRead(OUT) == LOW)
//      {  delay(10000);
//         digitalWrite(SLEEP, LOW);
//     }
     
 
//loop for in movement of motor
  while (digitalRead(IN) == HIGH){
   // digitalWrite(SLEEP, HIGH);
    digitalWrite(OUT, LOW);
    digitalWrite(DIR, LOW);
    digitalWrite(STEP, HIGH);
    delay(50);
    digitalWrite(STEP, LOW);
    delay(50);}
    
//loop for out movement of motor
  while (digitalRead(OUT) == HIGH){
  //  digitalWrite(SLEEP, HIGH);
    digitalWrite(IN, LOW);
    digitalWrite(DIR, HIGH);
    digitalWrite(STEP, HIGH);
    delay(50);
    digitalWrite(STEP, LOW);
    delay(50);}
       
}
 

Link to comment
Share on other sites

You need to code so that you don't hang around in delay loops. The thing gets very inresponsive when you code the way you have done.

Make the loop execute often and pre-scale it so that you on, for instance, every 100th time around do some work.

Enable pin is the one you want, but do not turn it on and off between steps, just when you know that you're done stepping. The step pulse needs to be no more than 1 microsecond regardless of the motor (that's what the A3967 is for ;))

Buttons should be debounced, for instance by making sure that they are pressed in the same state for a number of consecutive runs of the loop or the thing gets very nervous when you press a button - like issuing 30 steps instantly.

I threw this together real quick as an educational piece of code... Enjoy :)

/per

//Assume buttons go high...//This is not complete in any way but illustrates how to code//so that the thing never stands in daly loops more than absolutely//necessary.int buttonCount = 0;int lastButtonState = LOW;int prescale = 100;bool stepping = false;void loop(){    delayMicroSeconds(100);     if (--prescale < 0)    {        // inner loop. Handle buttons first        if (digitalRead(button) == lastButtonState)        {            buttonCount++;            if (buttonCount > 5)            {                //button was the same for five successive loops                //set stepping flag to whatever the button was                stepping = (lastButtonState == HIGH);            }        }        else        {             //button is different to last time - reset counter             buttonCount = 0;             lastButtonState = (lastButtonState == HIGH ? LOW : HIGH);        }        //next thing in inner loop is step the motor if we're stepping        //(add code for choosing direction above...)        if (stepping)        {            digitalWrite(enablePin, HIGH); //make sure we're always enabled when stepping            digitalWrite(directionPin, direction);            digitalWrite(stepPin, HIGH);            delayMicroseconds(1);            digitalWrite(stepPin, LOW);        }        else        {            //not stepping. Set enable low (only if we are not in microstep mode            digitalWrite(enablePin, LOW);        }        //do other things which fits this time interval...        //finally, reset pre-scaler        prescale = 100;    }    //This is place in the code in the outer, faster loop.    //Do important things that have to be done often}
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

I've wired everything up - correctly, I think - but it is not working.

To check that the motor and driver board are okay I uploaded the basic sketch from here that should rotate the motor one full turn backwards and then one full turn forwards, but the motor doesn't move.

What happens is all four LEDs on the driver board glow and the motor vibrates but does not rotate. Is there something obvious that I am doing wrong? I am powering the motor from the 5v output pin from my Nano - I'm getting 4.9v at the driver board input pins. Could it be that the Nano isn't providing enough current to drive the motor. But there must be another fault as I'm sure that the LEDs should blink on and off in sequence with the coils being activated. If all the LEDs are on constantly that can only mean that all four coils are being energised together so it is no wonder that the motor is not rotating as it must be locked in position.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.