Link here

DA 24/7 C Demo 2

C Demonstration code for the DA 24/7 Data Acquisition Wildcard: continuous data sampling

The 24/7 Data Acquisition Wildcard™ is a complete data acquisition system and analog front end for scientific instruments. It provides 24-bit, high-resolution conversion, good thermal stability, and internal digital filtering for noise rejection. It is ideal for low frequency high resolution analog measurement and data logging. The analog-to-digital converter (ADC) accepts low level signals directly from transducers, amplifies and conditions them, and converts them to a digital code with 24 bits of resolution with no missing codes performance.

The following C language program shows how to invoke the 24/7 ADC to do continuous sampling and store the resulting data to memory.


DA 24/7 C Demo 2

// ****************************************************************************************
// FILE NAME: wda247demo2.c
// copyright 2009 Mosaic Industries, Inc. All rights reserved.
// ---------------------------------------------------------------------
// DATE: 4/20/2009
// VERSION: 1.0, for QED/Q-Line (HC-11) and PDQ line (HCS-12) controllers
// ---------------------------------------------------------------------
// This is the demonstration code for the 24/7 Data Acquisition Wildcard.
// Please see its User Guide for more details.
//
// This second sample routine demonstrates how to use AD24_Multiple.
// This routine takes 10 samples from a single channel at 10 hz and
// stores the samples to the pad area.  Returns -1 if successful, 0
// if an invalid Wildcard number was passed to Init_AD24, returns 1-9
// if an invalid calibration coefficient was passed to
// Start_Conversion.
//
// MAKE SURE THAT THE DA247_MODULE_NUM CONSTANT MATCHES YOUR HARDWARE JUMPER SETTINGS!!
//
// ---------------------------------------------------------------------
// Disclaimer: THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
// ANY WARRANTIES OR REPRESENTATIONS EXPRESS OR IMPLIED,
// INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES
// OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//
// *********************************************************************
 
 
#include <mosaic/allqed.h>
//__GNUC__ is true for Mosaic PDQ IDE
 
#ifdef __GNUC__
#include <wda247.h>
#else
#include "library.h"
#include "library.c"
#endif
 
// NOTE: YOU MUST MAKE SURE THAT DA247_MODULE_NUM CONSTANT MATCHES YOUR HARDWARE JUMPERS!!
#define DA247_MODULE_NUM 0 // double check your hardware jumper settings!!!
 
#ifdef __GNUC__
#define PAD_16BIT_ADDR 0x1a08
#else
#define PAD_16BIT_ADDR 0x8b24
#endif
 
EXTENDED_ADDR pad_buffer;        // 88 byte buffer in common RAM
 
int Sample_Routine2 ( void )
{
  int flag = 0;
  pad_buffer.sixteen_bit.page16 = (void*) 0x00;
  pad_buffer.sixteen_bit.addr16 = (void*) PAD_16BIT_ADDR;
  if( Init_AD24( DA247_MODULE_NUM ) )       // 24/7 Data Acquisition Wildcard
                                   // is first Wildcard on the stack
  {
    Use_Onboard_Ref();             // Use on-board reference
    // Start_Conversion must be called before getting a sample!
    flag = Start_Conversion(  SELF_CAL,
                              1920,       // 10 Hz -> 19200/10=1920
                              GAIN_1,
                              BIPOLAR,
                              WORD_24BIT, // 24 bit resolution
                              BO_OFF,
                              CH_0_1 );
    if( flag == -1 )          // Start_Conversion was successful
    {
      // Get 10 samples, store to RAM
      // The values raw conversion values can be shown by typing:
      // pad 40 dump
      // The values can be read from memory by using: FetchLong()
      flag = AD24_Multiple( 10, pad_buffer.addr32 );
    }
  }
  return(flag);
}
 
void print_routine( void )
{
    int i;
    long val;
    printf("\n");
    for( i = 0; i < 10; i++ )
    {
      val = FetchLong(pad_buffer.addr32 + (0x4*i) );
      printf("%lx\n", val);
    }
}
 
int main( void )
{ Sample_Routine2();
  print_routine();
  return 0;
}



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 3
DA 24/7 Forth Demo 1
DA 24/7 Forth Demo 2
DA 24/7 Forth Demo 3

 
This page is about: C Language Program for 24-bit High Resolution A/D Converter – C language device driver for a 24-bit high resolution analog to digital converter used as an analog front-end for instrumentation and automation.
 
 
Navigation