EasyManua.ls Logo

Strasbaugh nTellect 7AF - Common Subroutines

Default Icon
2493 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
120 Pamux User’s Guide
COMMON SUBROUTINES
MyKillTime
This function implements a pause when running QBasic under DOS. It uses the BIOS timer to detect a
“timer tick.” Environments other than DOS, such as Windows or real-time kernels, typically offer better
timing capability with better resolution.
SUB MyKillTime
CONST BiosTimerLocation% = &H46C
DIM TickCounter%: TickCounter% = 3
DIM OldTick%: OldTick% = PEEK(BiosTimerLocation%)
DIM NewTick%
DEF SEG = 0
DO WHILE TickCounter%
NewTick% = PEEK(BiosTimerLocation%)
IF OldTick% <> NewTick% THEN
TickCounter% = TickCounter% - 1
OldTick% = NewTick%
END IF
LOOP
EXIT SUB
END SUB
CombineUpperAndLowerBytes
This function takes two bytes and combines them into a 16-bit integer. QBasic requires an “if” condition
to prevent an overflow exception. This is used to read and combine two eight-bit port values into one
16-bit integer such as when reading analog inputs.
FUNCTION CombineUpperAndLowerBytes% (UpperByte%, LowerByte%)
DIM Temp%
IF UpperByte% AND &H80 THEN
‘ Prevent overflow if negative
Temp% = ((UpperByte% AND &H7F) * &H100) OR &H8000
ELSE
Temp% = UpperByte% * &H100
‘ Shift left 8 bits
END IF
CombineUpperAndLowerBytes% = Temp% OR LowerByte%
END FUNCTION
GetUpperAndLowerBytes
This function takes a 16-bit integer and breaks it into two separate bytes. This is used to write analog
outputs, write 16 digital outputs (two banks), write watchdog values, and write watchdog times.
SUB GetUpperAndLowerBytes (Combined%, Upper%, Lower%)
Upper% = Combined% \ &H100
‘ Shift right 8 bits
Lower% = Combined% AND &HFF
END SUB
PROGRAMING WITHOUT THE PAMUX DRIVER

Table of Contents

Related product manuals