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!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!
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.