I made an Arduino Focuser :)
Posted: Wed Mar 15, 2023 10:19 pm
Hi folks,
If anyone has seen me over the years at one of the UK Astro Shows on the SharpCap stand, you have probably seen one or more incarnations of a homemade ASCOM focuser based on a simple SkyWatcher focus motor and a little USB gadget to drive it. Usually with 3D printed gears of one sort or another making the motor turn the focus ring of a lens...
That set up has been useful over the years, both for shows and for testing various focus related features, but the DC motor design meant that the position wasn't really stable - move it 1000 steps in one direction and you needed to come back 1050 to end up back in the same place.
Swapping round some kit (including installing a Pegasus Ultimate Power Box) meant that I ended up with a Pegasus motor focus controller spare, so I picked up an extra motor at the PAS show and set this up.
This works nicely, with the Pegasus turning the CS type lens focus ring attached to an Altair GPCam.
However, it was only a temporary setup because I have other plans for that Pegasus Focus motor - trying to get it set up on a long focal length scope for some testing on lunar/planetary imaging.
I was thinking of whether I should buy yet another focus motor, when I realised that among various bits sitting around the place I had...
* An Arduino Uno from testing out something
* A NEMA 17 stepper motor bought as a replacement when I thought one on my 3D printer was failing (it wasn't failing...)
That got me thinking about Arduino based focus controller for ASCOM, because I knew such things existed...
What a rabbit hole!
There are lots of them - all different, often designed around different ways to control the stepper motors, many with add-on hardware like displays or rotary encoders, or who knows what else. If you're lucky they're on Github and you can at least poke through the code. If you are unlucky then they are on SourceForge (who uses that anymore -really!) and it's a minefield of fake links to try to find what to download and where the code is.
In the end, I decided to start from basics and just make sure I could make a stepper motor move from the Arduino. One 'A4988' stepper driver circuit later (£3.99 from Amazon) and I had this
The Arduino on the left sends signals over two wires (direction and step) to the driver circuit in the middle, which just needs the addition of 12V and 5V power and it makes the stepper move. Hurrah!
That had me convinced I could make this work, so I started from one of the simpler existing Arduino Focuser projects on Github (https://github.com/ejholmes/Arduino-Focuser) and started to adapt it to my purposes.
I threw away the ASCOM driver and replaced it with the code I have previously written for driving the Skywatcher motor focus - the skeleton of the driver and the installer of that were fine, I would just need to replace the code that actually sent commands to the device.
On the Arduino side, less changes needed, although the original project was trying to do low level driving of the steppers, which is handled by the A4988, so I re-wrote the motor driver code in a much simpler form. Along the way I added some tweaks to make the command protocol more robust and to add acceleration and speed control.
On the hardware side, the mess of wires had to go and the best approach seemed to be to add a 'CNC Shield' to the Arduine - this costs about £7 off of Amazon and can hold up to 4 stepper motor drivers. Here's the improved hardware :
The only modifications necessary are the blue + orange wires you can see in the second picture. They take the Vin and GND from the Arduino and feed it to the supply for the stepper motors (the blue terminal connectors on the left). This means that powering the Arduino with 12V powers the whole system and is a bit tidier than feeding 12V direct to the terminals. You can't run this stepper on 5V, and the USB port will not provide enough power to drive a boost converter to give it 8V or so (I tried that).
So, there we go - nearly ready. I need to 3D print a bracket to fit it in place of the Pegasus unit and probably a case for the Arduino too.
The motor does 200 full steps per revolution, but can be set to 1/16 microstepping mode, giving a total of 3200 steps per revolution. If I put a relatively small gear on the shaft then I get some reduction too. For driving camera lenses that's fine - if you were trying to drive a telescope focuser with a heavy camera on, it might struggly. In that case some sort of more significant reduction gearing might be in order.
Anyway, if anyone is interested in trying it out, the code is on Github : https://github.com/rwg0/Arduino-Focuser/
I also uploaded the installer for the ASCOM driver and the compiled Arduino Sketch : https://github.com/rwg0/Arduino-Focuser ... tag/v2.0.0
Of course there are probably bugs - this has only existed for 2 days so far, so there have to be bugs...
cheers,
Robin
If anyone has seen me over the years at one of the UK Astro Shows on the SharpCap stand, you have probably seen one or more incarnations of a homemade ASCOM focuser based on a simple SkyWatcher focus motor and a little USB gadget to drive it. Usually with 3D printed gears of one sort or another making the motor turn the focus ring of a lens...
That set up has been useful over the years, both for shows and for testing various focus related features, but the DC motor design meant that the position wasn't really stable - move it 1000 steps in one direction and you needed to come back 1050 to end up back in the same place.
Swapping round some kit (including installing a Pegasus Ultimate Power Box) meant that I ended up with a Pegasus motor focus controller spare, so I picked up an extra motor at the PAS show and set this up.
This works nicely, with the Pegasus turning the CS type lens focus ring attached to an Altair GPCam.
However, it was only a temporary setup because I have other plans for that Pegasus Focus motor - trying to get it set up on a long focal length scope for some testing on lunar/planetary imaging.
I was thinking of whether I should buy yet another focus motor, when I realised that among various bits sitting around the place I had...
* An Arduino Uno from testing out something
* A NEMA 17 stepper motor bought as a replacement when I thought one on my 3D printer was failing (it wasn't failing...)
That got me thinking about Arduino based focus controller for ASCOM, because I knew such things existed...
What a rabbit hole!
There are lots of them - all different, often designed around different ways to control the stepper motors, many with add-on hardware like displays or rotary encoders, or who knows what else. If you're lucky they're on Github and you can at least poke through the code. If you are unlucky then they are on SourceForge (who uses that anymore -really!) and it's a minefield of fake links to try to find what to download and where the code is.
In the end, I decided to start from basics and just make sure I could make a stepper motor move from the Arduino. One 'A4988' stepper driver circuit later (£3.99 from Amazon) and I had this
The Arduino on the left sends signals over two wires (direction and step) to the driver circuit in the middle, which just needs the addition of 12V and 5V power and it makes the stepper move. Hurrah!
That had me convinced I could make this work, so I started from one of the simpler existing Arduino Focuser projects on Github (https://github.com/ejholmes/Arduino-Focuser) and started to adapt it to my purposes.
I threw away the ASCOM driver and replaced it with the code I have previously written for driving the Skywatcher motor focus - the skeleton of the driver and the installer of that were fine, I would just need to replace the code that actually sent commands to the device.
On the Arduino side, less changes needed, although the original project was trying to do low level driving of the steppers, which is handled by the A4988, so I re-wrote the motor driver code in a much simpler form. Along the way I added some tweaks to make the command protocol more robust and to add acceleration and speed control.
On the hardware side, the mess of wires had to go and the best approach seemed to be to add a 'CNC Shield' to the Arduine - this costs about £7 off of Amazon and can hold up to 4 stepper motor drivers. Here's the improved hardware :
The only modifications necessary are the blue + orange wires you can see in the second picture. They take the Vin and GND from the Arduino and feed it to the supply for the stepper motors (the blue terminal connectors on the left). This means that powering the Arduino with 12V powers the whole system and is a bit tidier than feeding 12V direct to the terminals. You can't run this stepper on 5V, and the USB port will not provide enough power to drive a boost converter to give it 8V or so (I tried that).
So, there we go - nearly ready. I need to 3D print a bracket to fit it in place of the Pegasus unit and probably a case for the Arduino too.
The motor does 200 full steps per revolution, but can be set to 1/16 microstepping mode, giving a total of 3200 steps per revolution. If I put a relatively small gear on the shaft then I get some reduction too. For driving camera lenses that's fine - if you were trying to drive a telescope focuser with a heavy camera on, it might struggly. In that case some sort of more significant reduction gearing might be in order.
Anyway, if anyone is interested in trying it out, the code is on Github : https://github.com/rwg0/Arduino-Focuser/
I also uploaded the installer for the ASCOM driver and the compiled Arduino Sketch : https://github.com/rwg0/Arduino-Focuser ... tag/v2.0.0
Of course there are probably bugs - this has only existed for 2 days so far, so there have to be bugs...
cheers,
Robin