Bahtinov based autofocus

Note latest version is V10.0 from Sep 20 2009!
release notes:
1) text now outside bitmap
2) remembers last settings used

I could not resist to take the next step:

The Bahtinov grabber (13571) gives your absolute focussing error (in pixels), so even with a simple non-absolute motorized focusser it should be possible to develop a fully automatic focus control.

There is now only one Bahtinov grabber version, one that includes autofocus control. It is not necessary to use autofocus of course, of you just want to determine the focus error live.

Ingredients:

- Celestron 8 inch telescope

- JMI motofocus (simpleDC motor that is able to rotate the focuser knob, prevents telescope shake while focusing)

- Shoestring PC focus control unit (USB box that gives PC control over the JMI motofocus)  ASCOM driver here

- ASCOM, open software platform for controlling “any” focusser

When you have selected the capture area (live view of my Philips ToUcam in VirtualDub in my case), the software starts detecting the focus error. I used an artificial star (Maglite LED torch, with a tiny pinhole on some household aluminium foil at about 15 m distance, just within focal range of the telescope.) and a water-jet cut aluminium Bahtinov mask.

As soon as you hit any of the buttons in the “focusser” box, an ASCOM dialog asks you to connect to which focusser. Then you can manipulate focus, left or right, or… autofocus!

Autofocus works in 5 steps:

- 1: check unitial focus error: must be smaller than 100 pixels to continue to step 2 otherwise stop autofocus

- 2: backlash removal: motor starts slowly until the bahtinov pattern changes sinificantly

- 3: determine sensitivity: move until bahtinov pattern changes 5 pixels and determine how much the motor has to move per pixel change

- 4: fine focussing

- 5: When both the focus error and the 15s averge focus error is smaller than 0.5 pixels: “AF Ready”.

ascom.jpg

with-error-sign-and-5s-average

35 Responses to “Bahtinov based autofocus”

  1. Thierry says:

    Hi Niels, that’s a fantastic tool for a fantastic focusing.

    When do you share this new version?

    Thank you very much for this great job

    Thierry

  2. Yuriy Toropin says:

    Hi Niels,

    It looks like it’s not possible to download the newest version with the “focusser” buttons’ box, all links point to older version without this new cool addition. Could you please correct this?

    Anyway – tried it with different images and animations of stars imaged with the Bahtinov mask – works like a charm, thanks a lot!

  3. Jerry Ott says:

    Neil,
    Great work. I don’t own a motorized focuser. Would this software actually work using manual focusing?
    Thanks,
    Jerry.

  4. Ioannis Ioannou says:

    I was looking for something like this since last September, looking forward for the version with the ascom drivers focus support.

  5. Enrico says:

    Hello Niel.I have purchased, a few weeks ago, two Bratinov masks even if I am having good luck with my Starizona microtouch autofocus motor served by MaximDL used directly, without the mask, I mean. I wonder if your sofware might work with my setup.
    Thanks for your attention.

    Clear Skies. Enrico

  6. admin says:

    Starizona claims that your focuser is ASCOM compatible:

    http://starizona.com/acb/MicroTouch-Wireless-Autofocuser-P1041C0.aspx

    You need to install the ASCOM platform:

    http://mswwt.vo.llnwd.net/o25/ascom/ASCOMPlatform5a.msi

    and normally you need to install an ASCOM driver, specifically for your focuser. Maybe it is already installed on your system, otherwise ask starizona for the ASCOM driver.

  7. Enrico says:

    In fact I have either the ASCOM platform and Ascom driver for my focuser installed already and working properly.
    So I should be able to try with your program mated with Bratinov mask. Isn’t it?

  8. admin says:

    Enrico, you are ready to start using autofocus.

  9. Jon says:

    The grabber works very well except I have problems controlling an Optec TCF-S focuser. Setting 100 in the GUI and clicking [Right] the focuser moves to absolute position 100 rather than an increment of 100. Clicking [left] gives an error message (probably because grabber is trying to move to absolute position -100?).

    I’m using the latest August version and an up to date driver for the Optec.

    Jon

  10. Boris says:

    I have a Moonlite with DC motor control and soon I hope to have the Shoestring FCUSB interface. I can’t wait to try your autofocus program. I was already impressed by the Bahtinov grabber but this autofocus function will be incredible (if I can get all parts and make it work).

    Great work thank you.
    Boris

  11. admin says:

    Together with Jon we tested autofocus for his absolute (Optec TCF-S ) focuser. It works fine now (Version 9.0 of the Bahtinov Grabber, 12 Sep 2009).
    Thanks Jon!

  12. admin says:

    Should be working fine. Let me know how it works out!

  13. admin says:

    Let me know if it works. Feedback makes things better in this case!

  14. Hi Niel and excuse my English. I also have a Celestron C8 and MOTOFOCUS JMI, and you know the final approach to the focus in C8 to be done in an anti-clockwise to compensate for gravity. this is done by the software (Bahtinov grabber) in autofocus mode
    Thanks.

  15. admin says:

    I did not do that on purpose, but it is good to hear Murphy sometimes sleeps!

  16. Sorry, the above is not an assertion, is a question.
    Could we schedule a check box with the final rotation direction?
    Thank you.

  17. Themos Tsikas says:

    Hello, thanks for a great tool. I have a bug report though: With the increment set to 10, if I press the button “Left” (and I have the Pipe diagnostic tool ASCOM focuser selected) I see:

    Focuser Link: -> True (done)
    Focuser IsMoving: False
    Focuser Absolute: True
    Focuser Position: 0
    Focuser Move: -10 (initiated)

    I think the ASCOM standard says you are not supposed to pass negative values to the Move method:

    ” If the Absolute property is True, then this is an absolute positioning focuser. The Move command tells the focuser to move to an exact step position, and the Position parameter of the Move() method is an integer between 0 and MaxStep.”

  18. Themos Tsikas says:

    I have modified my own ASCOM driver to handle negative Move vals in Absolute mode so I can use your existing app.

    Thanks again!

  19. [...] Software de ayuda al enfoque con máscaras Bahtinov para Windows. Es muy interesante la capacidad incluida de autofoco. Habrá que probarlo. [...]

  20. B. Ramsey says:

    Hello, I would love to use this program, but I receive an unhandled exception when I try to click on anything in the program.

    Windows 7 64bit (UAC turned off)

    Here is the detailed error..

    ************** Exception Text **************
    System.Runtime.InteropServices.COMException (0×80040154): Retrieving the COM class factory for component with CLSID {BDE110B3-5859-440C-8ABA-AD9A9D5F7481} failed due to the following error: 80040154.
    at ASCOM.DriverAccess.Focuser.Choose(String focuserID)
    at Bahtinov_grabber_autofocus.MainForm.FocusserConnected()
    at Bahtinov_grabber_autofocus.MainForm.config_button_Click(Object sender, EventArgs e)
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Loaded Assemblies **************
    mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
    —————————————-
    Bahtinov_grabber
    Assembly Version: 1.0.0.1
    Win32 Version: 1.0.0.1
    CodeBase: file:///D:/Desktop/Bahtinov_grabber.exe
    —————————————-
    System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    —————————————-
    System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    —————————————-
    System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    —————————————-
    ASCOM.DriverAccess
    Assembly Version: 1.0.5.0
    Win32 Version: 1.0.5.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ASCOM.DriverAccess/1.0.5.0__565de7938946fba7/ASCOM.DriverAccess.dll
    —————————————-
    ASCOM.Interfaces
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ASCOM.Interfaces/1.0.0.0__565de7938946fba7/ASCOM.Interfaces.dll
    —————————————-
    ASCOM.Helper
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/ASCOM.Helper/1.0.0.0__565de7938946fba7/ASCOM.Helper.dll
    —————————————-

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

  21. Tom says:

    I get the same error as B. Ramsey.
    Please fix this great program for us :)

  22. admin says:

    I will try to make a 64 bit version soon.

  23. Christian Schubert says:

    Dear Nils,
    I like the Bahtinov Greabber very much. Now I want to go to autofocus.
    I am using a system that understands and speaks the robofocus protocol. Interface is the ASCOM Robofocus driver 5.20 running with ASCOM platform 5.5 . Bahtinov grabber 10 Sep 2010 starts perfectly. I am able to move the focuser using the button right/left. The Robofocus interface is able to display the data traffic.
    After pushing the buttons I can see the commands to the hardware and also the confirming reply from the stepper motor control.
    I do not see a message from the Bahtinov Grabber to the stepper controller and therefor no changes in the position of the focuser. Do I have to initiate something else ? What am I doing wrong ?
    Please be so kind to let me know.
    kind regards
    Chris

  24. Huw Orwig says:

    Hi Nils,
    I’m using Bahtinov Grabber to focus my dslr on my f4 scope, focus is very critical, especially for blue channel, is there any way to make it selectable ; full colour, or colour components?

    All the best and thanks for a really great product.

    Huw

  25. Vlad says:

    Hello,
    I’m trying to use the autofocus in the Bahtinov grabber with my Accufocus and Shoestring FCSUB. Whenever I click the: Autofocus button, config, left or right, I get an error” Unhandled exception “, and the message is “Object variable or With block variable not set”, and I can either quit or continue without using the autofocus feature. Is there anyway around this?
    I can still use it (and do so all the time) manually

  26. John says:

    Hi Nils,
    Does this program work with Win 7 64bit ??
    Rgds
    John

  27. Carl Rainer says:

    Hi there
    I dont have any aoutofucus setup. But i do focus accurately using Nebulosity2 and a Bahtinov mask for photography. Can i use the grabber or do i need autofocus. Just dont have the money at the moment.

    Regards carl

  28. Carl Rainer says:

    Tried to load bahtinov grabber and get this error message.

    (Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error message and attempt to continue. If you click Quit, the application will close immediately.

    Could not load file or assembly.
    ‘Ascom.driver access, version=1.0.4.0, culture=neutral, public key token=565de7938946fba7′ or one of its depndencies. The system cannot find the file specified.)

    Q1.Do i have to also install Ascom drivers? I dont need them for my system, wont that cause conflict issues with other software?

    Q2. I focus with Nebulocity2 and a Bahtinov mask. I do not have the luxury of computer controlled auto focus yet. Can the grabber be used with my software and how.

    Q3. When i unzip the file it indicates that it isan evaluation trial version only

    Any suggestions appreciated as i would like to try the software

    Regards
    Carl Rainer

  29. Jeremy Royston says:

    Dear Niels,
    I just found your Bahtinov Grabber, and have no autofocus hardware. This is just what I wanted.
    Questions:
    Does it run under Windows 7?
    Does it work with manual focussing by reducing the focus error to 0.
    It looks like only ASCOM 6SP1 is available from Ascom for download. Does Bahtinov Grabber run with this rev. rather than the 5b which you name?
    Does one need to install ASCOM drivers for the camera used? I wanted to try you program with an SPC900NC webcam, and there was nothing in the picture area.
    Thanks for your help,

    Jerry

  30. admin says:

    Yes (Windows7)
    Yes, manual works fine.
    I have not tried, let me know what happens with 6sp1.
    No need for camera ASCOM, ASCOM is just for controlling the focusser.
    You have to select a capture area within the live view of your SPC900 using the mouse (point at the bahtinov cross, keep mouse button pressed and move until the yellow square fits the bahtinov pattern.

  31. Jeremy Royston says:

    Dear Niels,
    Thanks for the quick reply.
    Only the Ascom 6SP1 Platform is installed, the SPC900NC shows a picture in Giotto. The Bahtinov Grabber does not show a picture in its window, so I can’t choose an area for it to use.
    Questions:
    Are there installation instructions for the program? (Just unzipped and ran the program)
    How does one choose the camera from those available?
    Which focusser does one choose if there is no manual focusser
    Thanks for your help,
    Jerry
    PA Even if there is no focusser I see that Ascom must be installed, otherwise there’s an exception from the program

  32. Jeremy Royston says:

    Just tried it out with a file from maskulator, once I’d worked out how to drive the grabber it worked with Ascom 6SP1

  33. Rich Accomando says:

    I read a comment from Ove on Oct 15 that he encounted High CPU…100%.

    Is this an issue when running grabber?

    Rich

  34. admin says:

    That is just the Grabber working hard for you :-) .

  35. [...] exposures and overall look of the images after capture, and for later processing of the images), Bhatinov Grabber (this uses a cut-n-paste method to grab the star diffraction image created by a bhatinov mask from [...]

Leave a Reply