DscADCodeToVoltage

Universal Driver Documentation
Utility function for converting AD units to voltage based on the AD settings used.

Table of contents

Function Definition

BYTE dscADCodeToVoltage(DSCB board, DSCADSETTINGS adsettings, DSCSAMPLE adcode, DFLOAT *voltage);

Function Parameters

NameDescription
boardThe board handle
adsettingsAD settings used when the sample was taken
adcodeAD code to be converted
voltagePointer to the variable which will hold the converted voltage

Return Value

Error code or 0.

Usage Example

    ERRPARAMS errparams;
    DSCADSETTINGS adsettings;
    DSCB dscb;
    DSCSAMPLE sample;
    DFLOAT voltage;
    BYTE result;

    /* Board initialization code omitted */

    if ((result = dscADSample(dscb, &sample)) != DE_NONE)
    {
        dscGetLastError(&errparams);
        fprintf(stderr, "dscADSample failed: %s (%s)\n", 
                dscGetErrorString(result), errparams.errstring);
        return result;
    }

    if ((result = dscADCodeToVoltage(dscb, adsettings, sample, &voltage)) != DE_NONE)
    {
        dscGetLastError(&errparams);
        fprintf(stderr, "dscADCodeToVoltage failed: %s (%s)\n", 
                dscGetErrorString(result), errparams.errstring);
        return result;
    }

   printf("Sample readout: %hd, Actual voltage: %5.3lfV\n", sample, voltage); 


This page was last modified 19:42, 17 Jun 2004.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.