UltimaSerial How to program DataqSDK in Visual Studio 2010 (Visual Basic, Visual C++ and C#)

Windaq add-ons






 


 






Programming Language and Components

Visual Studio 2010, where Express version can be downloaded for free from Microsoft's website, includes

  • Visual Basic 2010 
  • Visual C++ 2010 
  • Visual C# 2010 

DATAQSDK ActiveX control

Charting ActiveX controls 

32 or 64-bit?

Most ActiveXs are 32-bit components, you must select 32-bit code option when using 64-bit compilers. Both 32-bit and 64-bit Windows runs 32-bit applications properly. 

We highly suggest you using DataqSDK.NET Class if you are starting a new project on products supported by the class

Screen Capture (The following is the output from Visual Basic 2010 Express Example)

DATAQDSK ActiveX Programming

Hardware 

Any device supported by DATAQSDK ActiveX Control, which includes:

DI-149, DI-145, DI-148U, DI-154RS, DI-158U/UP, DI-194RS, DI-195B, DI-710, DI-715B, DI-718B, DI-718Bx, DI-720, DI-722, DI-730,  DI-760, DI-785, DI-788 and DI-5001, Parallel port, USB, RS232 or Ethernet interface

Project Files Downlad

Visual Basic 2010 DataqSDK Example

Visual C++ 2010 DataqSDK Example

Visual C# 2010 DataqSDK Example

Tutorial

To use ActiveX under Visual Basic Express

To use ActiveX under Visual C++ Express

To use ActiveX under Visual C# Express

To use XChart

To use UltimaWaterfall

To use UltimaMeter

To use FFT1024

Feature

Live analog waveform

Waterfall Spectrogram

Live Meters

How to determine Device Driver and Device ID

Some popular devices

  • DI-720/730 USB
    • DataqSDK DeviceDriver = "DI720NT.DLL"
    • DataqSDK DeviceID="0"
  • DI-720/730 Ethernet
    • DataqSDK DeviceDriver = "DI800NT.DLL"
    • DataqSDK DeviceID=<IP Address of the device>
    • For example, if 720's IP address is 192.168.0.22, DeviceID="192.168.0.22"
  • DI-145
    • DataqSDK DeviceDriver = "DI1??NT.DLL", where ?? is the two-digit Virtual COM port number for the device
    • DataqSDK DeviceID="COM?? 145 9600", where ?? is theVirtual COM port number for the device
    • For example, if DI-145 is connected to Virtual COM 4, DeviceDriver = "DI104NT.DLL" and DeviceID="COM4 145 9600"
  • DI-149
    • DataqSDK DeviceDriver = "DI1??NT.DLL", where ?? is the two-digit Virtual COM port number for the device
    • DataqSDK DeviceID="COM?? 149 38400", where ?? is the Virtual COM port number for the device
    • For example, if DI-149 is connected to Virtual COM 13, DeviceDriver = "DI113NT.DLL" and DeviceID="COM13 149 38400"
  • DI-155
    • DataqSDK DeviceDriver = "DI1??NT.DLL", where ?? is the two-digit Virtual COM port number for the device
    • DataqSDK DeviceID="COM?? 155 38400", where ?? is the Virtual COM port number for the device
    • For example, if DI-155 is connected to Virtual COM 10, DeviceDriver = "DI110NT.DLL" and DeviceID="COM10 155 38400"
  • DI-158
    • DataqSDK DeviceDriver = "DI1??NT.DLL", where ?? is the two-digit Virtual COM port number for the device
    • DataqSDK DeviceID="COM?? 158 38400", where ?? is the Virtual COM port number for the device
    • For example, if DI-158 is connected to Virtual COM 5, DeviceDriver = "DI105NT.DLL" and DeviceID="COM5 158 38400"
  • DI-71x USB
    • DataqSDK DeviceDriver = "DI1??NT.DLL", where ?? is the two-digit COM port number the device connected to
    • DataqSDK DeviceID="COM?? 710 38400", where ?? is the COM port number the device connected to
    • For example, if DI-718 is connected to COM 8, DeviceDriver = "DI108NT.DLL" and DeviceID="COM8 718 38400"
  • DI-148
    • DataqSDK DeviceDriver = "DI1??NT.DLL", where ?? is the two-digit Virtual COM port number for the device
    • DataqSDK DeviceID="COM?? 148 38400", where ?? is the Virtual COM port number for the device
    • For example, if DI-148 is connected to Virtual COM 3, DeviceDriver = "DI103NT.DLL" and DeviceID="COM3 148 38400"
  • Please refer to this document for more info

 

Source Codes 

Visual Basic 2010 Example...

Public Class Form1

Dim v(,) As Short

Dim v2(,) As Short

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click

AxDataqSdk1.DeviceDriver = TextBox1.Text

AxDataqSdk1.DeviceID = TextBox2.Text

AxDataqSdk1.SampleRate = Val(TextBox3.Text)

AxDataqSdk1.ADChannelCount = 1

AxDataqSdk1.EventPoint = 1

AxDataqSdk1.Start()

AxUltimaMeter2.MaxValue = AxDataqSdk1.SampleRate / 2

TextBox3.Text = AxDataqSdk1.SampleRate

Timer1.Interval = 10

Timer1.Enabled = True

Timer2.Interval = 50

Timer2.Enabled = True

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

AxDataqSdk1.Stop()

Timer1.Enabled = False

Timer2.Enabled = False

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Dim dTemp As Double

If AxDataqSdk1.AvailableData > 0 Then

v = AxDataqSdk1.GetData

AxXChart1.Chart(v)

dTemp = Val(v(0, 0))

AxUltimaMeter1.Value = dTemp / 3276.8

End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

AxUltimaMeter1.MinValue = -10

AxUltimaMeter1.MaxValue = 10

AxUltimaMeter2.MinValue = 0

AxUltimaMeter2.Unit = "Peak Hz"

AxUltimaWaterfall1.ChartType = ULTIMAWATERFALLLib.enumCharType.uw3D

AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwNSlope

AxUltimaWaterfall1.ScalingMethod = ULTIMAWATERFALLLib.enumColorScale.uwBGR

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

Dim i As Short

v2 = AxDataqSdk1.GetDataFrame(1024)

For i = 0 To 1023

AxFFT10241.SetWaveformPt(i, v2(0, i))

Next i

AxFFT10241.FFTNow(1024)

AxUltimaWaterfall1.Chart(AxFFT10241.Power)

AxUltimaMeter2.Value = AxUltimaMeter2.MaxValue * (AxFFT10241.GetPeakIdx() / 512)

End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

If Timer1.Enabled Then AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwB2T

End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

If Timer1.Enabled Then

If CheckBox1.CheckState = CheckState.Checked Then

AxUltimaWaterfall1.ChartType = ULTIMAWATERFALLLib.enumCharType.uw3D

RadioButton6.Enabled = False

RadioButton4.Enabled = False

Else

AxUltimaWaterfall1.ChartType = ULTIMAWATERFALLLib.enumCharType.uw2D

RadioButton6.Enabled = True

RadioButton4.Enabled = True

End If

End If

End Sub

Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged

If Timer1.Enabled Then AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwR2Lx

End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

If Timer1.Enabled Then AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwNSlope

End Sub

Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged

If Timer1.Enabled Then AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwT2B

End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

If Timer1.Enabled Then AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwSlope

End Sub

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged

If Timer1.Enabled Then AxUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwR2L

End Sub

End Class

 

Visual C++ 2010 Example...

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#include <vcclr.h>

...

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

axDataqSdk1->DeviceDriver=textBox1->Text;

axDataqSdk1->DeviceID=textBox2->Text;

axUltimaMeter1->MaxValue=10;

axUltimaMeter1->MinValue=-10;

 

axDataqSdk1->SampleRate=Double::Parse(textBox3->Text);

axUltimaWaterfall1->ChartType=ULTIMAWATERFALLLib::enumCharType::uw3D;

axUltimaWaterfall1->ChartDirection=ULTIMAWATERFALLLib::enumCharDir::uwSlope;

axDataqSdk1->EventPoint=1;

timer1->Interval=10;

timer1->Enabled=1;

timer2->Interval=50;

timer2->Enabled=1;

axDataqSdk1->Start();

}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {

timer1->Enabled=0;

timer2->Enabled=0;

axDataqSdk1->Stop();

}

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {

if (axDataqSdk1->AvailableData >0){

array<Int16, 2>^ Data = (array<Int16, 2>^)axDataqSdk1->GetData();

axXChart1->Chart(Data);

axUltimaMeter1->Value=(double)Data[0,0]/3276.8;

}

}

private: System::Void axDataqSdk1_ControlError(System::Object^ sender, AxDATAQSDKLib::_DDataqSdkEvents_ControlErrorEvent^ e) {

timer1->Enabled=0;

timer2->Enabled=0;

}

private: System::Void timer2_Tick(System::Object^ sender, System::EventArgs^ e) {

array<Int16, 2>^ Data2 = (array<Int16, 2>^)axDataqSdk1->GetDataFrame(1024);

int i;

for (i=0; i<1024; i++){

axFFT10242->SetWaveformPt(i,(double)Data2[0,i]);

}

axFFT10242->FFTNow(1024);

axUltimaWaterfall1->Chart(axFFT10242->Power());

}

 

 
Visual C# 2010 Example...

.....

private void button1_Click(object sender, EventArgs e)

{

axDataqSdk1.DeviceDriver=textBox1.Text;

axDataqSdk1.DeviceID=textBox2.Text;

axUltimaMeter1.MaxValue=10;

axUltimaMeter1.MinValue=-10;

axDataqSdk1.SampleRate=Convert.ToDouble(textBox3.Text);

axUltimaWaterfall1.ChartType = ULTIMAWATERFALLLib.enumCharType.uw3D;

axUltimaWaterfall1.ChartDirection = ULTIMAWATERFALLLib.enumCharDir.uwSlope;

axDataqSdk1.EventPoint=1;

timer1.Interval=10;

timer1.Enabled = true;

timer2.Interval=50;

timer2.Enabled = true;

axDataqSdk1.Start();

}

private void button2_Click(object sender, EventArgs e)

{

timer1.Enabled = false;

timer2.Enabled = false;

axDataqSdk1.Stop();

}

private void timer1_Tick(object sender, EventArgs e)

{

if (axDataqSdk1.AvailableData > 0)

{

object V;

short[,] intArray;

V = axDataqSdk1.GetData();

axXChart1.Chart(V);

intArray = (short[,])V;

axUltimaMeter1.Value = intArray[0, 0]/3276.8;

}

}

private void timer2_Tick(object sender, EventArgs e)

{

object V;

short[,] intArray;

short i;

V = axDataqSdk1.GetDataFrame(1024);

intArray = (short[,])V;

for (i=0; i<1024; i++){

axFFT10241.SetWaveformPt(i, intArray[0, i]);

}

axFFT10241.FFTNow(1024);

axUltimaWaterfall1.Chart(axFFT10241.Power());

}

private void axDataqSdk1_ControlError(object sender, AxDATAQSDKLib._DDataqSdkEvents_ControlErrorEvent e)

{

timer1.Enabled = false;

timer2.Enabled = false;

axDataqSdk1.Stop();

MessageBox.Show("Error: Please check DeviceDriver and DeviceID");

}

 

Last update: 11/18/16

© www.ultimaserial.com