EQContrl.DLL Developer's Guide Version 1.0


1.0 DRIVER and MOUNT INITALIZATION

The driver connects to the mount through the EQ_Init() function. It first opens the port at 9600 baud, 8 bits no parity, 1 stop bit. It then reads the mount's controller parameters and stores them within the DLL memory.

The main app must then call the EQ_InitMotors() function to initialize the motors and activate the mount's controller coil drivers. This will lock the motor at its current position. At this point you will hear the mount faint high pitch sound indicating that the motors are activated. You must also include within the EQ_InitMotors() function the initial values for the motor encoders. These values will depend on the Main application's preferred initial procesing values which could be any number within the 24BIT (3 bytes) range.


Sample Code

result = EQ_Init(COM1,9600,1000,1)  ; Initialize COM1 at 9600 baud, 1000 millisecond timout, 1 retrycount

result = EQ_InitMotors(0x800000,0x800000) ; Activate Coils with both motor encoders set at 0x800000
 

 

2.0 RA/DEC MOTOR GOTO

Each motor has its own independent controller that is specified by the motor_id parameter. That means each motor (RA and DEC) has to be treated independently. Before any slew process could take place, the Main App must first query if the motors are running or not through the function EQ_GetMotorStatus(). If its running, the main app must issue a EQ_MotorStop() function before it can initiate the GOTO microsteps function EQ_StartMoveMotor().

Sample Code (all motor values here are in microstep count not coordinate count)

Delta_RA = YourGetNew_RA_OffsetPositionAPP();   ' Compute for RA microstep count

Delta_DEC = YourGetNew_DEC_OffsetPositionAPP(); ' Compute for DEC microstep count

Dir_RA = YourGetDir_RA_APP()   ' Compute for Direction 0-forward, 1-reverse

Dir_DEC = YourGetDir_RA_APP()   ' Compute for Direction 0-forward, 1-reverse
 
 
Slowdown_RA = Delta_RA * 0.8   ' Specify which part of the microstepping series  the motor should slow down
Slowdown_DEC = Delta_DEC * 0.8    ' Specify which part of the microstepping series   the motor should slow down
        
    * WARNING!! - Setting the Slowdown_RA/DEC equal to the requested microstep count will cause the mount to slew and make an 'abrupt'  stop on the desired location. This may not be  good for the mount specially if its carrying a very heavy load. This value specifies when  during the slew process the motors will start to de-accelerate.
        

' Stop all motors

 result = EQ_MotorStop(0);   ' Stop RA Motor
 
' You may add your own error handling here
 
 result = EQ_MotorStop(1);   ' Stop DEC Motor

' You may add your own error handling here
 
' Wait until the motors have stopped moving
 
 do {
  
  result_ra = EQ_GetMotorStatus(0); ' Get State of Motors
  result_dec = EQ_GetMotorStatus(1); 
 
  ' You may add your own error / timeout handling here
 
 
    } while (((result_ra & 0x10) + (result_dec & 0x10)) != 0) ' Wait until both motors are not rotating
 
 ' Initiate the GOTO (Motor Slew) command
 
 EQ_StartMoveMotor(0, 0, Dir_RA,  Delta_RA, Slowdown_RA);
 EQ_StartMoveMotor(0, 0, Dir_DEC,  Delta_DEC, Slowdown_DEC);
 
 'Both RA and DEC motors should be moving at this point
 
 ' Wait until the motors have stopped moving
 
 do {
  
  result_ra = EQ_GetMotorStatus(0); ' Get State of Motors
  result_dec = EQ_GetMotorStatus(1); 
 
  ' You may add your own error / timeout handling here
 
 
     } while (((result_ra & 0x10) + (result_dec & 0x10)) != 0) ' Wait until both motors are not rotating
    

   
3.0 MOTOR SLEWING / USER INITIATED BUTTON SLEW


Main app should initate a EQ_MotorStop() function, query the status of the motors, and then initate the slew command.
 
Sample Code (for RA Slewing on the positive(+) direction)

 result = EQ_MotorStop(0);   ' Stop RA Motor
 
  ' You may add your own error / timeout handling here
  
 do {
  result_ra = EQ_GetMotorStatus(0); ' Get State of RA Motor
  ' You may add your own error / timeout handling here

    } while ((result_ra & 0x10) != 0) ' Wait until RA motor not rotating
   
 result = EQ_Slew(0,0,0,399);   ' Slew RA Motor at the rate of Sidreal * 399
 
  ' App must then wait for the user to release the button
  
 result = EQ_MotorStop(0);   ' Stop RA Motor

   
  
4.0 TRACKING

Main app should initate a EQ_MotorStop() function, query the status of the motors, and then initate the track command.

Sample Code

 result = EQ_MotorStop(0);   ' Stop RA Motor
 
  ' You may add your own error / timeout handling here
  
 do {
  result_ra = EQ_GetMotorStatus(0); ' Get State of RA Motor
  ' You may add your own error / timeout handling here

    } while ((result_ra & 0x10) != 0) ' Wait until RA motor not rotating
   
 result = EQ_StartRATrack(0, 0, 0 , 0);  ' Slew RA Motor at the Sidreal rate
 
 ' Below is the function to stop tracking
  
 EQ_MotorStop(0);    ' Stop RA Motor
   

 
 
5.0 GUIDING

Main app must first initate the track command (as specified above) then initate the corresponding guide adjustments;
 
Sample Code (When main app initates a 50% of Sidreal RA+ Guide)

 result = EQ_SendGuideRate(0, 0, 5, 0, 0, 0); ' Set RA speed at 50% more of the Sidreal
 
 sleep(pulseduration);
 
 result = EQ_SendGuideRate(0, 0, 0, 0, 0, 0); ' Set RA speed back to Sidreal
 

Sample Code (When main app initates a 50% of Sidereal DEC- Guide)

 result = EQ_MotorStop(1);   ' Stop DEC Motor
 
  ' You may add your own error / timeout handling here
  
 do {
  result_dec = EQ_GetMotorStatus(1); ' Get State of DEC Motor
  ' You may add your own error / timeout handling here

    } while ((result_dec & 0x10) != 0) ' Wait until RA motor not rotating

 result = EQ_SendGuideRate(1, 0, 5, 1, 0, 0); ' Start DEC motor at  speed at 50% more of the Sidreal
       ' and at Negative(-) direction
 
 sleep(pulseduration);
 
 result = EQ_MotorStop(1);   ' Stop DEC Motor


6.0 GUIDING RATES SETTINGS ON THE AUTOGUIDER PORT

 To set the Autoguider Port's guide rate, Main app must send a separate command on the RA and DEC controller;
 
Sample Code;

 result = EQ_SetAutoguiderPortRate(0,2);  ' Set RA GuidePort at .75
 result = EQ_SetAutoguiderPortRate(1,2);  ' Set DEC GuidePort at .75



7.0 SYNC

 The SYNC function basically is a software adjusment function based on the current position of the RA and DEC stepper motor encoders
 
 
Sample Code;

 ' At this point, MOUNT and SCOPE must be pointed at the desired-to-be-synced sky object
   and should be tracking

 Current_RA = EQ_GetMotorValues(0);  ' Read Current RA Encoder value
 Current_DEC = EQ_GetMotorValues(1);  ' Read Current DEC Encoder value
 
 Current_RA_Coordinate = Your_RA_Encoder_to_RA_coordinate_converter_function(Current_RA);
 Current_DEC_Coordinate = Your_DEC_Encoder_to_DEC_coordinate_converter_function(Current_DEC);
 
 
 YourProcess_RADEC_Sync_Correction_app(Current_RA_Coordinate, Current_DEC_Coordinate, Sky_Object_RA_Coordinate, Sky_Object_DEC_Coordinate);
 
 'At this point each time you initate the succeding GOTO command, the app should return the correct
 Delta_RA and Delta_DEC microstep counts.

 

8.0 Other Commands

      8.1 Get Mount Version
 
 mount_version = EQ_GetMountVersion();
 
 ' Version number is XX.YY where XX is the 8bit value at bits 8 to 15 and YY is an 8 bit value at bits 0 to 7
 
 

    8.2 Get Mount Status
 
 mountstats = EQ_GetMountStatus();
  
  'Returns 1 if Connected, 0 - Not Connected
  

    8.3 Get RA/DEC Motor Total microstep count for a 360 degree revolution
 
   ra_total_steps = EQ_GetTotal360microstep(0);
  dec_total_steps = EQ_GetTotal360microstep(1);
 
 ' These values are usually needed for GOTO coordinate computations
  

EQContrl.DLL FUNCTIONS AND PARAMETERS DESCRIPTION


 Function name    : EQ_Init()
 Description      : Connect to the EQ Controller via Serial and initialize the stepper board
 Return type      : DOUBLE
                      000 - Success
                      001 - COM Port Not available
                      002 - COM Port already Open
                      003 - COM Timeout Error
                      005 - Mount Initialized on using non-standard parameters
                      010 - Cannot execute command at the current stepper controller state
                      999 - Invalid parameter
 Argument         : STRING COMPORT Name
 Argument         : DOUBLE baud - Baud Rate
 Argument         : DOUBLE timeout - COMPORT Timeout (1 - 50000)
 Argument         : DOUBLE retry - COMPORT Retry (0 - 100)

EQ_Init (COMPORT As String, baud As Long, timeout As Long, retry As Long) As Long
DWORD __stdcall EQ_Init(char *comportname,DWORD baud,DWORD timeout, DWORD retry)


 Function name    : EQ_End()
 Description      : Close the COM Port and end EQ Connection
 Return type      : DOUBLE
                     00 - Success
                     01 - COM Port Not Openavailable

EQ_End () As Long
DWORD __stdcall EQ_End()


 Function name    : EQ_InitMotors()
 Description      : Initialize RA/DEC Motors and activate Motor Driver Coils
 Return type      : DOUBLE
                     000 - Success
                     001 - COM PORT Not available
                     003 - COM Timeout Error
                     006 - RA Motor still running
                     007 - DEC Motor still running
                     008 - Error Initializing RA Motor
                     009 - Error Initilizing DEC Motor
                     010 - Cannot execute command at the current stepper controller state

 Argument         : DOUBLE RA_val  Initial ra microstep counter value
 Argument    : DOUBLE DEC_val     Initial dec microstep counter value

EQ_InitMotors (RA as Long, DEC As Long) As Long
DWORD __stdcall EQ_InitMotors(DWORD RA_val, DWORD DEC_val)


 Function name    : EQ_GetMotorValues()
 Description      : Get RA/DEC Motor microstep counts
 Return type      : Double - Stepper Counter Values
                     0 - 16777215  Valid Count Values
                     0x1000000 - Mount Not available
                     0x1000005 - COM TIMEOUT
                     0x10000FF - Illegal Mount reply
                     0x3000000 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor

EQ_GetMotorValues (value As Long) As Long
DWORD __stdcall EQ_GetMotorValues(DWORD motor_id)                    


 Function name    : EQ_GetMotorStatus()
 Description      : Get RA/DEC Stepper Motor Status
 Return type      : DOUBLE
                     128 - Motor not rotating, Teeth at front contact
                     144 - Motor rotating, Teeth at front contact
                     160 - Motor not rotating, Teeth at rear contact
                     176 - Motor rotating, Teeth at rear contact
                     200 - Motor not initialized
                     001 - COM Port Not available
                     003 - COM Timeout Error
                     999 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor

EQ_GetMotorStatus (value As Long) As Long
DWORD __stdcall EQ_GetMotorStatus(DWORD motor_id)

 Function name    : EQ_SeTMotorValues()
 Description      : Sets RA/DEC Motor microstep counters (pseudo encoder position)
 Return type      : DOUBLE - Stepper Counter Values
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     010 - Cannot execute command at the current stepper controller state
                     011 - Motor not initialized
                     999 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor
 Argument         : DOUBLE motor_val
                     0 - 16777215  Valid Count Values

EQ_SetMotorValues (motor_id As Long, motor_val As Long) As Long
DWORD __stdcall EQ_SetMotorValues(DWORD motor_id, DWORD motor_val)


 Function name    : EQ_StartMoveMotor
 Description      : Slew RA/DEC Motor based on provided microstep counts
 Return type      : DOUBLE
                     000 - Success
                     001 - COM PORT Not available
                     003 - COM Timeout Error
                     004 - Motor still busy, aborted
                     010 - Cannot execute command at the current stepper controller state
                     011 - Motor not initialized
                     999 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor
 Argument         : DOUBLE hemisphere
                     00 - North
                     01 - South
 Argument         : DOUBLE direction
                     00 - Forward(+)
                     01 - Reverse(-)
 Argument         : DOUBLE steps count
 Argument         : DOUBLE motor de-acceleration  point (set between 50% t0 90% of total steps)

EQ_StartMoveMotor (motor_id As Long, hemisphere As Long, direction As Long, steps As Long, stepslowdown As Long) As Long
DWORD __stdcall EQ_StartMoveMotor(DWORD motor_id, DWORD hemisphere, DWORD direction,  DWORD steps, DWORD stepslowdown)

              

 Function name    : EQ_Slew()
 Description      : Slew RA/DEC Motor based on given rate
 Return type      : DOUBLE
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     004 - Motor still busy
                     010 - Cannot execute command at the current stepper controller state
                     011 - Motor not initialized
                     999 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor
 Argument         : INTEGER direction
                    00 - Forward(+)
                    01 - Reverse(-)
 Argument         : INTEGER rate
                         1-800 of Sidreal Rate

EQ_Slew (motor_id As Long, hemisphere As Long, direction As Long, rate As Long) As Long
DWORD __stdcall EQ_Slew(DWORD motor_id, DWORD hemisphere, DWORD direction, DWORD rate)

 Function name    : EQ_StartRATrack()
 Description      : Track or rotate RA/DEC Stepper Motors at the specified rate
 Return type      : DOUBLE
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     010 - Cannot execute command at the current stepper controller state
                     011 - Motor not initialized
                     999 - Invalid Parameter
 Argument         : DOUBLE trackrate
                     00 - Sidreal
                     01 - Lunar
                     02 - Solar
 Argument         : DOUBLE hemisphere
                     00 - North
                     01 - South
 Argument         : DOUBLE direction
                     00 - Forward(+)
                     01 - Reverse(-)

EQ_StartRATrack (trackrate As Long, hemisphere As Long, direction As Long) As Long
DWORD __stdcall EQ_StartRATrack(DWORD trackrate, DWORD hemisphere, DWORD direction)


 Function name    : EQ_SendGuideRate()
 Description      : Adjust the RA/DEC rotation trackrate based on a given speed adjustment rate
 Return type      : int
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     004 - Motor still busy
                     010 - Cannot execute command at the current stepper controller state
                     011 - Motor not initialized
                     999 - Invalid Parameter

 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor
 Argument         : DOUBLE trackrate
                     00 - Sidreal
                     01 - Lunar
                     02 - Solar
 Argument         : DOUBLE guiderate
                     00 - No Change
                     01 - 10%
                     02 - 20%
                     03 - 30%
                     04 - 40%
                     05 - 50%
                     06 - 60%
                     07 - 70%
                     08 - 80%
                     09 - 90%
 Argument         : DOUBLE guidedir
                     00 - Positive
                     01 - Negative
 Argument         : DOUBLE hemisphere (used for DEC Motor control)
                     00 - North
                     01 - South
 Argument         : DOUBLE direction (used for DEC Motor control)
                     00 - Forward(+)
                     01 - Reverse(-)

EQ_SendGuideRate (motor_id As Long, trackrate As Long, guiderate As Long, guidedir As Long, hemisphere As Long, direction As Long) As Long
DWORD __stdcall EQ_SendGuideRate(DWORD motor_id, DWORD trackrate, DWORD guiderate, DWORD guidedir, DWORD hemisphere, DWORD direction)


 Function name    : EQ_SendCustomTrackRate()
 Description      : Adjust the RA/DEC rotation trackrate based on a given speed adjustment offset
 Return type      : DOUBLE
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     004 - Motor still busy
                     010 - Cannot Execute command at the current state
                     011 - Motor not initialized
                     999 - Invalid Parameter

 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor
 Argument         : DOUBLE trackrate
                     00 - Sidreal
                     01 - Lunar
                     02 - Solar
 Argument         : DOUBLE trackoffset
                     0 - 300
 Argument         : DOUBLE trackdir
                     00 - Positive
                     01 - Negative
 Argument         : DOUBLE hemisphere (used for DEC Motor)
                     00 - North
                     01 - South
 Argument         : DOUBLE direction (used for DEC Motor)
                     00 - Forward(+)
                     01 - Reverse(-)

EQ_SendCustomTrackRate (motor_id As Long, trackrate As Long, trackoffset As Long, trackdir As Long, hemisphere As Long, direction As Long) As Long
DWORD __stdcall EQ_SendCustomTrackRate(DWORD motor_id, DWORD trackrate, DWORD trackoffset, DWORD trackdir, DWORD hemisphere, DWORD direction)

 Function name    : EQ_MotorStop()
 Description      : Stop RA/DEC Motor
 Return type      : DOUBLE
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     010 - Cannot execute command at the current stepper controller state
                     011 - Motor not initialized
                     999 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor

EQ_MotorStop (value As Long) As Long
DWORD __stdcall EQ_MotorStop(DWORD motor_id)


 Function name    : EQ_GetTotal360microstep()
 Description      : Get RA/DEC Motor Total 360 degree microstep counts
 Return type      : Double - Stepper Counter Values
                     0 - 16777215  Valid Count Values
                     0x1000000 - Mount Not available
                     0x3000000 - Invalid Parameter
 Argument         : DOUBLE motor_id
                     00 - RA Motor
                     01 - DEC Motor

EQ_GetTotal360microstep (value As Long) As Long
DWORD __stdcall EQ_GetTotal360microstep(DWORD motor_id)

 Function name    : EQ_GetMountVersion()
 Description      : Get Mounts Firmware version
 Return type      : Double - Mounts Firmware Version

                     0x1000000 - Mount Not available

EQ_GetMountVersion () As Long
DWORD __stdcall EQ_GetMountVersion()

 Function name    : EQ_GetMountStatus()
 Description      : Get Mounts Firmware version
 Return type      : Double - Mount Status
                       0 - Not Connected
                       1 - Connected

EQ_GetMountStatus () As Long
DWORD __stdcall EQ_GetMountStatus()

 Function name    : EQ_SetAutoguiderPortRate()
 Description      : Sets RA/DEC AUTOGUIDEPORT rate
 Return type      : DOUBLE - Stepper Counter Values
                     000 - Success
                     001 - Comport Not available
                     003 - COM Timeout Error
                     999 - Invalid Parameter
 Argument         : motor_id
                       00 - RA Motor
                       01 - DEC Motor
 Argument         : DOUBLE guideportrate
                       00 - 0.25x
                       01 - 0.50x
                       02 - 0.75x
                       03 - 1.00x

EQ_SetAutoguiderPortRate (motor_id As Long, guideportrate As Long) As Long
DWORD __stdcall EQ_SetAutoguiderPortRate(DWORD motor_id, DWORD portguiderate)

 

DISCLAIMER:

You can use the information on this site COMPLETELY AT YOUR OWN RISK. The modification steps and other information on this site is provided to you "AS IS" and WITHOUT WARRANTY OF ANY KIND, express, statutory, implied or otherwise, including without limitation any warranty of merchantability or fitness for any particular or intended purpose. In no event the author will  be liable for any direct, indirect, punitive, special, incidental or consequential damages or loss of any   kind whether or not the author  has been advised of the possibility of such loss.

 WARNING:

Circuit modifications implemented on your setup could invalidate any warranty that you may have with your product. Use this information at your own risk. The modifications involve direct access to the stepper motor controls of your mount. Any "mis-control" or "mis-command"  / "invalid parameter" or "garbage" data sent to the mount could accidentally activate the stepper motors and allow it to rotate "freely" damaging any equipment connected to your mount. It is also possible that any garbage or invalid data sent to the mount could cause its firmware to generate mis-steps pulse sequences to the motors causing it to overheat. Make sure that you perform the modifications and testing while there is no physical "load" or dangling wires on your mount. Be sure to disconnect the power once this event happens or if you notice any unusual sound coming from the motor assembly.