UltimaSerial How to use ActiveX in VC (Visual C++)
USB-based DI-148, DI-158, DI-710, DI-715B & DI-718B are now supported by Ultimaserial

158u.jpg (11869 bytes)

Let UltimaSerial unleash the power of your Windaq Starter kit!

 

UltimaWaterfall

UltimaWaterfall

 

FFT1024

FFT1024

 

XChart

 

Ultimaserial Classroom

Lessons on how to use UltimaSerial

 

download.jpg (1018 bytes) Downloads

 

Registration.jpg (4365 bytes)

info@ultimaserial.com

 

 

The following is a step-by-step lesson on how to use ActiveX in Visual C++ (VC++)

In this lession, we will use Ultimaserial ActiveX to develop a data acquisition application with DATAQ's Starter kit. 

Specification of the sample program:

a) Acquire voltage signal between -10 to 10V via Channel 1 of DI-194 at a rate of 240 Samples/second 
b) The data is streamed back to the PC via COM 1
c) The input signal is displayed on a scrolling waveform window

Here, we will create a  Windows dialog-based Visual C++ program to acquire data from the DI-194 via COM 1. The program will start to acquire data as soon as the it is started, you can push the Cancel button to exit the program.

Before we start, please download and install UltimaSerial then run Microsoft Visual C++.

1) Start Visual C++, and follow File->New

2) In the dialogue box New, choose Projects Tab

3) Select MFC AppWizard (exe), Fill in the name "Ultima" in project name and hit OK

4) Select Dialogue-based for "What type of application would you like to create?", then hit Finish.

5) Hit OK to create the project files.

6) If you see a dialoge box template labled as Ultima on your screen, you can proceed to Step 11)

7) From Workspace pane, select Resource

8) Click on the + sign in front of Ultima resources and you should see the folder labled as Dialog

9) Click on the + sign in front of the folder Dialog, and you should see IDD_ULTIMA_DIALOG.

10) Double-click on IDD_ULTIMA_DIALOG and you will see the dialoge box template labled as Ultima on your screen

11) Move the cursor to the dialog box template Ultima, and click the right button on your mouse, and follow Insert ActiveX Control ...

12) In several seconds, you will see a dialog box labeled as Insert ActiveX Control

13) Double click on DQChart Control in the list (If you don't see this control in the list, you need to install UltimaSerial.)

14) Repeat 11-13) to insert UltimaSerial Control

15) Remove the OK button and the "TODO Place dialog controls here" text from the dialog box. Also, resize/re-arrange the objects on the dialog box if you like

16) Follow View->ClassWizard ... to bring up the MFC ClassWizard

17) From the Member Variables tab of the MFC ClassWizard, Double-click on IDC_DQCHARTCTRL1, and the Wizard will ask if it is OK to generate a C++ wrapper class for it

18) Select OK to create the wrapper class for DQ Chart Control. When the Add Member Variable dialog box comes up, set the member variable name to m_dqchart

19) Repeat 16-18) to add a member variable m_ultima for IDC_ULTIMASERIALCTRL1

20) Hit OK to exit MFC ClassWizard

21) On the dialog box template Ultima, right-click on UltimaSerial control and follow Events...

22) You will see a dialog box labled as New Windows Message and Event Handlers for CUltimaDlg.

23) Double-click on NewData under New Windows messages/events list, then hit OK to use the default name

24) Hit OK to exit the dialog box New Windows Message and Event Handlers for class CUltimaDlg

25) From the Workspace pane, follow FileView tab, and open UltimaDlg.cpp

26) Add the follow codes to BOOL CUltimaDlg::OnInitDialog(), right after the comment // TODO: Add extra initialization here (If you decide to type in the codes, you will notice the properties and methods will be displayed in a drop-down menu once you typed in m_ultima.)

m_ultima.SetDevice(194);
m_ultima.SetCommPort(1);
m_ultima.SetEventLevel(2);
m_ultima.SetSampleRate(240);
m_ultima.SetChannelCount(1);
m_ultima.Start();

27) Add the follow codes OnNewDataUltimaserialctrl1(short Count)

m_dqchart.Chart (m_ultima.GetData());

Now, compile the project and run!

Last update: 10/05/07

Copyright: 2000-2005  www.UltimaSerial.com