EasyManua.ls Logo

Strasbaugh nTellect 7AF - Reading an Analog Channel

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...
112 Pamux User’s Guide
Releasing Access
This step is crucial. Once you are finished reading from or writing to the Pamux analog brain board,
you must release access back to the brain board. If you do not release access, inputs and outputs
will never be updated!
To release access, write a hex 82 to the control register, then write anything to the data register. The
function below illustrates how to do this in QBasic. The ReleaseAccess function releases access by
simply writing any value to the semaphore register.
SUB ReleaseAccess (DataPortArg%)
CONST SemaphoreRegister% = &H82
CONST Anything% = &HFF
DIM ControlPort%: ControlPort% = DataPortArg% + 1
‘ 2nd register on B6
OUT ControlPort%, SemaphoreRegister%
OUT DataPortArg%, Anything%
END SUB
READING AN ANALOG CHANNEL
Remember that before reading an analog channel, you must first gain access to the internal registers, as
described previously.
After gaining access, write the position to be read to the control register, then read the contents of the
data register to get the least significant byte. Increment the contents of the control register, then read
the data register to get the most significant byte. Remember, I/O instructions are done one byte at a
time, and an analog value is a 12-bit value (0–4095).
The following example continuously reads an analog input and prints the value to the screen.
DIM HaveAccess%
‘ Non-zero if we have access
DIM DataPort%: DataPort% = MyAc28IoPort% + MyAnalogBoard%
DIM ControlPort%: ControlPort% = DataPort% + 1
DIM LowerByte%
DIM UpperByte%
DIM AnalogValue%
DO WHILE 1
‘ Loop until ctrl-break
HaveAccess% = GetAccess%(DataPort%)
IF HaveAccess% THEN
OUT ControlPort%, MyAnalogInputChannel% * 2
‘ Select a channel
LowerByte% = INP(DataPort%)
‘ Read lower byte
OUT ControlPort%, MyAnalogInputChannel% * 2 + 1
UpperByte% = INP(DataPort%)
‘ Read upper byte
AnalogValue% = CombineUpperAndLowerBytes(UpperByte%, LowerByte%)
PRINT AnalogValue%
‘ Print result
ELSE
PRINT “No Access”
END IF
CALL ReleaseAccess(DataPort%)
LOOP
IMPORTANT: Don’t forget to release access to the brain board if this is the last operation you will be doing on
this pass.
PROGRAMING WITHOUT THE PAMUX DRIVER

Table of Contents

Related product manuals