DscVoltageToDACode

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

Table of contents

Function Definition

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

Function Parameters

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

Return Value

Error code or 0.

Usage Example

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

    /* Board initialization code omitted */

    voltage = 2.0;

    dasettings.polarity = BIPOLAR;
    dasettings.load_cal = TRUE;
    dasettings.range = 10.0;
    
    if ((result = dscVoltageToDACode(dscb, dasettings, voltage, &dacode)) != DE_NONE)
    {
        dscGetLastError(&errparams);
        fprintf(stderr, "dscVoltageToDACode failed: %s (%s)\n", 
                dscGetErrorString(result), errparams.errstring);
        return result;
    }

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


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