Chapter 2. Communication
47
Retrieving information from the fast status area using QuickBASIC: The
following is a source code example written in QuickBASIC. This source code example is also
provided on the DOS Support Disk in subdirectory SAMPLES, file QB45FAST.BAS.
DEFINT A-Z
DECLARE SUB requeststatus()
DECLARE SUB setpointer(statusoffset)
DECLARE SUB readstatus()
DECLARE SUB createposition()
'--- AT6nnn default address.
CONST BASEP = &H0300
CONST CSUPDATED = &H08 'AT6nnn card status update
CONST REQSTATUS = &H48 'tells AT6nnn that you want a status update
CONST AXIS1CMD = &H00 'Axis 1 commanded position in fast status area
'--- AT6nnn address offsets.
CONST FASTSTATUS = 2 'offset to fast status area
CONST STATUS = 4 'offset to set/clear status
'--- Globals
COMMON SHARED Address, Status4, Status3, Status2, Status1
COMMON SHARED Position#
'************************************************************************
' MAIN PROGRAM
'************************************************************************
address = BASEP
requeststatus
setpointer(AXIS1CMD)
readstatus
createposition
print "Axis 1 Commanded Position = ";position#
END
SUB requeststatus STATIC
'************************************************************************
'SUBPROGRAM : requeststatus
'************************************************************************
OUT address+STATUS, REQSTATUS
while (INP(address+STATUS) AND CSUPDATED) = 0
wend
END SUB
SUB setpointer(statusoffset) STATIC
'************************************************************************
'SUBPROGRAM : setpointer
'************************************************************************
out address+FASTSTATUS, statusoffset
END SUB
SUB readstatus STATIC
'************************************************************************
' SUBPROGRAM : readstatus
'************************************************************************
status4 = INP(address+FASTSTATUS)
status3 = INP(address+FASTSTATUS+1)
status2 = INP(address+FASTSTATUS)
status1 = INP(address+FASTSTATUS+1)
END SUB
Continued on next page ...
Comments to this Manuals