Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


How to reconstruct an analog signal


How to reconstruct an analog signal

Author
Message
artreyu
artreyu
Forum God
Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)

Group: Forum Members
Posts: 4, Visits: 6
i'm new to vb. i'll be using vb6 to do a program whereby i need to input an analog signal thru an ADC and reconstruct it in the computer using vb so that i could analyze it. i'm just wondering how do i reconstruct the signal and display it real-time in vb? any help will be greatly appreciated.
DougT
DougT
Forum God
Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)

Group: Forum Members
Posts: 12, Visits: 99
Hi,

Given that you can interface the ADC to the computer you can sample the input over time and draw the resulting trace using VBs native drawing capabilities. You'll always be a little behind 'real time' because of the time it takes to process. Have you worked out the interface yet ? (eg Serial, Parallel, USB)

Regards

Doug

artreyu
artreyu
Forum God
Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)

Group: Forum Members
Posts: 4, Visits: 6
hi doug,

yeah i've work out the interface already. i'll connect it thru the pc's parallel port. this might sound abit stupid, but how do the vb's drawing capability work? it is like a function where i can add directly to my code? thanks for the help. appreciate it Smile

DougT
DougT
Forum God
Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)

Group: Forum Members
Posts: 12, Visits: 99
Hi,

Here's a bit of code which demonstrates some of the "basic" graphics methods you're likely to require. (Just draw a Picturebox - Picture1 and a Command Button - Command1 , copy and paste, run and click the Command Button

Option Explicit


Private Sub Command1_Click()
Dim sngSin(0 To 360) As Single
Dim sngCos(0 To 360) As Single
Dim sngSinD(0 To 360) As Single
Dim sngScaleX As Single
Dim sngScaleY As Single
Dim sngX As Single
Dim sngY As Single
Dim PI As Single
Dim intI As Integer
PI = 22# / 7#
'
' sngScaleX and sngScaleY as their names imply, are scaling factors
' so the plots fill the Picturebox
'
sngScaleX = Picture1.Width / 360
sngScaleY = Picture1.Height / 2
'
' Draw an X axis
'
Picture1.Line (0, sngScaleY)-(Picture1.Width, sngScaleY)
'
' Put something in the arrays to plot
'
For intI = 0 To 360
    sngSin(intI) = Sin(intI * PI / 180)
    sngCos(intI) = Cos(intI * PI / 90)
    If intI <> 0 Then
        sngSinD(intI) = sngSin(intI) - sngSin(intI - 1)
    Else
        sngSinD(intI) = sngSin(intI)
    End If
Next intI
'
' Plot the Sine and Cosine waves using Pset
'
For intI = 0 To 360
    sngX = intI * sngScaleX
    sngY = sngScaleY * (1 + sngSin(intI))
    Picture1.PSet (sngX, sngY), vbBlue
    sngY = sngScaleY * (1 + sngCos(intI))
    Picture1.PSet (sngX, sngY), vbRed
    '
    ' Draw tick marks on the x-axis every 90 degrees
    '
    If intI Mod 90 = 0 Then
        Picture1.Line (sngX, sngScaleY)-(sngX, sngScaleY + 100)
    End If
Next intI
'
' Plot the Sine wave using the Line method and relative points
' (ie (sngx,sngy) are relative to the last point plotted
' so sngx will be constant, and the values in sngSinD were
' set up as relative values above)
' The Picture1.Pset statement below defines the starting point
'
Picture1.PSet (0, sngScaleY)
sngX = 1 * sngScaleX
For intI = 0 To 360
    '
    ' Plot the Sine Wave with a third of the amplitude
    '
    sngY = sngSinD(intI) * (sngScaleY / 3)
    Picture1.Line -Step(sngX, sngY), vbBlack
Next intI
End Sub

For a very simple plot, just putting the info from your ADC into an array and using something like to above should get you going.

Hope tis helps

Regards

Doug

artreyu
artreyu
Forum God
Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)

Group: Forum Members
Posts: 4, Visits: 6
thank doug. i'll try this out as soon as i finish constructing my circuit. thanks a bunch. really really appreaciate it BigGrin . btw, if you don't mind, do you have an email that i could reach you if i have further questions?

cheers

art.

Edited
9/21/2005 by artreyu
DougT
DougT
Forum God
Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)Forum God (1.6K reputation)

Group: Forum Members
Posts: 12, Visits: 99
Hi Art,

Let me know how you get on. Best to continue to use the Forum as other people may be interested / have better ideas.

Regards

Doug

artreyu
artreyu
Forum God
Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)Forum God (636 reputation)

Group: Forum Members
Posts: 4, Visits: 6
hi doug,

just wanna keep you up to date with my work. The book I'm currently referring on write its sample code in VB4. So I'm kinda having trouble trying to write it in VB6. Plan to build my ADC circuit this week and test it. Due date is looming near. Stress.

art

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search