DscDACodeToVoltage

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

Table of contents

Function Definition

BYTE dscDACodeToVoltage(DSCB board, DSCDASETTINGS dasettings, DSCDACODE dacode, DFLOAT *voltage);

Function Parameters

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

Return Value

Error code or 0.

Usage Example

    ERRPARAMS errparams;
    DSCDASETTINGS dasettings;
    DSCB dscb;
    DSCDACODE dacode;
    DFLOAT voltage;
    BYTE result;

    /* Board initialization code omitted */

    dasettings.polarity = BIPOLAR;
    dasettings.load_cal = TRUE;
    dasettings.range = 10.0;

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

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

   printf("DA code converted: %d, Actual voltage: %5.3lfV\n", dacode, voltage); 


This page was last modified 00:28, 7 Aug 2004.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.