import com.LabJack.LabJackJNI; import com.LabJack.LabJackException; /** * This program demonstrates the use of com.LabJack.LabJackJNI.AISample(). */ public class AISample { static public void main( String args[] ) { System.out.println( "AISample() Example" ); int idnum[] = new int[ 1 ]; idnum[ 0 ] = -1; // use first LabJack found int demo = 1; // DEMO mode, set to 0 if LabJack connected int channel = 0; int stateIO[] = new int[ 1 ]; // receives input values for IO0-IO3 int updateIO = 0; // don't update IOx int ledOn = 1; // turn on LED int numChannels = 2; // read two channels int channels[] = new int[ numChannels ]; channels[ 0 ] = 0; // read AI0 (single-ended) channels[ 1 ] = 9; // read AI2/AI3 (differential) int gains[] = new int[ numChannels ]; gains[ 0 ] = LabJackJNI.G_01; // single-ended must be G_01 gains[ 1 ] = LabJackJNI.G_02; // differnental input range +/-10V int disableCal = 0; // don't disable automatic calibration correction int overVoltage[] = new int[ 1 ]; float voltages[] = new float[ 4 ]; // user manual says size has to be 4 (i.e. not numChannels). int errCode = LabJackJNI.AISample( idnum, demo, stateIO, updateIO, ledOn, numChannels, channels, gains, disableCal, overVoltage, voltages ); if( errCode != 0 ) { System.out.println( "error: " + errCode ); } else if( overVoltage[ 0 ] > 0 ) { System.out.println( "Overvoltage detected on input" ); } else { System.out.println( " Input channel " + channels[ 0 ] + " voltage is " + voltages[ 0 ] ); System.out.println( " Input channel " + channels[ 1 ] + " voltage is " + voltages[ 1 ] ); System.out.println( " IO0-IO3 inputs: " + stateIO[ 0 ] ); } } }