Help with making a PC oscilloscope  , graphing display how??

Posted on 2006-04-25
Last Modified: 2008-02-01
Hi I have built a simple A/D converter that connects to the PC's lpt port and i have stored the values in a array,
i want to display these values as a oscilloscope type display, anyone point me at a bit of sample code for generating such a display?
many thanks

Question by:2E0AQU
    LVL 96

    Assisted Solution

    by:Bob Learned
    There is a sample here, using Managed DirectX to plot a sine wave:;article=20

    Down toward the bottom are links for the code:

    Source for VB.Net (9K)
    To compile this lesson you will also need the Drunken Hyena .Net Common Code

    You are also going to need the DirectX 9 SDK:

    Microsoft DirectX Downloads

    The process of using DirectX is very powerful, but also very complex, and the learning curve is very daunting, but with power comes speed and versatility.

    LVL 9

    Accepted Solution

    Why not using the pretty strong GDI+?
    Here is an example.

    To run it you need to add Imports System.Math to the top of the form class.
    Then create a PictureBox with the default name PictureBox1 abour 4 x 4 inches in size. Give it a green background color. (I use BackColor = Color.SeaGreen. It looks like my Tek 465!)

    Add the following code to your form and run it.

        Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
            Dim ix As Integer = PictureBox1.Width
            Dim iy As Integer = PictureBox1.Height

            ' Make up some values
            Dim Values(ix) As Double
            For i As Integer = 0 To Values.GetUpperBound(0)
                Values(i) = Sin(i * 25)

            ' Display the values
            Dim OldPoint = New Point(0, iy \ 2)
            For i As Integer = 1 To Values.GetUpperBound(0)
                Dim y As Integer = iy \ 2 + CInt(Values(i) * (iy \ 3)) ' do some scale factor to make it look good
                Dim NewPoint = New Point(i, y)
                e.Graphics.DrawLine(Pens.Yellow, OldPoint, NewPoint)
                OldPoint = NewPoint

            ' Make the Grid
            For x As Integer = 25 To ix Step 25
                e.Graphics.DrawLine(Pens.LightGreen, x, 0, x, iy)
            For y As Integer = iy - 25 To 0 Step -25
                e.Graphics.DrawLine(Pens.LightGreen, 0, y, ix, y)
        End Sub

    have fun

    Author Comment

    Thanks to both of you for the help, i have split the points as although im not using TheLearnedOnes answer it will give me  some pointers for more complex stuff when im ready.
    Thanks to both of you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now