Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wanting real time graphs

Status
Not open for further replies.

acjeff

Programmer
Aug 10, 2004
148
0
0
US
Hi all,

I think I posted about the same questions before but just never mind.

I am using VB6 application for automation machines. I want to develop a real time graph that shows a curve while taking test data. I know this task will be very difficult.

What is the best way to do it? I mean, least risk of crashing system, fast response, easiest to develop and least developing cost. I believe C++ goes faster than VB6 but is it possible to plug a C++ program into an VB6 application? If third party is a good option, any referrals?

Thanks and good day!
Jeff
 
It is possible to use DLLs written in other languages if thats what you are asking. Many of the COM objects that we use in VB are actually written in C.
 
The MSChart tool that comes with VB6 can do a lot. You've got all 4 axis available, and even a 3D option. I've used it to develop a test program that reads RF data through a serial port, and gives me a realtime graph of the information packets coming into a radio receiver. A lot of it depends on how much processing you need to do of the data, and how you are capturing it.

Robert
 
Sounds good, Robert. Do you mind giving me your test program as a reference since I have never tried using MSChart. I am using a third party software for graphing right now. Thanks.
 
Unless you have reams of data, why not draw on a picturebox? I have successfully done this plenty of times to graph many data points. It is some work, but you can write code to zoom-in and zoom-out, pan, etc. The redraw is surprisingly fast on modern computers, especially if you are only drawing a line graph (or something of that ilk).

A VB picturebox's circle and line methods can draw thousands of line segments and/or arcs with no noticable slowdown and you get great flexibility. Once you've done it once, you can generate attractive X-Y graphs very easily.
 
Here is a very simple example:

Create a new project with a command button and a picturebox. Paste this code:

Code:
Private Sub Command1_Click()
    x_small = -5
    x_large = 5
    y_small = -5
    y_large = 5

    Picture1.Scale (x_small, y_large)-(x_large, y_small)
    
    
    'draw polynomial function X^3-4X^2+X+1
    lasty = 9000
    For x = -20 To 20 Step 0.1
        y = (0.5 * x * x * x) - (2 * x * x) + x + 1
        If lasty <> 9000 Then
            Picture1.Line (lastx, lasty)-(x, y)
        End If
        lastx = x
        lasty = y
    Next x

End Sub

Cool, huh?

It looks better if the appearance property of the picture box is set to '0-flat'

Good luck,
Ryan
 
acjeff,

Sure, I can send you the source code and form in a ZIP file if you give me an address. The MSchart control will take either an array of data or a database and display them. It just depends on how many rows of data you have, or how many elements in the array. What kind of data are you trying to display, and how are you capturing the data?

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top