-
March 15th, 2009, 09:47 PM
#1
[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!
-
March 15th, 2009, 10:34 PM
#2
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...
-
March 15th, 2009, 10:50 PM
#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.
-
March 15th, 2009, 11:51 PM
#4
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.
-
March 16th, 2009, 12:26 AM
#5
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?
-
March 16th, 2009, 09:24 PM
#6
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...
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|