Hello all,
This is kinda long but please bear with me.
Am new to the VB platform and have only been messing around with 2008 for a few months,off and on.
Have built a rotational inertia based Dynamometer for personal use in my R/C hobby.Have written some code that allows me to read roller frequency,that is then figured to roller RPM,and eventually ,vehicle ground speed.
Now before anyone shoots me down,( I don't mean this to be sarcastic,but I have received negativity on other forums) I know that ,because of various interupts on my P.C.,that the windows timers aren't all that accurate,causing me to miss incoming signals that screw up my measurements, and the best thing is an external aquisition unit.Let me just say that I run my VB program parallel to an external frequency counter,and have at any given time a difference of max. 8 hz at higher revs.Also I use an external timer based counter that figures the ground speed ,and it also is within a half KmH.This is only a hobby for me and that's close enough.Someday I may build something that does the computing externally and gives it to VB,but for now.........
So now to the good part
Here’s my question:
How can I write code that will let me record the RPM ,from TextBox2, at each timer interval,and have them listed?
I need this to calculate the RPM changes per interval in order to establish "angular acceleration" ,for further calculations.
In Addition,I need a way for my program to know when something changes or does'nt.If I start my programm and don't run the dyno ( no signals) then it will start saving a bunch of zero's that I don't need,and when I get to the end of the run,the RPM will top off(no change in signals)but keep saving.The best would be,start recording when the 1st signal is detected and stop recording when the signals stop changing, and tell me I can stop.
But I'm not that advanced.........yet.
The next problem is that I have no idea,depending on what vehicle I test, how many intervals will be recorded, as one may or may not take longer to reach max.RPM.
Heres what I have so far:
Public Class Form1
Dim product1 As Double
Dim product2 As Double
Dim product3 As Double
Dim product4 As Double
Dim Fx As Double
Dim impulse As Integer = 1
Dim interval As Integer
Dim imp_count As Integer = 0
Dim RPM As Double
Dim time_sec As Integer
Dim updatetext As Integer
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 1000 'set the time interval'
Timer2.Interval = 1000
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SerialPort1.IsOpen = False Then
SerialPort1.Open() 'open the port for access'
Timer1.Enabled = True
Button1.Text = "Stop"
Else
SerialPort1.Close()
Timer1.Enabled = False
Timer2.Enabled = False
Button1.Text = "Start"
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
TextBox2.Text = (TextBox1.Text * 60) / 6 '(Fx x 60sec.)/ hole=RPM
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If impulse > 0 Then
imp_count = (imp_count + 1)
End If
Fx = (imp_count)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Timer2.Enabled = True
updatetext = Fx
Me.Invoke(New EventHandler(AddressOf TextUpdate))
End Sub
Private Sub TextUpdate(ByVal sender As Object, ByVal e As EventArgs)
TextBox1.Text = updatetext
TextBox2.Text = updatetext
TextBox3.Text = updatetext
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer1.Enabled = True
imp_count = 0
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
product1 = (TextBox4.Text * 3.141592654) * TextBox2.Text 'circumferance x RPM = cm/min
product2 = product1 / 100 'meter/min
product3 = product2 * 60 'meter/hour
product4 = product3 / 1000 'Kmh
TextBox3.Text = product4 'Displays speed
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
End Class
This is kinda long but please bear with me.
Am new to the VB platform and have only been messing around with 2008 for a few months,off and on.
Have built a rotational inertia based Dynamometer for personal use in my R/C hobby.Have written some code that allows me to read roller frequency,that is then figured to roller RPM,and eventually ,vehicle ground speed.
Now before anyone shoots me down,( I don't mean this to be sarcastic,but I have received negativity on other forums) I know that ,because of various interupts on my P.C.,that the windows timers aren't all that accurate,causing me to miss incoming signals that screw up my measurements, and the best thing is an external aquisition unit.Let me just say that I run my VB program parallel to an external frequency counter,and have at any given time a difference of max. 8 hz at higher revs.Also I use an external timer based counter that figures the ground speed ,and it also is within a half KmH.This is only a hobby for me and that's close enough.Someday I may build something that does the computing externally and gives it to VB,but for now.........
So now to the good part
Here’s my question:
How can I write code that will let me record the RPM ,from TextBox2, at each timer interval,and have them listed?
I need this to calculate the RPM changes per interval in order to establish "angular acceleration" ,for further calculations.
In Addition,I need a way for my program to know when something changes or does'nt.If I start my programm and don't run the dyno ( no signals) then it will start saving a bunch of zero's that I don't need,and when I get to the end of the run,the RPM will top off(no change in signals)but keep saving.The best would be,start recording when the 1st signal is detected and stop recording when the signals stop changing, and tell me I can stop.
But I'm not that advanced.........yet.
The next problem is that I have no idea,depending on what vehicle I test, how many intervals will be recorded, as one may or may not take longer to reach max.RPM.
Heres what I have so far:
Public Class Form1
Dim product1 As Double
Dim product2 As Double
Dim product3 As Double
Dim product4 As Double
Dim Fx As Double
Dim impulse As Integer = 1
Dim interval As Integer
Dim imp_count As Integer = 0
Dim RPM As Double
Dim time_sec As Integer
Dim updatetext As Integer
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 1000 'set the time interval'
Timer2.Interval = 1000
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If SerialPort1.IsOpen = False Then
SerialPort1.Open() 'open the port for access'
Timer1.Enabled = True
Button1.Text = "Stop"
Else
SerialPort1.Close()
Timer1.Enabled = False
Timer2.Enabled = False
Button1.Text = "Start"
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
TextBox2.Text = (TextBox1.Text * 60) / 6 '(Fx x 60sec.)/ hole=RPM
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
If impulse > 0 Then
imp_count = (imp_count + 1)
End If
Fx = (imp_count)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Timer2.Enabled = True
updatetext = Fx
Me.Invoke(New EventHandler(AddressOf TextUpdate))
End Sub
Private Sub TextUpdate(ByVal sender As Object, ByVal e As EventArgs)
TextBox1.Text = updatetext
TextBox2.Text = updatetext
TextBox3.Text = updatetext
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer1.Enabled = True
imp_count = 0
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
product1 = (TextBox4.Text * 3.141592654) * TextBox2.Text 'circumferance x RPM = cm/min
product2 = product1 / 100 'meter/min
product3 = product2 * 60 'meter/hour
product4 = product3 / 1000 'Kmh
TextBox3.Text = product4 'Displays speed
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
End Sub
End Class
Last edited: