Link here

DA 24/7 Forth Demo 1

Forth demonstration code for the DA 24/7 Data Acquisition Wildcard: bipolar data sampling

The 24/7 Data Acquisition Wildcard™ is a complete analog front end, offering exceptional 24-bit resolution, excellent stability, and remarkable noise rejection for instrumentation applications. Ideal for high resolution, low frequency measurements and data logging, this analog-to-digital converter (ADC) accepts low level signals directly from transducers, amplifies and conditions them, and converts them with 24 bits of resolution with no missing codes performance.

This Forth language demonstration program provides examples of how to invoke the 24/7 ADC to acquire a bipolar data sample.


DA 24/7 Forth Demo 1

\ ---------------------------------------------------------------------
\                          Example 1
\ ---------------------------------------------------------------------
 
HEX
FF CONSTANT LSB_MASK   \ Constant to isolate 8 least
                       \ significant bits of an integer
DECIMAL
 
\ This first sample routine demonstrates how to use Init_AD24,
\ Use_Onboard_Ref, Start_Conversion, and AD24_Sample.  This routine
\ takes 1 differential 24-bit bipolar sample at 10 Hz with a gain of 1
\ and the burnout options turned off and prints it out.  If an invalid
\ option is specified or if a timeout occurs, an error flag is
\ returned.  Error flags are: INIT_ERROR = 0,
\         INVALID_GAIN = 1, INVALID_FREQ = 2, INVALID_CAL = 3,
\              INVALID_CHANNEL = 4, INVALID_FSYNC = 5, INVALID_BO = 6,
\           INVALID_SIZE = 7, INVALID_POLARITY = 8, TIMEOUT_ERROR = 9
 
: Sample_Routine ( -- flag | flag = success )
FALSE locals{ &flag }
  MODULE0 Init_AD24                  \ 24/7 Data Acquisition Wildcard is
                                     \ the first Wildcard on the stack
  IF
    Use_Onboard_Ref                  \ Use on-board reference
    SELF_CAL
    1920                             \ 10 Hz -> 19200 / 10 = 1920
    GAIN_1
    BIPOLAR
    WORD_24BIT                 \ 24 bit resolution
    BO_OFF
    CH_0_1
    Start_Conversion                 \ This must be called before
                             \ getting a sample
    TO &flag
    &flag -1 =
    IF
      AD24_Sample                    \ Get sample
      OVER LSB_MASK AND              \ Just look at 8 LSB of the sample
      TIMEOUT_ERROR = NOT            \ Does it equal to timeout flag?
      IF                             \ If no timeout occurred,
        -8 DSCALE                    \ Shift sample to get 24 bits
        0x00FF AND                   \ DSCALE sign-extended, remove the
                                     \ excess sign bits
                                     \ Convert to volts
        DIN 8388608 d- DFLOT         \ Subtract off 0x800000 because
                                     \ of the bipolar conversion
        2.9802E-7 F*                 \ Multiply by (5.00+/-0.01)/(2^24)
        \ 5.00+/-0.01 is obtained by multiplying the reference
        \ voltage by 2; i.e. (2.500+/-0.005)*2
        \ 1.0 f/                     \ Divide by the gain if necessary
                                     \ DO NOT DIVIDE BY GAIN_1!
        \ GAIN_1 != 1, GAIN_2 != 2, ...
        f.                           \ Print out result
        TRUE TO &flag                \ Return true
      ENDIF
    ENDIF
  ENDIF
  &flag
;



See also →
24/7 Data Acquisition Wildcard Users Guide
24/7 Data Acquisition Wildcard Glossary
DA 24/7 C Demo 1
DA 24/7 C Demo 2
DA 24/7 C Demo 3
DA 24/7 Forth Demo 2
DA 24/7 Forth Demo 3

 
This page is about: Forth Language Demo Program, Code Examples, Acquire Bipolar Data Samples – This Forth language demonstration program provides examples of how to invoke the 24/7 ADC to acquire a bipolar data sample.
 
 
Navigation