Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

I have this NI visual basic example for AI, but I really don't understand what it's reading

I have this NI visual basic example for AI, but I really don't understand what it's reading. I think it's reading voltage, but when i turn of my power supply it still shows fluctuations. For example, in the attached picture, it shows the y value reading to be at the 6.5 range.... I am confused because my power supply is off. But I guess it's probably not reading voltage?? I have everything connected correctly. I don't know what the x and y values represent.

I have a power supply and would like to use this program to read the voltage it's putting out and then display it, using this program. Could somebody please tell me how to make the program do this. Here's the code:

Option Explicit

Private Sub CWGraph1_Click()

End Sub

Private Sub CWHelpButton1_GotFocus()

End Sub

Private Sub Form_Load()

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Start_Click()
If CWButton1.Value Then
CWAI1.StopCondition.Type = cwaiContinuous
Else
CWAI1.StopCondition.Type = cwaiNoActiveCondition
End If

CWAI1.Configure
CWAI1.Start
End Sub

Private Sub Stop_Click()
CWAI1.Stop
' Only need to call Reset to free up
' resource if you don't plan to run
' another acquisition
CWAI1.Reset
End Sub

Private Sub CWAI1_AcquiredData(ScaledData As Variant, BinaryCodes As Variant)
CWGraph1.PlotY ScaledData
End Sub

Private Sub CWButton1_ValueChanged(ByVal Value As Boolean)
If Value Then
CWAI1.StopCondition.Type = cwaiContinuous
Else
CWAI1.StopCondition.Type = cwaiNoActiveCondition
End If
End Sub

Private Sub CWAI1_DAQError(ByVal StatusCode As Long, ByVal ContextID As Long, ByVal ContextDescription As String)
MsgBox "Error: " & StatusCode & vbCrLf & "Context: " & ContextDescription & vbCrLf & CWDAQTools1.GetErrorText(StatusCode)
End Sub

Private Sub CWAI1_DAQWarning(ByVal StatusCode As Long, ByVal ContextID As Long, ByVal ContextDescription As String)
MsgBox "Warning: " & StatusCode & vbCrLf & "Context: " & ContextDescription & vbCrLf & CWDAQTools1.GetErrorText(StatusCode)
End Sub


**********
Thank you so much.
0 Kudos
Message 1 of 2
(3,110 Views)
Hi Salsa,
You're right, it is reading voltage. The x and y values represent time and voltage level. Depending on how fast you're sampling is a determining factor in the x value, and the y value represents your signal. The program you have here is correct, all of the settings and properties of the data acquisition is being set in the activeX control itself, not in the code. The code here sets up the form, and records the data (ScaledData) to the graph. When you go to the front panel of your program and right click on the AI CW control, you can select properties and then choose how you want your data to be acquired and from where (this is also where you select the channel to be read).
If you would like to check out more AI examples that ship with MeasurementS
tudio, you'll be able to compare and understand further how everything is working. Good luck Salsa.
Thanks,
Ted F.
0 Kudos
Message 2 of 2
(3,110 Views)