Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: CWAI stops after msgbox is displayed

3 views
Skip to first unread message

Chapashop

unread,
Aug 4, 2008, 1:40:09 PM8/4/08
to
Below is how I configure the channels.  Below that I have the complete module for acquireddata event.

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

J_Stape

unread,
Aug 12, 2008, 2:10:07 PM8/12/08
to
Hi Chapashop,

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.

0 new messages