Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

CWAI stops after msgbox is displayed

I am doing a continuous acquisition which when the acquireddata method is reached it displays the values on the the screen.  However, I noticed that if I display a msgbox (waiting for OK to be pressed) that acquisition stops and does not restart.  I have been using the CWAI components for a while but I guess I have never had this problem before.

Using MS 6.0 with VB6. (legacy daq)

thanks for any help
0 Kudos
Message 1 of 8
(13,260 Views)
Hello Chapashop,

Could you provide a piece of your code with the relevant functions and calls that cause this behavior?
Manooch H.
National Instruments
0 Kudos
Message 2 of 8
(13,234 Views)
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 = cwaiContinuous

Private Sub CWAIDisplayMeters_AcquiredData(ScaledData As Variant, BinaryCodes As Variant)

Dim i As Integer
Dim TotalLoad As Long, TotalTraction As Long, TotalVehicleSpeed As Long, TotalTireSpeed As Long
Dim AvgLoad As Single, AvgTraction As Single, AvgVehicleSpeed As Single, AvgTireSpeed As Single
Static 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

0 Kudos
Message 3 of 8
(13,231 Views)
Hello Chapashop,

I don't see a call to msgbox in the code you provided. Is the above provided code the working version or the version that stops acquisition and doesn't start it again?
Manooch H.
National Instruments
0 Kudos
Message 4 of 8
(13,208 Views)
Manooch,

Sorry I did not include code for the msgbox.

I have about 5 msgboxes that are the same.  My msgbox type is a standard 'MsgBox "Hello"' style that displays an OK button on it.
0 Kudos
Message 5 of 8
(13,205 Views)

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.

Jessica
National Instruments
Product Support Engineer
0 Kudos
Message 6 of 8
(13,163 Views)
Jessica,

Thanks for the info.  What you said makes sense. 

I did a search for synchronous but could not find something related to configuring my CWAI control.  Do you know how I can configure it?

My previous acqs were not a problem because when I would do an acq no other processes in my VB program could occur.  This new acq that I am doing is to display values on the screen so the user could hit other buttons while this was happening.

thanks,
0 Kudos
Message 7 of 8
(13,158 Views)
Jessica,

I looked at the your comments and the Measurement Studio documentation further.  I start my acquisition (actually all) with a CWAI1.Start method.  I was not familiar with the AcquireData method.
0 Kudos
Message 8 of 8
(13,155 Views)