Results 1 to 4 of 4

Thread: Urgent help for counting serial data using timer

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    2

    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

  2. #2

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Urgent help for counting serial data using timer

    What do you get, if anything, when you run your code?

    Any errors?

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2007
    Posts
    2

    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.

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