114 Pamux User’s Guide
The following example configures an analog output and, within a loop, continuously writes a changing
value to the output.
DIM HaveAccess%
‘ Non-zero if we have access
DIM DataPort%: DataPort% = MyAc28IoPort% + MyAnalogBoard%
DIM ControlPort%: ControlPort% = DataPort% + 1
DIM LowerByte%
DIM AnalogValue%
DIM AnalogPercent%
‘ Configure analog outputs
HaveAccess% = GetAccess%(DataPort%)
IF HaveAccess% THEN
CALL GetUpperAndLowerBytes(MyAnalogOutputMask%, UpperByte%, LowerByte%)
OUT ControlPort%, OutConfigRegister%
OUT DataPort%, LowerByte%
OUT ControlPort%, OutConfigRegister% + 1
OUT DataPort%, UpperByte%
ELSE
PRINT “No Access”
END IF
CALL ReleaseAccess(DataPort%)
‘ Done configuring analog outputs
DO WHILE 1
‘ Loop until ctrl-break
‘ Generate dummy data in AnalogValue% using QBasic’s SIN and TIMER
‘ Data fluctuates between 0 and &HFFF
AnalogValue% = &HFFF * (SIN(TIMER) + 1) / 2
AnalogPercent% = AnalogValue% / &HFFF * 100
PRINT AnalogValue%, AnalogPercent%; “%”
HaveAccess% = GetAccess%(DataPort%)
IF HaveAccess% THEN
CALL GetUpperAndLowerBytes(AnalogValue%, UpperByte%, LowerByte%)
OUT ControlPort%, MyAnalogOutputChannel% * 2
‘ Select a channel
OUT DataPort%, LowerByte%
OUT ControlPort%, MyAnalogOutputChannel% * 2 + 1
OUT DataPort%, UpperByte%
ELSE
PRINT “No Access”
END IF
CALL ReleaseAccess(DataPort%)
LOOP
I mportant: 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