Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

Arduino controlled focussing


Gina

Recommended Posts

It's easy to measure, Gina. Just mark the position of the drawtube, turn the focuser knob one full turn and measure how far the draw tube moved out. On my refractor, it moved 20mm for one full turn of the knob (no fine focus). So if I want each 'tick' in the program to give me 0.02mm say, I know that one step must be 0.02 divided by 20, = 1/1000 rotation.

Adrian

Ah right :) Yes, the SteelTrack already has a scale on the drawtube - useful for setting focus approximately after changing cameras or FR. So I can mark the coarse focus knob then turn it one full revolution and see take the drawtube reading. Then I can work out the fine focus to drawtube ratio.
Link to comment
Share on other sites

  • Replies 180
  • Created
  • Last Reply

Have the Nano working fine from the netbook. Hoping to get it all working tomorrow. Control box is half built and I'm well under way on the sketch :)

Link to comment
Share on other sites

Here's the current sketch using the 5 button control system. Not tested yet. Profusely commented so further explanation should not be necessary :D


/* Astro Focussing System using Unipolar Stepper Motor
* Modified 2013-02-27 by Gina Davis
* to control one of two stepper motors selected by toggle switch
* contains routines to move forwards or backwards one phase at a time
* Manual control voltage 0 1 2 3 4 5 volts
* 5v corresponds to 1024
* Voltage levels correspond to 205, 410, 614, 819 and 1024
* Half-way points 102, 307, 512, 717 and 922
//
*/
int motorPins_a[] = {2, 3, 4, 5}; // motor pins for the widefield focuser
int motorPins_b[] = {6, 7, 8, 9}; // motor pins for the scope focuser
int wfPin = 10; // Widefield focuser select switch
int controlPin = 1; // Input control line pin
boolean wf; // Widefield focuser true/false
int focusCount_a = 0; // focus count for WF
int focusCount_b = 0; // focus count for scope
int count = 0; // select motor pin
int count2 = 0; // binary mask for motor pins to select phase
int delayTime = 5; // motor phase time - determines motor rotation speed
int val = 0; // value of control input voltage
int opCode = 0; // corresponding operation code
int stepSize = 20; // how many motor steops correspond to one focussing step
boolean busy = false; // used to provide single action buttons - wait for "up" before continuing
void setup() {
pinMode (wfPin, INPUT_PULLUP); // widefiels switch input with internal pullup resistor
for (count = 0; count < 4; count++) {
pinMode(motorPins_a[count], OUTPUT); // set the widefield motor pins for output
pinMode(motorPins_b[count], OUTPUT); // ditto for scope
}
}
void moveForward() { // move one stepper motor phase forwards
if ((count2 == 0) || (count2 == 1)) {
count2 = 16; // set/reset phase mask
}
count2>>=1; // binary shift phase mask one position right
for (count = 3; count >= 0; count--) {
if (wf) {
digitalWrite(motorPins_a[count], count2>>count&0x01); // widefield focuser
focusCount_a += 1; // increment focus count a
} else {
digitalWrite(motorPins_b[count], count2>>count&0x01); // scope focuser
focusCount_b += 1; // increment focus count b
}
}
delay(delayTime); // stepper phase pulse width (time in ms)
}
void moveBackward() { // move one stepper motor phase backwards
if ((count2 == 0) || (count2 == 1)) {
count2 = 16;
}
count2>>=1;
for (count = 3; count >= 0; count--) {
if (wf) {
digitalWrite(motorPins_a[3 - count], count2>>count&0x01);
focusCount_a -= 1; // decrement focus count a
} else {
digitalWrite(motorPins_b[3 - count], count2>>count&0x01);
focusCount_b -= 1; // decrement focus count b
}
}
delay(delayTime);
}
void moveB10() {
int i ;
if (busy == false) { // do it once then wait for button release
for (i = stepSize * 10; i >= 0; i--) {
moveBackward(); }
busy = true; }
}
void moveB1() {
int i ;
if (busy == false) {
for (i = stepSize; i >= 0; i--) {
moveBackward(); }
busy = true; }
}
void moveF1() {
int i ;
if (busy == false) {
for (i = stepSize; i >= 0; i--) {
moveForward(); }
busy = true; }
}
void loop() {
wf = (digitalRead(wfPin) == LOW);
val = analogRead(controlPin);
// Break points 102, 307, 512, 717 and 922
if (val < 102) { // allow for small variations in control line voltage by separating into bands
opCode = 0;
} else if (val < 307) {
opCode = 1;
} else if (val < 512) {
opCode = 2;
} else if (val < 717) {
opCode = 3;
} else if (val < 922) {
opCode = 4;
} else {
opCode = 5;
}

switch(opCode) {
case 0 : busy = false; delay(100); break; // clear busy flag and wait for button state to settle (switch bounce)
case 1 : moveBackward(); break;
case 2 : moveB10(); break;
case 3 : moveB1(); break;
case 4 : moveF1(); break;
case 5 : moveForward(); break;
}
}
Link to comment
Share on other sites

I'm planning a similar project myself to build a focusser for my MAK127. I have an arduino uno and have this switch on order:

http://www.amazon.co.uk/Buttons-Switches-Joysticks-COM-10541-Selector/dp/B004VBNRTU/ref=sr_1_20?s=electronics&ie=UTF8&qid=1362509899&sr=1-20

I plan to have the 5 positions:

1 fast cw

2 slow cw

3 off

4 slow ccw

5 fasr ccw

Link to comment
Share on other sites

I'm planning a similar project myself to build a focusser for my MAK127. I have an arduino uno and have this switch on order:

http://www.amazon.co...2509899&sr=1-20

I plan to have the 5 positions:

1 fast cw

2 slow cw

3 off

4 slow ccw

5 fasr ccw

Sounds fine :) Though that switch has a strange permutation of connections.
Link to comment
Share on other sites

I'll let you know how I get on decoding the permutations. I'll start a fresh topic once I have all the bits together and can start programming the arduino. It's actually a nano not uno as stated in my previous post.

Link to comment
Share on other sites

I've finished the control box and that's working. But the sketch may have problems. Well something has. I've added a readout (by serial monitor) of the focus count and the count is going up and down but the B10, B1 and F1 seem to produce the wrong count change. The one-shot action works OK for those and the FF & FB increase and decrease the count continuously as expected. However, the stepper is not moving :( It vibrates in the two fast modes but doesn't actually move. More detailed testing required.

Link to comment
Share on other sites

I'll let you know how I get on decoding the permutations. I'll start a fresh topic once I have all the bits together and can start programming the arduino. It's actually a nano not uno as stated in my previous post.

OK - fine :)
Link to comment
Share on other sites

Gina,

If you can check that the stepper is actually a 64 step motor. I think I read somewhere that some are 32 step, and the gearbox is not exactly 64:1 as well. All a bit weird. Dont know if this will have an effect or not. As i dont have any of them yet i cannot confirm thats the case, and i have looked but also can not find where i read about this supposed oddity!! I will keep looking...

Simon

Link to comment
Share on other sites

For those of you who want an easier/cheaper route to controlling a stepper I can recommend coupling the EasyDriver stepper

http://proto-pic.co.uk/easydriver-stepper-motor-driver/

with a FTDI USB to parallel port converter.

http://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT245R.pdf

With the addition of a connector to interface to the motor and power connector for the motor nothing else is needed.

The library provided by FTDI provides an easy solution to control the parallel interface directly from a PC via a USB port.

No embedded programming required. £30 for the two devices.

gallery_27167_2435_2267823.jpg

gallery_27167_2435_1032366.jpg

Link to comment
Share on other sites

I've finished the control box and that's working. But the sketch may have problems. Well something has. I've added a readout (by serial monitor) of the focus count and the count is going up and down but the B10, B1 and F1 seem to produce the wrong count change. The one-shot action works OK for those and the FF & FB increase and decrease the count continuously as expected. However, the stepper is not moving :( It vibrates in the two fast modes but doesn't actually move. More detailed testing required.

From my experience, that indicates that the stepper is underpowered. It lacks the initial impetus to move a step as fast as the step rate, and so it stalls. How much load does the focuser put on the motor? If it's a 64-step motor then steps are big, 5v isn't much to push it, and the load won't help. I'm reluctant to join the chorus of people recommending EasyDriver boards, but they handle 12v steppers brilliantly - I use one geared at 1 : 1 on a fairly stiff C9.25 focuser. Since steppers give no feedback on whether or not they've moved, and since accuracy is part of the exercise, I favour using a motor which I can be certain has done what I've asked of it. There's such a thing as too big, but there's no such thing as too strong.
Link to comment
Share on other sites

Gina,

If you can check that the stepper is actually a 64 step motor. I think I read somewhere that some are 32 step, and the gearbox is not exactly 64:1 as well. All a bit weird. Dont know if this will have an effect or not. As i dont have any of them yet i cannot confirm thats the case, and i have looked but also can not find where i read about this supposed oddity!! I will keep looking...

Simon

Here's the details of the stepper motor :-

  • Model: 28BYJ48
  • Operating voltage: 5V
  • Step angle: 5.625°
  • Reduction ratio: 64
  • Pull-in Torque: >300gf.cm
  • Max starting frequency: 500pps
  • Max operating frequency: 900pps
  • Diameter: 28mm

I'm running at 200pps so that should be alright. I'm testing with no load. The measured supply voltage I'm feeding it is 4.75v. Driver is ULN2003A darlington transistor chip which is well up to the job. One thing I might try is running the stepper and driver from a separate supply rather than the 5v pin on the Arduino. I could at the same time try increasing the voltage slightly. Presumably the motor is rated for continuous operation so with the intermittent operation of focussing I could increase the supply voltage a fair bit. Also the load is very light for both focusers. SteelTrack is very light on the fine focus knob and the widefield has a free running 64:1 gearbox.

Link to comment
Share on other sites

If there's no load then the only time I've encountered the symptoms you describe was when one motor lead wasn't properly connected.

That's how it seemed to me but they seem to be alright.
Link to comment
Share on other sites

I think I might try a half phase stepper sketch and see if that's better. Gives a smoother drive and more power as there are two coils powered half the time. I have a link to another stepper sketch that uses a lookup table to determine which coils are powered. I prefer this to the (what I consider) "over clever" binary shift method in the present sketch but that's a purely personal opinion though I can't see any way of using the bit shift method for half-phase stepping.

Link to comment
Share on other sites

D'Oh! What a numpty I am! I'd forgotten that pots have a limited travel so I won't be able to do what I'd hoped to with one. Looks like I need a rotary encoder or something - preferably without any detentes as I'd rather have a smooth control. The general idea being to translate clockwise/counter-clockwise motion of a rotary control to forward/reverse motion of a motor connected to the focuser. Back to drawing board for me! :)

Link to comment
Share on other sites

I made myself one of those. It was a rotary dial with 12 contacts, smooth travel, no stops. By connecting each contact to one of 4 coils of a unipolar stepper (and shorting contact #1-#5-#9 and #2-#6-#10, etc) I could get a "jog" function that worked both forwards and backwards in full step mode.

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.