Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

AI multiple channels charting problem

Hi from a newbie,

I'm having a little trouble charting 2 ai channels at the same time. Please review following code. I used max to create virtual channels. I think I have set my chart properties correctly. I think the problem is in my code where I add,singleread, or chart the 2 channels.

Public Sub cmdStart_Click()

'Clear the channel list and add a new channel
CWAIPoint1.Channels.RemoveAll
CWAIPoint1.Channels.Add txtXaxis.Text
CWAIPoint1.Channels.Add txtYaxis.Text


Do While StopFlag <> True
CWAIPoint1.SingleRead X, Y
CWGraph1.ChartY X
CWGraph1.ChartY Y
DoEvents
Loop

StopFlag = False

End Sub

thanks,
Brian
0 Kudos
Message 1 of 4
(3,505 Views)
I'm not clear what the problem is that you're seeing. Is it with the acquisition or the charting? One potential problem that I see with the charting is that this code is charting the X & Y points as two separate points, not as x & y coordinates of a single point. If you want to chart the values as x & y coordinates of a single point, you should pass both the X & Y values to the ChartXY method instead of calling ChartY twice. If this was not the problem that you're seeing, please reply with more information about the problem. Thanks.

- Elton
0 Kudos
Message 2 of 4
(3,505 Views)
Sure, sorry about the confusion. X and Y are 2 different channels of data coming from an accelerometer. I have since renamed them to Xdata and Ydata. They are not the x and y coordinates of a single point, so I don't want to use the chartxy method. I want to get 2 plots or channels to show up on the same chart (Xdata and Ydata). I'm not sure if my syntax is incorrect for the aquiring or the charting.

thanks,
Brian
0 Kudos
Message 3 of 4
(3,505 Views)
If you want to chart the data on two separate plots, you will need to first add a second plot to the graph. You can do this via the Plots tab in the property pages or you can do it programatically (for example, in the Load event of the form) like this:

Private Sub Form_Load()
' This could also be done via the Plots tab in the property pages.
CWGraph1.Plots.Add
End Sub

Then you can call ChartY on the CWPlot object that you want to plot data on. For example:

CWAIPoint1.SingleRead xData, yData
CWGraph1.Plots(1).ChartY xData
CWGraph1.Plots(2).ChartY yData

Give this a try and see if this does what you're looking for.

- Elton
0 Kudos
Message 4 of 4
(3,505 Views)