Appendix B - Emant300 Class Reference Represents the EMANT300, a low cost USB data acquisition module from EMANT PTE LTD. The USB DAQ Module measures analog input voltages, output analog current and perform digital input and outputs, PWM or Counter functions. The following example reads in the analog voltage connected to Analog Input 0 and the Common Analog Input. Imports Emant Module Module1 Sub Main() Dim volt As Double Dim DAQ As Emant300 = New Emant300 DAQ.Open() volt = DAQ.ReadAnalog(Emant300.AIN.AIN0, Emant300.AIN.COM) Console.WriteLine(volt) DAQ.Close() End Sub Requirements Namespace: Emant Assembly: Emant300.dll, CommBase.dll, Sim300.dll, EmantUtil.dll 1 2005, 2006 Emant Pte Ltd www.emant.com
List of Emant300 Constructor Initializes a new instance of the Emant300 class. public Emant300(); Creates an instance called DAQ Dim DAQ As Emant300 = New Emant300 Emant300.Simulation Property Gets or sets the boolean to determine to use the hardware or simulator. Must set Simulation before calling Open method. public boolean Simulation {get; set;} Property Value true to connect to simulator, false to connect to hardware. Default is false. Use simulator Dim DAQ As Emant300 = New Emant300 DAQ.Simulation = True DAQ.Open() Emant300.HwId Property Gets the Hardware Identity of the Emant300 DAQ module connected. The string gives the model and firmware version public string HwId {get;} Property Value If the following string is returned, Emant300 000001, it indicates that the firmware version is 000001. Emant300.CommPort Property Gets the virtual Comm Port, the Emant300 DAQ module is connected to. public string CommPort {get;} Property Value If the module is connected to the virtual serial comm port 2, then COM2 is returned. This information is useful when you need to connect several Emant300 to the same computer. 2 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.Open Method Opens the connection to the Emant300. public boolean Open(); Returns true if DAQ module is found. Finds and opens the connection to the DAQ module. DAQ.Open() Emant300.Open Method (bool, string) Opens the connection to the Emant300. public boolean Open( bool find, string port); Port The virtual serial comm. Port the Emant300 is connected to. Returns true if DAQ module is found. Do not find but open the DAQ module that is connected to COM2. Use this to connect to several Emant300 to the same computer. DAQ.Open(false, COM2 ) If find is true, it will find the Emant300 connected with the lowest Virtual Comm Port Number. Emant300.Close Method Close the Emant300 connection. IMPORTANT - the Close method must be called before the program exits if Open was successful. public void Close(); DAQ.Close() Emant300.Reset Method Reset the Emant300. public void Reset(); 3 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.ConfigDIO Method (Int32) Sets the 8 bits of the DIO indicating the bit should be configured as input or output. Must set configuration before calling Open method public Boolean ConfigDIO(Int32 Value) Value 0 to set bit as output and 1 to set bit as input. True if configuration is successful otherwise false. The light application adaptor has bit 0-2 as outputs and bit 3 as input. Emant3001.ConfigDIO(&H08) Emant300.ConfigPWMCounter Method (Emant300.PWMORCNT, Emant300.EVENTORTIMED, Int32, Int32) Configures the PWM or Counter public Boolean ConfigPWMCounter (Emant300.PWMORCNT PWMOrCnt, Emant300.EVENTORTIMED EventOrTimed, Int32 MSInt, Int32 SetCount) PWMOrCnt Specify if PWM or Counter in operation. EventOrTimed Specify if Counter is Timed or Event Counting. MSInt For Timed Counting, specifies the period in msec to count pulses. SetCount For Event Counting, used to clear or set count to specific start value. True if configuration is successful otherwise false. Strain gauges connected in the bridge configuration have very low output voltage. The following line configures the analog input range to -0.01 to 0.01 and sampling rate to 10Hz Emant3001.ConfigAnalog(0.01,Emant.Emant300.POLARITY.Bipolar, 10) Emant300.ConfigAnalog Method (Double, Emant300.POLARITY,Int32) Configures the Analog Input for Input Range, Polarity and Sampling Rate public Boolean ConfigAnalog(Double InputLimit, Emant300.POLARITY Polarity, Int32 SampleFreq ) InputLimit The input range of the input signal. Polarity Specify if input signal is unipolar or bipolar. SampleFreq Sampling frequency. The default is 100 samples/sec. True if configuration is successful otherwise false. For Strain gauges, set analog input range to -0.01 to 0.01 and sampling rate to 10Hz Emant3001.ConfigAnalog(0.01,Emant.Emant300.POLARITY.Bipolar, 10) 4 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.ConfigAnalogAdvance Method (Emant300.POLARITY, Emant300.FILTER, Emant300.CALIBRATION, Boolean, Emant300.REF, Emant300.VREF, Boolean, Emant300.PGA, Int32, Int32, Int32) Configures the Analog Input - for advanced users public Boolean ConfigAnalogAdvance (Emant300.POLARITY Polarity, Emant300.FILTER Filter, Emant300.CALIBRATION Calibration, Boolean BOD,Emant300.REF Reference, Emant300.VREF VRef, Boolean Buffer, Emant300.PGA Gain, Int32 ACLK, Int32 Decimation, Int32 ODAC) Polarity Specify if input signal is unipolar or bipolar. Filter Set ADC Filter. Calibration Set ADC Calibration. BOD When the Burnout Detect is set, two current sources are enabled. The current source on the positive input channel sources approximately 2µA of current. The current source on the negative input channel sinks approximately 2µA. This allows for the detection of an open circuit (full-scale reading) or short circuit (small differential reading) on the selected input differential pair. Enabling the buffer is recommended when BOD is enabled. Set true to enable and false to disable Reference Specify internal or external reference. VRef Set the internal reference to either 1.25V or 2.5V Buffer Set true to enable input Buffer Amplifer, false to disable buffer. Gain Set PGA gain. ACLK Analog clock frequency Decimation Decimation Ratio ODAC The analog output from the PGA can be offset by up to half the full-scale input range of the PGA by using the ODAC register. The ODAC (Offset DAC) register is an 8-bit value; the MSB is the sign and the seven LSBs provide the magnitude of the offset. The data rate for the ADC is determined by ACLK and Decimation Ratio. First, the ACLK register divides the system clock; that value is then divided by 64 to give us the modulation clock. The data output rate is determined by the Decimation Ratio. The eleven bits in the decimation ratio divide the modulation clock to calculate the data output rate. 22118400 Data Rate= ACLK 1 64 Decimation True if configuration is successful otherwise false. 5 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.ReadAnalog Method (Emant300.AIN, Emant300.AIN) Measures the analog voltage of any two of the six plus one common analog inputs of the DAQ module. Measures the internal temperature sensing diode voltage if both inputs set to DIODE. public double ReadAnalog( Emant300.AIN PositiveInput, Emant300.AIN NegativeInput); PositiveInput The positive analog input channel. NegativeInput The negative analog input channel. The value of the voltage read. Measure voltage difference between analog input channel 0 and analog input common. Dim volt As Double volt = DAQ.ReadAnalog(Emant300.AIN.AIN0,Emant300.AIN.COM) Emant300.ReadAnalogWaveform Method (Emant300.AIN, Emant300.AIN, Int32) Measures the waveform of any two of the six plus one common analog inputs of the DAQ module. Measures the internal temperature sensing diode voltage if both inputs set to DIODE. public double[] ReadAnalogWaveform ( Emant300.AIN PositiveInput, Emant300.AIN NegativeInput, Int32 NumberOfSamples ) PositiveInput The positive analog input channel. NegativeInput The negative analog input channel. NumberOfSamples Specify the number of samples The waveform read. Measure a 300 point waveform of the voltage difference between analog input channel 0 and analog input common. Dim mywave(300) As Double mywave = emant3001.readanalogwaveform(emant300.ain.ain3,emant300.ain.com,300) Emant300.WriteAnalog Method (double) Set the analog output current of the DAQ module. public void WriteAnalog(double ma) ma The analog current value to be output (0 to 1mA). Set Analog Output Current to 0.1 ma DAQ.WriteAnalog(0.1) 6 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.ReadDigitalBit (Int) Reads in the state of the Digital Input of the DAQ module. public boolean ReadDigital(int32 channel) channel The digital channel to read. The return bool represents the state of the digital input. Read the state of the digital bit 4. Dim swstate as Boolean swstate = DAQ.ReadDigitalBit(4) Emant300.ReadDigitalPort Reads in the state of the Digital Input of the DAQ module. public int32 ReadDigital() The return int32 represents the 8 bits of the digital port. Emant300.WriteDigitalBit Method (int, bool) Set state of the Digital Ouput of the DAQ module. Does not affect bits configured as Digital Inputs. public boolean WriteDigital(int32 channel, boolean DAQDO) channel The digital channel to set. DAQDO The state to be set. Set the output of bit 0 of the DIO to high. DAQ.WriteDigitalBit(0, True) Emant300.WriteDigitalPort Method (int) Set state of the Digital Ouput of the DAQ module. Does not affect bits configured as Digital Inputs. public boolean WriteDigitalPort(int32 value) value 8 bit value of the output. 7 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.ReadCounter (out Double) Reads the counter value. public Int32 ReadCounter(out Double Period) The return int32 represents the count. Period returns the period if counter is configured for Timed Counting Read the count and period of the input digital waveform. Dim Period, temp As Double temp = Emant3001.ReadCounter(out Period); Emant300.WritePWM (Double, Double) Reads the counter value. public Boolean WritePWM (Double Period, Double DutyCycle ) Period Period of the PWM in us (100 to 35000). DutyCycle The duty cycle (0 to 100%). Set up a 10ms period (100 Hz), 40% duty cycle PWM. Emant3001.WritePWM(10000, 40); 8 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.AIN Enumeration Specifies the inputs of the ReadAnalog method. AIN0 AIN0 Analog Input 0 AIN1 AIN1 Analog Input 1 AIN2 AIN2 Analog Input 2 AIN3 AIN3 Analog Input 3 AIN4 AIN4 Analog Input 4 AIN5 AIN5 Analog Input 5 COM DIODE AINCOM Common Analog Input DIODE Temperature Sensing Diode Emant300.VREF Enumeration Specifies the internal reference voltage. V2_5 Sets internal reference voltage to 2.5V V1_5 Sets internal reference voltage to 1.5V Emant300.POLARITY Enumeration Specifies the polarity of the input voltage. Unipolar Bipolar The input voltage range is unipolar (example 0 to 2.5V) The input voltage range is bipolar (example -2.5V to 2.5V) 9 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.FILTER Enumeration At the ouput of the ADC is a Digital Filter. The Digital Filter can use either the Fast Settling, Sinc2, or Sinc3 filter. In addition, the Auto mode changes the Sinc filter after the input channel or PGA changed. When switching to a new channel, it will use the Fast Settling filter. It will then use the Sinc2 followed by the Sinc3 filter to improve noise performance. Auto Fast_Settling Sinc_2 Sinc_3 Auto mode Fast Settling Sinc2 Sinc3 Emant300.CALIBRATION Enumeration The offset and gain errors in Emant300, or the complete system, can be reduced with calibration. Each calibration process takes seven acquisition clock cycles to complete. Therefore, it takes 14 clock cycles to complete both an offset and gain calibration.. No_Cal Self_Cal_Offset_Gain Self_Cal_Offset Self_Cal_Gain Sys_Cal_Offset Sys_Cal_Gain No Calibration Self Calibrate Offset and Gain Self Calibrate Offset Only Self Calibrate Gain Only System Calibrate Offset Only System Calibrate Gain Only Emant300.REF Enumeration The Emant300 can use either an internal or external voltage reference. Internal External Internal voltage reference External voltage reference 10 2005, 2006 Emant Pte Ltd www.emant.com
Emant300.PGA Enumeration Specifies the gain of the Programmable Gain Amplifier. G1 Sets Gain to 1 G2 Sets Gain to 2 G4 Sets Gain to 4 G8 Sets Gain to 8 G16 Sets Gain to 16 G32 Sets Gain to 32 G64 Sets Gain to 64 G128 Sets Gain to 128 Emant300.PWMORCNT Enumeration Use the Counter or the PWM. Count PWM Use Counter Use PWM Emant300.EVENTORTIMED Enumeration The Counter can be configured to either measure frequency/period of a digital waveform or count events. Timed Event Measure Frequency / Period Count Events 11 2005, 2006 Emant Pte Ltd www.emant.com