Urgent help for counting serial data using timer
Hello all,
I am a newbie and i am totally lost.Do help me.
I want to accurately find baud rate.
I have already programmed such that if i send character 'i' i get some value from my microcontroller.
But the problem is i dont know how to program this:
In 10 sec, how many times I can transmit 'i' and receive data.
I thought all i have to do is set a timer that counts till ten and in the meanwhile transmit 'i' but i found that the timer does not seem to work parallely at all.
here is the code which dint work.
Code:
Public Class Form1
Dim i As Integer
Dim count As Integer
Dim txt As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Private Sub calculate_transmit()
Do While i < 10
SerialPort1.WriteLine("i")
txt = SerialPort1.ReadChar
count = count + 1
Debug.Print(txt)
Loop
Debug.Print("total 'i' sent = ")
Debug.Print(count)
End Sub
Private Sub Form1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Click
calculate_transmit()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
i = i + 1
End Sub
End Class
Re: Urgent help for counting serial data using timer
http://www.vbforums.com/attachment.p...id=47243&stc=1
It looks like you are using VB.Net so I've move your thread to here.
Re: Urgent help for counting serial data using timer
What do you get, if anything, when you run your code?
Any errors?
Re: Urgent help for counting serial data using timer
Well the value "i" from the timer routine which I use to check in calculate_transmit() routine remains always 0 !!
And the loop in the calculate_transmit() happens infinitely as i<10 is always true.