Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Arduino focuser - is this idea feasible?


Andy_K

Recommended Posts

I've read through just about all of the threads relating to Arduino based focusers and building one is definitely something I'm going to have a go at.

A 'version' I haven't seen yet is one using rotary encoders...so I'm guessing there's probably a reason for it! But here goes...

My idea was to use 2 rotary encoders to control the stepper.  One encoder for coarse focusing and the other one for fine adjustment.

Something like this :

post-35784-0-90612000-1397055964_thumb.j

In theory the coarse encoder would move the stepper a larger number of steps and the fine one would be single (or half) step.

I did toy with the idea of using potentiometers (connected to the analogue inputs) instead of rotary encoders but thought the 360° rotation of the encoders would be more suitable.

As my knowledge of programming is on a par with my guinea pig's, I'd like to know if the idea is feasible or not before attempting to blatantly copy and modify the various (rather brilliant) sketches and ideas from southerndiver357, yesyes, Gina etc. :wink:

Any comments would be gratefully received.

Link to comment
Share on other sites

I built a focuser using almost precisely that setup - except I use a single rotary encoder, and the built-in push button on it cycles between fast and slow modes.

Works very nicely.

I should probably get around to cleaning up and publishing the source code sometime. Getting the rotary encoder to work smoothly was the tricky bit, especially with cheap encoders that generate quite a bit of bounce. Interrupts are the key here.

Link to comment
Share on other sites

I did one using a joystick with the push in switch grounding the 1/2 step pins on the stepper drive for a high speed mode. It works very well.

Link to comment
Share on other sites

Interesting :)  Not come across those before.  Makes for a neat and compact solution.  Could even work out cheaper too.  Needs debouncing code in the sketch but so do push buttons.  Definitely something to think about :)

Later...  Well, its £6.88 inc. P&P and VAT.

Link to comment
Share on other sites

  • 6 months later...

I built a focuser using almost precisely that setup - except I use a single rotary encoder, and the built-in push button on it cycles between fast and slow modes.

Works very nicely.

I should probably get around to cleaning up and publishing the source code sometime. Getting the rotary encoder to work smoothly was the tricky bit, especially with cheap encoders that generate quite a bit of bounce. Interrupts are the key here.

Is the publishing of the source code still a possibility?

I've not had a great deal of luck myself yet - I should really have made use of the light nights to read up on Arduino coding! ;)

Link to comment
Share on other sites

There is more than way to skin a cat. I haven't toyed with this yet but intuitively it should be somewhat straightforward.

Back in the day the problem I had while playing with encoders was my circuit missing some of the pulses and/or the quadrature getting out of whack. But with a fairly quick microcontroller you should have no problems.

The only thing I would try myself if I were in your shoes would be a magnetic/hall effect encoder. Those are some fun devices :)

Link to comment
Share on other sites

There is more than way to skin a cat. I haven't toyed with this yet but intuitively it should be somewhat straightforward.

Back in the day the problem I had while playing with encoders was my circuit missing some of the pulses and/or the quadrature getting out of whack. But with a fairly quick microcontroller you should have no problems.

The only thing I would try myself if I were in your shoes would be a magnetic/hall effect encoder. Those are some fun devices :)

Interesting point :)  I've been using push button switches with de-bounce code in the Arduino sketch.  This is simple and works, though push buttons are far from the most reliable devices and sometimes don't make contact.  I may have a play with hall-effect devices - I have several, also a number of small magnets.  OTOH I use optical encoding for my weather station wind vane so that's another option.

With my Arduino controlled focusers I have strived to keep things simple and keep the number of wires to/from the scopes to warm room to a minimum.  I could reduce this further when I add ASCOM code to my Arduino sketch to provide auto-focussing but ATM I have so much on my mind that I just can't cope with the complication.  My latest design just uses an audio screened cable with a resistor network in the warm room.  Then at the Arduino a resistor from the +5v and to the wire and that then connects to an analogue input.  The code then sorts out which button was pressed by the resistance produced and the resulting voltage.

Link to comment
Share on other sites

Ah... I didn't considered the possibility of using this remotely (from a warm, cozy room). That would probably add an extra layer of complexity, because the signals from the encoder may deteriorate fairly quickly with distance.

In any case, and just to throw an idea into the mix: the "magnetic encoders" I was talking about are actually ICs from a company called Austria Microsystems ("AMS"). These ICs can detect the rotation of a magnet located close to the IC surface, and can also detect the magnet being pushed toward the IC (pushbutton-style). The output can be I2C, SPI, quadrature, PWM or even analog (different part numbers for each one), and the number of pulses per revolution so far go up to 4096. The nice thing of using one of these is that -as far as I can remember- you can change the number of pulses per revolution on the go... giving you the variable rate focuser you need :)

I think there are some "actual" (i.e. more than the IC) encoders on the market using the AMS ICs, but I have never used one.

Link to comment
Share on other sites

Is the publishing of the source code still a possibility?

I've not had a great deal of luck myself yet - I should really have made use of the light nights to read up on Arduino coding! ;)

The full code needs a lot of cleanup before I could publish it - but here's the ISR I use to track the encoder position:

/* encoder routine. Expects encoder with four state changes between detents *//* This code will need changing for other boards and other pins *//* I use Arduino Micro */#define ROTA                   2 // pin 2 associated with int0#define ROTB                   3 // pin 3 associated with int1void setup(){    pinMode(ROTA, INPUT);    pinMode(ROTB, INPUT);    digitalWrite(ROTA, HIGH);                        // enable pullups    digitalWrite(ROTB, HIGH);    attachInterrupt(0, rotary_isr, CHANGE);    attachInterrupt(1, rotary_isr, CHANGE);}volatile int rotary_position = 0;void rotary_isr(){    static int8_t stepsSeen = 0;    static uint8_t old_AB = 3; //lookup table index and initial state    uint8_t encport; //encoder port copy    static const int8_t enc_states[] PROGMEM =    { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 }; //encoder lookup table    old_AB <<= 2;     //remember previous state    encport = ENC_RD & 0x03;    //read encoder    old_AB |= encport;   //create index    stepsSeen += pgm_read_byte(&(enc_states[( old_AB & 0x0f )]));    if (stepsSeen > 1)    {        // two steps forward        rotary_position += 1;        stepsSeen = 0;    }    else if (stepsSeen < -1)    {        //two steps backwards        rotary_position -= 1;        stepsSeen = 0;    }}
Link to comment
Share on other sites

This link gives a nice way of reading rotary encoders  without needing any debounce routines.

There is also a useful discussion of implimenting as an interrupt driven routine.

Hope it helps.

Hugh

www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino 

Thank you for that link - it could be very useful :)  I have several rotary encoders that I haven't got round to using :D

Link to comment
Share on other sites

Two in fact :)

I was talking about the scroll wheel :) I don't know if there's any non-optical mouse left among the pile of electronic garbage spares I have in my home "office".

Googling "mouse scroll wheel arduino" gives you, among other things, the following:

http://www.stevekamerman.com/2010/12/understanding-a-mouse-scroll-wheel/

Oh my... now I'll have to build one of these... ;)

Link to comment
Share on other sites

I was talking about the scroll wheel :) I don't know if there's any non-optical mouse left among the pile of electronic garbage spares I have in my home "office".

Googling "mouse scroll wheel arduino" gives you, among other things, the following:

http://www.stevekamerman.com/2010/12/understanding-a-mouse-scroll-wheel/

Oh my... now I'll have to build one of these... ;)

Ah yes, I see :D  I had forgotten about the scroll wheel - good thinking :)  And thank you for posting that link - very interesting :)  I have quite a collection of "dead" mice and trackballs :D

Link to comment
Share on other sites

The thing to remember about the small rotary encoders is that they will only give you the direction they are turning i.e. clockwise/anticlockwise. They are not analogue devices. If you get it working using the code in the link I posted (scroll to the very end for the code I used) you can then decide how many steps to move the stepper motor for each transition from the encoder. My first focuser used this method in combination with a 5-way switch to determine direction and speed. The encoder was used for fine adjustment when the switch was in the centre/neutral position.

http://stargazerslounge.com/topic/202282-ascom-and-arduino/

I eventually discarded the manual focuser although it worked fine and converted it to a pure ascom-based design as I wanted control from my PC.

http://stargazerslounge.com/topic/218975-arduino-ascom-focuser-mark2/

I got the encoder I used from technobots - they have a good range

http://www.technobotsonline.com/?subcats=Y&status=A&pshort=N&pfull=N&pname=Y&pkeywords=N&search_performed=Y&q=rotary+encoder&x=0&y=0&dispatch=products.search

I used this one, it also has a handy push switch in the centre http://www.technobotsonline.com/rotary-encoder-12-step.html

Link to comment
Share on other sites

Yep... Encoders will give you the information you need to determine which way they are moving ("quadrature"), and you need to implement a way to handle that. In the good old days you would use a couple of flip-flops on the A/B signals from the encoders and that would give you signals to increment/decrement a counter.

Now... the interesting stuff is what you do with that signal. You can either use that as a position (i.e. one pulse of the encoder translates into a fixed number of steps of the motor), as speed (count the number of pulses from the encoder over a certain amount of time and use that as a speed signal for the motor), acceleration, etc.

Have you ever read the sentence "when I finally knew all the answers they changed all the questions"? Now... if instead of a stepper you use a small servo (removing the rotation limits) and use the encoder to determine speed... Just sayin' :)

Link to comment
Share on other sites

I still prefer a stepper motor.  Whether to use a rotary encoder, push buttons or ASCOM interface depends on your abilities and feelings on the matter :D  I shall probably go for the ASCOM interface eventually.  My problem is that I'm no longer able to progress projects at anything like I did in the past - I just don't have the stamina now :(

Link to comment
Share on other sites

Archived

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

×
×
  • 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.