CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2009
    Posts
    3

    Unhappy [VB 2008] Merging Different Concepts Together

    Hi Guys,

    This is my first post as I don't like to ask questions without making sure I've exhausted all other means. I'm new to VB2008 and programming in general but I'm learning. I want to do several simple tasks. Doing each separately is easy but when I put them together I don't know what to do. For one thing to work all the code must be changed and everything else doesn't work. I hope you guys can help me out as I'm really lost. I want to:

    1. Plot a graph of data from a DAQ. I can do this by using a Timer1_tick method and displaying the data on the linegraph as long as the timer is turned on. I've decided to stick with this method of acquisition. I want to acquire data for long periods of time (perhaps 3 hours) so a timer is pretty good. No problems here.
    2. Apply a filter to remove noise from the plot dynamically as the data comes in so that I get a smooth curve instead of a jagged graph. I know I can do this with for loops if I'm using an array. But how do I do it since I'm using a timer? Here the problem begins.
    3. Log every piece of the filtered data that the timer is getting to be exported to a CSV file. I learned how to do this with do loops but not with a timer or array. But I really need to use the timer this time.
    4. Acquire statistics for the data like maximum value, minimum value, and average value dynamically as the data changes. I know how to do this with an array of data after all the data is acquired. But How do I do this with a timer while the data is still being collected?
    5. Monitor the data coming in to execute an alarm (Or event, like stopping the acquisition) when the data coming in has plateaued and is constant (eg: The voltage I'm monitoring starts to become constant and becomes one constant value) - Ok I don't know anything about this.
    6. Execute a mathematical operation on the data that has been acquired (post acquisition) like finding gradients and such. Basically this means "How do I now manipulate the data I have and where is this data stored?"
    7. Know any good free linegraphs with autoscaling?

    I know these things must be a cakewalk for you guys but I'm still clueless about them as I learn bits and pieces but It's hard to put them together.

    Here's my starting code that gathers data with a timer. How do I work from here?:

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
    System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    Timer1.Enabled = False
    DAQ.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load
    DAQ.Open()
    Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Timer1.Tick
    Dim volt, Temp As Double
    volt = DAQ.ReadAnalog(Positive Input Terminal, Negative Input Terminal)
    Temp = 50 * volt
    LineGraph1.Value = Temp
    Label1.Text = Temp.ToString("0.0 Farenheit")
    End Sub
    End Class

    Thanks In Advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [VB 2008] Merging Different Concepts Together

    Separate tasks into different threads. That's the best option, but very advanced. Looks like a semester project at the end of the semester...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2009
    Posts
    3

    Re: [VB 2008] Merging Different Concepts Together

    No it's not a semester project. I am a plastics engineer and I want to study the curing of a plastic in a cheap way. So I built my own cure mapper and now I want to build the software for it to monitor the cure. But I am a plastics expert, not a programming expert, and I'm trying to merge the knowledge of plastics and programming together to solve this problem.

    I don't understand what you mean by separating into different threads. I know this has to be a simple project to do, but I can't wrap my head around it. Everything has to happen fluidly in one interface.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [VB 2008] Merging Different Concepts Together

    Write each step down, and see what tasks have to wait for other tasks to compete. You'll have things that are dependent on an outcome, and others that just have to complete a task when there's data.

    These can be theads. One can wait for a flag to fire, and the other can wait for a task complete to fire.

    Design is 90% of the solution. Your first post was a bit much

    EDIT: One thread to read the data, and load into buffer. Another thread to smooth data when it's present. Another to look for smoothed data (on a timer) and update the graph
    Last edited by dglienna; March 15th, 2009 at 11:54 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Mar 2009
    Posts
    3

    Re: [VB 2008] Merging Different Concepts Together

    Ok, so my first part is done. I can get data from the input terminals like what I wrote already in the code. This gives me the variable of volt.

    I can see that after the data is smoothed, I need to send the data into a variable eg:smoothedvariable and finally

    Temp = 50*smoothedvariable
    Linegraph.value = Temp

    So my first problem is now turning 'volt' into 'smoothedvariable'. Can I do this without much addition to the code? Where can I find an example of this?

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [VB 2008] Merging Different Concepts Together

    How about creating a Handler that fires whenever VOLTAGE changes? That way the graph would have to re-plot occasionally.

    That could also trigger other events...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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
  •  





Click Here to Expand Forum to Full Width

Featured