Sensoray 421 Manual de usuario Pagina 22

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 27
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 21
Page 20 Sensoray Model 421 Instruction Manual
Appendix D: Programming
Sample QuickBasic code segments are listed below to illustrate programming interface techniques for the 421
board. If you are coding your application in a language other than QuickBasic, you may find these listings
useful as a framework for writing your own drivers.
Although these listings are intended principally as programming examples, they may be used as is (or with
minor modification) as a basic set of interface drivers for the 421.
Feel free to modify, plagiarize and adapt these listings to suit your application requirements.
‘****************************************************************************
‘ SAMPLE QUICKBASIC INTERFACE CODE FOR THE 421
‘****************************************************************************
CONST BASEPORT = &H3A0 ‘421 I/O base address
‘ Write-only I/O ports:
CONST DAC0LSB = BASEPORT + 0 ‘DAC data registers
CONST RESETPORT = BASEPORT + 11 ‘board reset
CONST CHCTRL = BASEPORT + 12 ‘ADC channel reg / watchdog, DAC enables
CONST ADSTART = BASEPORT + 13 ‘start A/D
CONST CNTCTL = BASEPORT + 14 ‘encoder control port
CONST HITDOG = BASEPORT + 15 ‘watchdog refresh
‘ Read-only I/O ports:
CONST LDAC = BASEPORT + 0 ‘DAC update port
CONST STATUSPORT = BASEPORT + 11 ‘board status
CONST ADLSB = BASEPORT + 12 ‘A/D least-significant byte
CONST ADMSB = BASEPORT + 13 ‘A/D most-significant nibble
CONST CNTLSB = BASEPORT + 14 ‘encoder least-significant byte
CONST CNTMSB = BASEPORT + 15 ‘encoder most-significant byte
‘ Read/Write I/O ports:
CONST RELAY0 = BASEPORT + 8 ‘relay channel low bank access ports
CONST RELAY2 = BASEPORT + 16 ‘relay channel high bank access ports
‘ CHCTRL port bit constants:
CONST DOGBIT = 1 ‘watchdog enable/disable control bit
CONST DACBIT = 2 ‘DAC output enable/disable control bit
‘ Boolean constants:
CONST FALSE = 0
CONST TRUE = NOT FALSE
‘ Variables that are visible throughout this module:
DIM SHARED relay%(0 To 5) ‘image of relay channel output registers
DIM SHARED chctrlImage% ‘image of CHCTRL output port
Module Level Code
Vista de pagina 21
1 2 ... 17 18 19 20 21 22 23 24 25 26 27

Comentarios a estos manuales

Sin comentarios