Download and install the latest UltimaSerial
ActiveX control, then you can try to use the follow examples to try out some hidden
features of UltimaSerial
DataPt: Instead
of using GetData or GetDataEx to retrieve the data points from the data stream, you can
use GetDataPt to retrieve a single point from the data stream.
Note:
1) Since GetDataPt is a hidden method, you will not be prompted as you
type, like all the other methods
2) If you enable more than one channel, you will have to sort out the data for each
channel yourself. The order of data points is: Ch1, Ch2, Ch1, Ch2, Ch1, Ch2, ....
(assuming you enable two channels)
3) You must use either AvailableData or NewData event to make sure you empty all the data.
see below:
Private Sub Start_Click()
UltimaSerial.Device = 194
UltimaSerial.CommPort = 1
UltimaSerial.ChannelCount = 1
UltimaSerial.EventLevel = 1
UltimaSerial.SampleRate = 24
UltimaSerial.Start
End Sub
Private Sub Stop_Click()
UltimaSerial.Stop
End Sub
Private Sub UltimaSerial_NewData(ByVal Count As Integer)
For j = 0 To Count - 1 'You must clear them all! i =
UltimaSerial.GetDataPt() 'GetDataPt is an
undocumented method
Label1.Caption = "Ch1: " & i
Next
Label3.Caption = "Available# " &
UltimaSerial.AvailableData
End Sub
To convert the AD Readings to voltage (assuming you are
using -10 to +10V input range, which is the default for most of the serial devices):
For 12-bit devices like DI-195B, DI-190, DI-150RS and DI-151RS:
Voltage = 10 * (ADReading >>4)/2048, where >>4 to means shift the data to
the right for 4 bits
For 8-bit devices like DI-194:
Voltage = 10 * (ADReading >>8)/128, where >>8 to means shift the data to
the right for 4 bits
If you don't mind the little error caused by the integer calculation, you can always
use:
Voltage = 10 * ADReading/32768
Last update: 02/29/12
Copyright: 2000-2005 www.UltimaSerial.com
|