Graphing Problem

ReCuRsI0N
01-31-2005, 07:32 AM
Hi everyone,

First of all I would like to say that I am totally new to these boards and fairly new to visual basic programming. Hopefully i'm posting this in the correct area but if i'm not then I am deeply sorry. Now with the explaination of my problem.

Well just to give you a little background this project involves me making an interface to a Gas Chromatograph. So basically I have to get the data in through the serial port and do a graphical analysis on it using VB. Due to the Chromatograph being tedious to work with I decided to do my testing using a function generator. All was going well and I managed to get a sine wave graphed but with one problem. While the programing is graphing it seems that my entire interface experiences a huge lag and I am unable to use the command buttons since the graph is consistantly updating.

I am using visual basic 6.0,componentone activex chart 7.0 control, and the activeDAQ control which allows me to get my serial data into VB. Below is my code so far and it would be greatly appreciated if you could give me some suggestions about how to resolve this problem. Thanks in advance.


Private Sub cmdGraph_Click()
Timer1.Interval = 1

Timer1.Enabled = True
End Sub

Private Sub cmdSelectDevice_Click()
DAQDevice1.SelectDevice
txtDeviceName.Text = DAQDevice1.DeviceName
End Sub

Private Sub mnuExit_Click()
End
End Sub

Private Sub Timer1_Timer()
DAQAI1.DeviceNumber = DAQDevice1.DeviceNumber
DAQAI1.OpenDevice

' Setup the chart so it will display correctly
Chart2D1.ChartGroups(1).Styles(1).Symbol.Size = 0

With Chart2D1.ChartGroups(1).Data
.IsBatched = True
.NumSeries = 1
.NumPoints(1) = 500
End With

'Generate some data, and add it to the chart
For j = 1 To 4

With Chart2D1.ChartGroups(1).Data
.X(1, j) = j

For i = 1 To 500
'Get the Serial data from analog pin
.Y(1, i) = DAQAI1.RealInput(0)
Next i

End With
Next j

Chart2D1.ChartGroups(1).Data.IsBatched = False

End Sub

Private Sub VScroll1_Change()

Chart2D1.ChartArea.Axes("Y").Max.Value = VScroll1.Value

End Sub

passel
01-31-2005, 08:02 AM
Could try adding "DoEvents" at suitable locations.
I would try inside your 1 to 500 loop.
Adding the line DoEvents, will allow VB to process any Events, like button presses, etc.
in they are pending.

You might need to add in other locations, if you end up with other processor
intensive loops.

ReCuRsI0N
01-31-2005, 08:54 AM
Could try adding "DoEvents" at suitable locations.
I would try inside your 1 to 500 loop.
Adding the line DoEvents, will allow VB to process any Events, like button presses, etc.
in they are pending.

You might need to add in other locations, if you end up with other processor
intensive loops.

I tryed what you said and it seems to be working thanks.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum