UltimaSerial How to use ActiveX in Matlab
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 Matlab

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

Contributed by: THYAGARAJAN SADASIWAN 

The following steps show you how to write a program to acquire data from DI-194 via COM 1 under Matlab. 

If you are starting a new project, upgrade to the UltimaSerial (Version 3) now!  UltimaSerial (version 3) supports USB-based DI-148, DI-158, DI-710 & DI-715B  

1) Open up Matlab (version 12 (6p1) and 13(6p5) are tested) and on the command line type

cal = actxcontrol('ULTIMASERIAL.UltimaSerialCtrl.1') 

2) This should load the ActiveX into Matlab. Once the control is loaded into Matlab, you may use get and set commands to view and change the properties. 

For example: get(cal) would show all the properties

 3) Type

methodsview(cal) to see all events and methods in the ActiveX

 4) From here on, go to Matlab's help and type

actxcontrol in the index to lookup all other uses

5) Also, please visit http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/matlab_external.shtml and search for COM and DDE support and under that go to Invoking Methods to see how you can call the methods and events of the ActiveX component in Matlab

 If this still does not work for you, please try the above on a Windows XP machine with Matlab version 13 (6p5) and start trouble-shooting the differences…

  Please try this command in Matlab:

>>cal = actxcontrol('ULTIMASERIAL.UltimaSerialCtrl.1')

Result:

cal =
         COM.ultimaserial.ultimaserialctrl.1

Note: “cal” is now the “handle” as referred to it by Matlab...

 

Now try this comamnd:

>>get(cal)

Result:

Device: 'DI194'

CommPort: 'COM1'
ChannelCount: 1
Key: ''
SampleRate: 1
EventLevel: 0
AvailableData: 0
SerialNumber: ''
PreTriggerLength: 100
PostTriggerLength: 100
AcquisitionMode: 'NoCondition'
MaskOutDigitalBits: 0
TriggerChannel: 'AnalogCh1'
TriggerStatus: 0
TriggerLevel: 0
SquareWaveOutput: 0
DevQuitLevel: 10 

To change Com port from COM1 to COM2:

>>set(cal,'CommPort','COM2')

To verify:

>>get(cal,'CommPort')

Result:

ans =

COM2

To view all methods/events:

>>methodsview(cal)

Result:

 

 

Note: You may have to explicitly invoke the methods/events using the “invoke command” before you can use them

 >>invoke(cal)

Result: 

GetData = Variant GetData(handle)

            GetDataEx = int16 GetDataEx(handle, int16, int16)

            Start = void Start(handle)

            Stop = void Stop(handle)

            DigitalInput = int16 DigitalInput(handle, Variant)

            TransitionCounter = int32 TransitionCounter(handle, Variant, Variant)

            ResetCounter = void ResetCounter(handle, Variant, Variant)

            AnalogInput = int16 AnalogInput(handle, Variant)

            GetDataFrame = Variant GetDataFrame(handle, int16)

            GetDataFrameEx = int16 GetDataFrameEx(handle, int16, int16)

            MapErrorMessage = string MapErrorMessage(handle, int32)

            SetLimitLine = void SetLimitLine(handle, int16, int32)

            ResetAvailCounter = void ResetAvailCounter(handle)

            AboutBox = void AboutBox(handle)

 

To use a method:

>>Start(cal)

or

>>Stop(cal)

 

If you have question regarding this info, you may contact the author at raju_sadasivan@hotmail.com


Last update: 12/17/07

Copyright: 2000-2005  www.UltimaSerial.com