Menu

PWM measuring: 0ms - 1ms

Help
2008-01-19
2013-05-30
  • Nobody/Anonymous

    Hello,
    I'd like to decode the PWM signals from a R/C receiver and then output a separate PWM signal to some gearbox motors.
    After much searching in order to actually get the width of the pulse from the receiver, I found a post by Hugh with the following snippet:
    ----
    PulseLength = 0
    do while PORTB.0 ON
    PulseLength = PulseLength + 1
    IF PulseLength = 0 then goto PulseTooLong
    Wait 1 ms
    loop
    PulseTooLong:
    ----
    I remember reading that the measure pulse can be between 0 - 255 ms with accuracy of 1ms. The problem is that the outputted pulse from the receiver is about 0-1 ms.
    I am wondering, is there any way I can measure the pulse more accurately with GCB? Perhaps I am overlooking something in the code above, and would greatly appreciate any help!

    Thank you!

     
    • justingra

      justingra - 2008-01-20

      If you replaced "Wait 1 ms" with "Wait 100 10us" you should be able to get more accuracy.  The units are 10us, which are predefined in GCB.  The first parameter to wait can be between 0 and 255.  If you need even more accuracy, you can use just "us" but remember to keep you values between 0 and 255. 

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.