Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Here is a sample flow diagram of how to can check if motion has stopped on a particular axis. The example is for an AT product under Visual Basic 4.0 environment.

Using the "Fast Status" capability of the AT6400 you may check a bit in a register. This bit will tell you if your motor is moving or not. A good idea would be to create a subroutine that waits for your motor to stop moving. Check Chapter 2 of the "6000 Series Programer's guide" for more details.

A sample is written below. The steps are as follows:

Step 1
Make a function that returns a TRUE if the motor is currently moving and a FALSE if the motor is not moving. Call the function IsMoving(....)

Arguments: Axis
This argument specifies which axis to check for motion.

Return Values: Boolean
TRUE if specified Axis is moving.
FALSE otherwise.

Step 2
Make a subroutine that waits for motion to stop. Call the subroutine WaitForMove(.....)

Arguments:Axis
Same as above.

Sample Program follows:

Public Function IsMoving(ByVal Axis As Integer) As Boolean

Dim status_high As Integer
Dim status_low As Integer
Dim status As Long

Dim Temp As Integer
Select Case Axis

Case 1
Temp = request_status(Address)
Call set_pointer(Address, AXIS1_STATUS)
Call read_status(Address, status_high, status_low, status)
IsMoving = status And 1 'Mask out all bit so that only bit one remains

Case 2
Call set_pointer(Address, AXIS2_STATUS)
Call read_status(Address, status_high, status_low, status)
IsMoving = status And 1 'Mask out all bit so that only bit one remains

Case 3
Call set_pointer(Address, AXIS3_STATUS)
Call read_status(Address, status_high, status_low, status)
IsMoving = status And 1 'Mask out all bit so that only bit one remains

Case 4
Call set_pointer(Address, AXIS4_STATUS)
Call read_status(Address, status_high, status_low, status)
IsMoving = status And 1 'Mask out all bit so that only bit one remains

Case Else
IsMoving = False

End Select

End Function

'This subroutine waits for axis to stop moving

Public Sub WaitForStop(ByVal Axis As Integer)

Do Until IsMoving(Axis) = False
Temp = DoEvents()
'have this loop wait

Loop
End Sub

Now if you start a motion on axis 1 just call the WaitForStop(1) funtion and it will wait until all motion has stopped.

Example:

Call MakeMove(1) 'make axis 1 move
Call WaitForStop(1) 'wait until axis one has stopped moving.

  • No labels