• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

detecting pulse width using PIC

Not open for further replies.

mr. mister

New Member
hello all

i'm trying to feed the output of one channel of a 6 channel receiver into a PIC, the channel is controlled by a switch i can flick on or off

i've been told that the pulse window for the output generated by the receiver is about 20ms, hence in this case i am assuming that since the channel is controlled by an on and off switch there will only be two types of pulse widths generated

what i want to know is how do i go about using the PIC to detect one pulse width as a high and the other as a low???

as i am still quite a novice with the PIC, i understand tht i have to use the timer aspect but i don't really understand the prescaler business. How do i measure the pulse width and assign one width to be recognised as a high and the other a low?

mr. mister

New Member
i couldn't quite find a clear explanationfrom your tutorials

the problem is that i somehow need to read the incoming pulses like i explained (should be two only since the channel is operated by a switch), thing is i don't know how to read from the timer, will this be;

MOVFW count

is this correct? placing it in a file register named count?

if so, how then do i set this as the only input recognised as a high so that when the switch is flicked in the other direction it is recognised as a low and no action is taken?

thanks in advance

mr. mister

New Member
also i am aware that when the switch is flicked in the other direction, it will give a different TMR0 count due to a different pulse width

my main problem is using the program to detect one pulse width and setting it as the only recognised input

Nigel Goodwin

Super Moderator
Most Helpful Member
It's no where near as simple as that, you need to use a timer module in CCP mode, you need to study the datasheet for explanations of how that works.

But, as I mentioned previously, you can do it with a simply software loop - as my IR tutorial uses. You might also like to consult the inline book that gives a suggested replacement for the BASIC PulseIn command at http://www.dontronics.com/psbpix/pulsin.html.
Not open for further replies.

Latest threads

EE World Online Articles