The following information is for the EMANT300

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.



Example

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


List of Members

Emant300 Constructor

Initializes a new instance of the Emant300 class.


public Emant300();

Example

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.

Example

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.

Emant300.Open Method

Opens the connection to the Emant300.


public boolean Open();

Return Value

Returns true if DAQ module is found.

Example

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);

Parameters

Port The virtual serial comm. Port the Emant300 is connected to.

Return Value

Returns true if DAQ module is found.

Example

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();

Example

DAQ.Close()


Emant300.Reset Method

Reset the Emant300.


public void Reset();




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)

Parameters

Value 0 to set bit as output and 1 to set bit as input.

Return Value

True if configuration is successful otherwise false.

Example

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)

Parameters

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.

Return Value

True if configuration is successful otherwise false.

Example

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 )

Parameters

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.

Return Value

True if configuration is successful otherwise false.

Example

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)

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)

Parameters

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 2uA of current. The current source on the negative input channel sinks approximately 2uA. 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.

Return Value

True if configuration is successful otherwise false.

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);

Parameters

PositiveInput The positive analog input channel.

NegativeInput The negative analog input channel.

Return Value

The value of the voltage read.

Example

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 )

Parameters

PositiveInput The positive analog input channel.

NegativeInput The negative analog input channel.

NumberOfSamples Specify the number of samples

Return Value

The waveform read.

Example

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)

Parameters

mA The analog current value to be output (0 to 1mA).

Example

Set Analog Output Current to 0.1 mA


DAQ.WriteAnalog(0.1)




Emant300.ReadDigitalBit (Int)

Reads in the state of the Digital Input of the DAQ module.


public boolean ReadDigital(int32 channel)

Parameters

channel The digital channel to read.

Return Value

The return bool represents the state of the digital input.

Example

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()

Return Value

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)

Parameters

channel The digital channel to set.

DAQDO The state to be set.

Example

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)

Parameters

value 8 bit value of the output.




Emant300.ReadCounter (out Double)

Reads the counter value.


public Int32 ReadCounter(out Double Period)

Return Value

The return int32 represents the count.

Period returns the period if counter is configured for Timed Counting

Example

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 )

Parameters

Period Period of the PWM in uS (100 to 35000).

DutyCycle The duty cycle (0 to 100%).

Example

Set up a 10ms period (100 Hz) , 40% duty cycle PWM.


Emant3001.WritePWM(10000, 40);

Emant300.AIN Enumeration

Specifies the inputs of the ReadAnalog method.

Members

Member name

Description

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

AINCOM - Common Analog Input

DIODE

DIODE - Temperature Sensing Diode


Emant300.VREF Enumeration

Specifies the internal reference voltage.

Members

Member name

Description

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.

Members

Member name

Description

Unipolar

The input voltage range is unipolar (example 0 to 2.5V)

Bipolar

The input voltage range is bipolar (example -2.5V to 2.5V)


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.

Members

Member name

Description

Auto

Auto mode

Fast_Settling

Fast Settling

Sinc_2

Sinc2

Sinc_3

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..

Members

Member name

Description

No_Cal

No Calibration

Self_Cal_Offset_Gain

Self Calibrate Offset and Gain

Self_Cal_Offset

Self Calibrate Offset Only

Self_Cal_Gain

Self Calibrate Gain Only

Sys_Cal_Offset

System Calibrate Offset Only

Sys_Cal_Gain

System Calibrate Gain Only


Emant300.REF Enumeration

The Emant300 can use either an internal or external voltage reference.

Members

Member name

Description

Internal

Internal voltage reference

External

External voltage reference


Emant300.PGA Enumeration

Specifies the gain of the Programmable Gain Amplifier.

Members

Member name

Description

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.

Members

Member name

Description

Count

Use Counter

PWM

Use PWM


Emant300.EVENTORTIMED Enumeration

The Counter can be configured to either measure frequency/period of a digital waveform or count events.

Members

Member name

Description

Timed

Measure Frequency / Period

Event

Count Events

DAQ & Visual Basic Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37