unable to use Maxim's s autofocus from vb.net

Discussion in 'Scripting and Programming' started by robert tremblay, Sep 24, 2017.

  1. robert tremblay

    robert tremblay Cyanogen Customer

    Joined:
    Aug 26, 2015
    Messages:
    34
    Hi,
    i'm writing a small program in VB.net for those amateurs that are having a hard time using MAXIM DL.
    Most of them don't even know how to connect the ccd camera.
    So, i'm using maxim's scripting language.

    Whenever i want to use maxim's autofocus function from the maxim.application object instance, the function
    WON'T work if i previously tried to connect the camera from maxim's maxim.ccdcamera object instance.
    Say
    a)- use maxim.ccdcamera object to connect the camera
    b)- use maxim.application object to start an autofocus process.

    The problem: using maxim.ccdcamera to open the communication with the ccd camera is NO GOOD.
    the autofocus WON'T execute unless i personnally go into the ccd camera setup menu within maxim DL and press the CONNECT button.

    How can I solve this problem so that i can make use of autofocus function using the maxim.ccdcamera to establish the camera link?

    Clear skies,
    Robert
     
  2. robert tremblay

    robert tremblay Cyanogen Customer

    Joined:
    Aug 26, 2015
    Messages:
    34
    Hi all,
    I finally found the way autofocus works using maxim DL. For the sake of completeness, please find a short VB listing that explains how.
    Actually,
    i needed maxim.robofocus.lib library, not robofocusserver.
    autofocus is part of maxim.application and robofocus.lib are 2 different entities.
    They both need to be linked and closed. If you enable one, you previously need to have the other one closed and vice-versa.
    The short listing showing how:

    Dim i As Integer
    Dim pos0 As Integer
    Dim stat As Boolean
    Dim foc As RoboFocusLib.Focuser
    foc = New RoboFocusLib.Focuser
    Dim stf As MaxIm.CCDCamera
    stf = New MaxIm.CCDCamera
    Dim app As MaxIm.Application
    app = New maxim.application

    stf.LinkEnabled = True
    stf.DisableAutoShutdown = True

    'faire 500 steps out
    stat = False
    foc.Link = True
    Do While (stat = False)
    stat = foc.Link
    Loop
    i = foc.MaxStep 'get max tarvel
    i = foc.Position 'get current position
    foc.Move(i + 500)
    stat = True
    Do While stat = True
    stat = foc.IsMoving
    Loop
    pos0 = foc.Position
    foc.Link = False
    stat = True
    Do While (stat = True)
    stat = foc.Link
    Loop

    'autofocusing
    app.FocuserConnected = False
    app.FocuserConnected = True
    app.Autofocus(0.5)
    i = -1
    Do While (i < 0)
    i = app.AutofocusStatus
    Loop
    app.FocuserConnected = False

    'autofocus failed -> go back to start position
    stat = False
    foc.Link = True
    Do While (stat = False)
    stat = foc.Link
    Loop
    foc.Move(pos0)
    stat = True
    Do While stat = True
    stat = foc.IsMoving
    Loop
    foc.Link = False
    stat = True
    Do While (stat = True)
    stat = foc.Link
    Loop

    MsgBox("done")
    Robert
     

Share This Page