Link here

DA 24/7 C Demo 1

C 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 C language demonstration program provides examples of how to invoke the 24/7 ADC to acquire a bipolar data sample.


DA 24/7 C Demo 1

// ****************************************************************************************
// FILE NAME: wda247demo1.c
// copyright 2009 Mosaic Industries, Inc. All rights reserved.
// ---------------------------------------------------------------------
// DATE: 4/16/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 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.  The Sample is
// taken between pins 22 and 24.  This is channel CH_0_1.  If an
// invalid option is specified or if a timeout occurs, an error flag
// is returned.  Error flags are:
//  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
//
// 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!!!
 
int Sample_Routine ( void )
{
  int flag = 0;
  long sample;
  float result;
  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 )
    {
      sample = AD24_Sample();              // Get sample
      if( sample != TIMEOUT_ERROR )        // If no timeout occurred
      {
 
        // Shift by 8 to remove timeout flag & convert to 24 bits
        sample = sample >> 8;
 
        // Logical AND to clear high bits
        sample = sample & 0x00ffffff;
 
        // Subtract 8388608 (2^23) to remove the bipolar offset
        sample = sample - 8388608;
 
        // Multiply by (5.00+/-0.01)/(2^24) to convert to volts
        // 5.00+/-0.01 is obtained by multiplying the reference
        // voltage by 2; i.e. (2.500+/-0.005)*2
        // Divide result by the gain for gains greater than 1
        // for example: for a gain of 8 divide result by 8
        // DO NOT DIVIDE BY GAIN_8! GAIN_8 != 8!
        result = sample * (0.0000002980);
 
        printf("\nResult = %2.4f \n",result);
      }
    }
  }
  return(flag);
}
 
int main( void )
{ Sample_Routine();
  return 0;
}



See also →
24/7 Data Acquisition Wildcard Users Guide
24/7 Data Acquisition Wildcard Glossary
DA 24/7 C Demo 2
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 Device Driver for 24-bit Resolution A-to-D Converter – This C language demo program performs continuous bipolar sampling from a 24-bit high resolution analog to digital converter and stores the resulting data to memory.
 
 
Navigation