Thanks for replying, I hope this is all you need.
CWAIDisplayMeters.Device = 1
' ChirpSampleRate = 50
CWAIDisplayMeters.NScans = 500
CWAIDisplayMeters.ReturnDataType = cwaiBinaryCodes ' cwaiBinaryCodes
CWAIDisplayMeters.ProgressEnabled = False
CWAIDisplayMeters.Channels.Add "0:1", -1, 1, cwaiRSE, cwaiDC
CWAIDisplayMeters.Channels.Add strVehicleandTireSpeedChannelRange,
intSpeedsVoltageSpanLow, intSpeedsVoltageSpanHigh, cwaiRSE, cwaiDC
CWAIDisplayMeters.ScanClock.TimebaseSource = cwaiInternalFrequencyTB
CWAIDisplayMeters.ScanClock.Frequency = 1000
CWAIDisplayMeters.StopCondition.Type = cwaiContinuousPrivate Sub CWAIDisplayMeters_AcquiredData(ScaledData As Variant, BinaryCodes As Variant)Dim i As IntegerDim TotalLoad As Long, TotalTraction As Long, TotalVehicleSpeed As Long, TotalTireSpeed As LongDim AvgLoad As Single, AvgTraction As Single, AvgVehicleSpeed As Single, AvgTireSpeed As SingleStatic beeptimer As Single 'For i = 0 To ((intContinuousSamplesperChannel * 4) - 1) Step 4 For i = 0 To ((50) - 1) ' Step 4 TotalLoad = TotalLoad + BinaryCodes(0, i) TotalTraction = TotalTraction + BinaryCodes(1, i) TotalVehicleSpeed = TotalVehicleSpeed + BinaryCodes(2, i) TotalTireSpeed = TotalTireSpeed + BinaryCodes(3, i) Next AvgVehicleSpeed = (TotalVehicleSpeed / 50) * VehicleSpeedFactor AvgTireSpeed = TotalTireSpeed / 50 If DisplayMetersRatio = 0 Then DisplayMetersRatio = 1 AvgTireSpeed = (AvgTireSpeed * DisplayMetersRatio) * VehicleSpeedFactor 'mph AvgTraction = (Int(TotalTraction / 50) * TractionFactor) - TracZero AvgLoad = (Int(TotalLoad / 50) * LoadFactor) - LoadZero TractionGrid.lblBigLoad.Caption = Format(AvgLoad, "#####")TractionGrid.lblBigTraction.Caption = Format(AvgTraction, "#####")TractionGrid.lblBigVehicleSpeed.Caption = Format(AvgVehicleSpeed, "###.0")TractionGrid.lblBigTestTireSpeed.Caption = Format(AvgTireSpeed, "###.0")End Sub
I believe that the problem you are experiencing is due to the AcquireData
method running synchronously. The Measurement Studio 6.0 help recommends acquiring
data asynchronously when using the CWAI control on a form that has other events
occurring. The CWAI.Start() function can be called to run your
acquisition asynchronously. This will place the data acquisition in a
separate thread so that it will not be affected by the UI events.