Thanks to the unfortunate current situation and having more time at home I have managed to complete this project. Well..kind of, it still has bugs and my self-learned coding skills are probably the most inefficient
To sum up what the telescope autoguider does:
I am taking images from a 1024x1280 pixels monochrome CMOS imager using teensy 3.6. Because there is not enough RAM in Teensy I am binning the data online in 4x4 pixels to get 320x240 images to an LCD.
The imager is pointed to stars on a telescope mount (I use a 180mm f/2.8 Nikkor lens). On the image it recognises the 3 brightest stars and I have to option to select one. After selection I start to collect subframes from the CMOS imager 200x200 pixels.
From the subframe I take the data 16x16 pixels around the star (most intense cluster of 5 pixels - central + 2 adjacent in each column and row direction). Within this 16x16 data array I do calculations to determine with sub-pixel precision the position of a star.
I tried a few different algorithms how to determine star centroid, tried even fitting a 2D-gaussian function with the Teensy, but the best result was to calculate simply the center of mass of the image. Works really well.
The autoguider has a bluetooth module that communicates with the telescope controller.
This is close to doing it's job, but first needs calibration (scale and angle of the image). I move the telescope for 10s in one direction and calculate how much and in which direction the star has moved, and calculate the parameters to be able to convert the positions into a new, rotated coordianate system.
Then it is ready to go! Once I start guiding the autoguider is measuring position of the star in the image and in case it moves from the position by a defined error margin it sends movement corrections to the telescope. Simple proportional control, works excellent. I get sub-pixel accuracy, so that I can track a 900mm telescope precisely using only a 180mm lens. I added the option of "dithering" this is doing small random movements, between every camera exposure I move the telescope for a random amount from the initial position, up to a given maximum amount of pixels in distance.
All comes with quite a few settings (for the CMOS imager and for the autoguiding algorithms) to be able to do everything accurately.
Here is a video to see it in action:
https://www.youtube.com/watch?v=eLeirHzpUQQ
Each line in the graph is 1 pixel difference in star position. As you can see the position of the star is kept very tight, p-p error was here some 0.7 pixel. RMS is probably about +-0.3 pixel, which with the imager and lens used is some 1.5 arcseconds. This is good enough for a medium sized telescope (up to 1000mm focal length). I use a relatively inacurate tracking mount, if I do not do any corrections the error in tracking the star will be about 30 arcseconds.
The best is that having a tiny unit directly on the lens that is battery powered (it is good for some 4-5 hours) I have everything ready in 10 minutes, whereas normally this king of autoguiding would involve a laptop and cables, there is also laptop battery life if being on the field. Some people do it with a Raspberry pi though I read...
This is how it looks like, attached to a 180mm lens:
The kind of an image that I would make: