|
-
Dec 20th, 2014, 09:21 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Looking for advice on updating VB6 high-speed DAQ/Charting loop
The current project I'm migrating from VB6 has code like this (I've simplified it and added some comments):
vb Code:
StartTimer = Timer
Penetration = 0 'variable for how far into the test it is
Do
Penetration = (elapsed(StartTimer) / TestLength)
If Penetration > 1.1 Then Penetration = 1.1
Meter.Width = Label1.Width * Penetration 'acts as a progress bar
Meter.Refresh
DoEvents 'so Meter will really refresh
OutputVoltage = FullScale * Penetration
Call VoltsOut(OutputVoltage)
Call ReadVoltage(Analog1, Analog2, Analog3, Analog4)
i = i + 1
TimeHistory(0, i) = elapsed(StartTimer)
TimeHistory(1, i) = Analog1
TimeHistory(2, i) = Analog2
TimeHistory(3, i) = Analog3
TimeHistory(4, i) = Analog4
Loop Until (Penetration >= 1) Or (Analog1 > TestSpec)
The processor is also being upgraded to a Core 2 Duo E7400 (from mid 90s CPU!).
So if it wasn't obvious, it's ramping voltage from 0 to FullScale over TestLength and storing input values into an array. It generally collects 30,000-50,000 records depending on TestLength so approximately 2,000 per second. Since a timer can't accurately handle that frequency, I'm assuming I'm stuck keeping it in a Do...Loop (or similar construct) or possibly using API functions as in game loops. If this is a fair assessment, which would be preferred?
The UI isn't too critical while this is running as the operator is just waiting for the test to complete. However, I would like to improve the flickering and would prefer to display a live chart of the curves generated instead of using a control like a progress bar (Meter above). Hence, I believe I will need to move this loop into it's own thread (something I need to learn to do). I've read a few of the CodeBank submissions on threading but don't have a handle on whether I should start one BGW to do the whole DAQ and charting or TWO BGWs (one for DAQ and one to Chart). If the latter, I'd appreciate some pointers on how that code structure may look vs just spawning a single BGW. FWIW, I am not intending to plot ALL the points, of course - I was thinking maybe every 100th point.
Any other tips that may help?
Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|