PulsIn question.


Results 1 to 5 of 5

Threaded View

  1. #5
    Peter Oors's Avatar
    Peter Oors Guest


    Did you find this post helpful? Yes | No

    Red face

    Thanks very much mister_e, you are a great help.
    The text was very helpfull. The accuracy is perfect for me.

    When I measured more pulses, there was a problem.
    Something goes wrong.
    Dividing by 5 gives problems.

    =====================================
    T1ON=1 ' start Timer
    While SIGNALINPUT=0 : Wend ' wait for next rising edge
    T1ON=0 ' stop timer
    PULSElow.HIGHBYTE=TMR1H ' store results
    PULSElow.LOWBYTE=TMR1L '
    pulselow=pulselow / 5
    =====================================

    The above part I changed in (not the most beautiful way):

    Start:
    GoSub meten
    PULSEhigh1.HIGHBYTE=TMR1H ' Store result
    PULSEhigh1.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh2.HIGHBYTE=TMR1H ' Store result
    PULSEhigh2.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh3.HIGHBYTE=TMR1H ' Store result
    PULSEhigh3.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh4.HIGHBYTE=TMR1H ' Store result
    PULSEhigh4.LOWBYTE=TMR1L
    GoSub Cleartimer
    GoSub meten
    PULSEhigh5.HIGHBYTE=TMR1H ' Store result
    PULSEhigh5.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh6.HIGHBYTE=TMR1H ' Store result
    PULSEhigh6.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh7.HIGHBYTE=TMR1H ' Store result
    PULSEhigh7.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh8.HIGHBYTE=TMR1H ' Store result
    PULSEhigh8.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh9.HIGHBYTE=TMR1H ' Store result
    PULSEhigh9.LOWBYTE=TMR1L
    GoSub meten
    PULSEhigh10.HIGHBYTE=TMR1H ' Store result
    PULSEhigh10.LOWBYTE=TMR1L
    GoSub Cleartimer

    Pulsehigh1=pulsehigh1 / 5
    Pulsehigh2=pulsehigh2 / 5
    Pulsehigh3=pulsehigh3 / 5
    Pulsehigh4=pulsehigh4 / 5
    Pulsehigh5=pulsehigh5 / 5
    Pulsehigh6=pulsehigh6 / 5
    Pulsehigh7=pulsehigh7 / 5
    Pulsehigh8=pulsehigh8 / 5
    Pulsehigh9=pulsehigh9 / 5
    Pulsehigh10=pulsehigh10 / 5

    Write 1, pulsehigh1
    Write 2 ,Pulsehigh2
    Write 3 ,Pulsehigh3
    Write 4 ,Pulsehigh4
    Write 5 ,Pulsehigh5
    Write 6 ,Pulsehigh6
    Write 7 ,Pulsehigh7
    Write 8 ,Pulsehigh8
    Write 9 ,Pulsehigh9
    Write 10 ,Pulsehigh10
    Stop
    ==================================
    meten:
    GoSub Cleartimer
    While signalinput=0 : Wend ' Waiting for rising edge
    T1ON=1 ' Start timer, measure High pulse
    While SIGNALINPUT=1 : Wend ' Wait for next falling edge
    T1ON=0 ' Stop Timer
    Return
    Cleartimer:
    TMR1L=0
    TMR1H=0
    Return

    It works fine, not beautiful, I know.
    Thanks for the help.
    Last edited by Peter Oors; - 15th January 2006 at 22:07.

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. Better understanding PULSIN
    By Wirecut in forum mel PIC BASIC
    Replies: 12
    Last Post: - 29th June 2008, 10:17
  3. Funny PULSIN values: what is going on???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 30th April 2008, 08:02
  4. Pulsin Math question
    By ruijc in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd April 2008, 16:15
  5. pulsin question
    By schu4647 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 29th May 2006, 20:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts