DscVoltageToADCode

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

Table of contents

Function Definition

BYTE dscVoltageToADCode(DSCB board, DSCADSETTINGS adsettings, DFLOAT voltage, DSCADSAMPLE *adsample);

Function Parameters

NameDescription
boardThe board handle
adsettingsAD settings to be used in unit conversion
voltageThe voltage to be converted
adsamplePointer to the variable that will hold the converted units

Return Value

Error code or 0.

Usage Example

    ERRPARAMS errparams;
    DSCADSETTINGS adsettings;
    DSCB dscb;
    DSCADSAMPLE adsample;
    DFLOAT voltage;
    BYTE result;

    /* Board initialization code omitted */

    voltage = 2.0;

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

   printf("Voltage: %5.3lfV, AD code: %d\n", voltage, adsample); 


This page was last modified 22:14, 30 Jun 2004.
Copyright (c) 2004 Diamond Systems. All Rights Reserved.