?
Solved

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

Posted on 2006-04-25
3
Medium Priority
?
653 Views
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

0
Comment
Question by:2E0AQU
3 Comments
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 400 total points
ID: 16540246
There is a sample here, using Managed DirectX to plot a sine wave:

http://www.drunkenhyena.com/cgi-bin/view_net_article.pl?chapter=2;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
http://msdn.microsoft.com/directx/sdk/

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.

Bob
0
 
LVL 9

Accepted Solution

by:
jrscherer earned 1600 total points
ID: 16541277
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)
        Next

        ' 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
        Next

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

have fun   Jack.net
0
 

Author Comment

by:2E0AQU
ID: 16541715
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.
Regards
Paul
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

839 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