I made an Arduino Focuser :)

A place to post guides, instructions and HOWTO documents on the use of SharpCap and Astrophotography in general
Forum rules
One tutorial per topic please.
Please only post content that you have created in this form.
Tutorials should be either in PDF format as an attachment or written in the first post of the topic. Links to video tutorials you created are also acceptable.
Post Reply
User avatar
admin
Site Admin
Posts: 13349
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

I made an Arduino Focuser :)

#1

Post by admin »

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.
PXL_20230315_213009418 (Medium).jpg
PXL_20230315_213009418 (Medium).jpg (230.13 KiB) Viewed 9538 times
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
PXL_20230314_164558770 (Medium).jpg
PXL_20230314_164558770 (Medium).jpg (350.94 KiB) Viewed 9538 times
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 :
PXL_20230315_212950226 (Medium).jpg
PXL_20230315_212950226 (Medium).jpg (322.78 KiB) Viewed 9538 times
PXL_20230315_221006473 (Medium).jpg
PXL_20230315_221006473 (Medium).jpg (311.19 KiB) Viewed 9538 times
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
Hirokazu
Posts: 6
Joined: Fri Apr 05, 2019 11:50 pm

Re: I made an Arduino Focuser :)

#2

Post by Hirokazu »

Hi Robin
I have just completed a DIY focuser for old Nikon 135mm too.
The motors etc,have a similar configuration.
The board is an ESP32.
I have already put it to practical use and am using it for astro-photography.
The SmartScan has great performance.
I thought it would be easier to DIY if there was a backlash analysis tool.

Regards
Attachments
IMG_0621.JPG
IMG_0621.JPG (97.63 KiB) Viewed 9438 times
Last edited by Hirokazu on Tue Mar 21, 2023 8:32 pm, edited 1 time in total.
User avatar
admin
Site Admin
Posts: 13349
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: I made an Arduino Focuser :)

#3

Post by admin »

Hi,

that looks great - I can see you have gone for a belt drive approach, which makes sense for a camera lens. One of these days I will get around to adding backlash measurement to SharpCap :)

cheers,

Robin
timh
Posts: 515
Joined: Mon Aug 26, 2019 5:50 pm

Re: I made an Arduino Focuser :)

#4

Post by timh »

That looks a fascinating little engineering project. Thanks for sharing it. I'd never heard of Arduino before but the link provided a good introduction. With that and a 3D printer the world of designing and controlling things via software looks like it's open to the hobbyist. Above my head though -- I was an electronics enthusiast years ago but that was way back in the stone age of discrete components and when programmable calculators were the latest thing.

Tim
Hirokazu
Posts: 6
Joined: Fri Apr 05, 2019 11:50 pm

Re: I made an Arduino Focuser :)

#5

Post by Hirokazu »

Hi Robin
Thanks for the reply.
I have another lens that needs a focusser so I will try your code as well.
I also found the UNO and shield in a storage box.

Regards
User avatar
admin
Site Admin
Posts: 13349
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: I made an Arduino Focuser :)

#6

Post by admin »

Hi Tim,

I remember programmable calculators - my Dad had a Hewlett Packard one back in the late 70s or very early 80s and it was great learning what you could do with it :)

For anyone who is building the Uno/Shield version, I also added the STL files for a 3D printed case to the github release page.

I have 2 more stepper motors sitting unused... Now I am starting to think about a flat frame device for solar imaging perhaps... :)

cheers,

Robin
WB91
Posts: 27
Joined: Wed Jun 17, 2020 3:13 pm

Re: I made an Arduino Focuser :)

#7

Post by WB91 »

Robin,

Will your code work on a Arduino Nano/shield? I have a design from a few years ago using a Nano with a PCB I designed for a single motor controller. It was originally supposed to work with the MyFocuserPro2 project but I gave up on it. It would be nice to test this out but using a Nano as it is smaller in size.

Regards,
Bill
User avatar
admin
Site Admin
Posts: 13349
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: I made an Arduino Focuser :)

#8

Post by admin »

Hi Bill,

I have not used a Nano, but I think it should work (perhaps with minor changes). You would need to make sure that you have a CNC shield with the A4988 stepper motor circuit plugged in - that handles most of the stepper motor control meaning that from the Arduino side it is very simple. I think that it would just be a case of (perhaps) changing the pin definitions for direction,step and motor enable in AFMotor.cpp.

cheers,

Robin
Post Reply