measuring pulse widths
Posted: Wed Jan 30, 2013 1:39 am
>from the help line
>What is the best way to measure pulse widths - ON pulse width and OFF pulse
width - in a pulse width modulated stream? Can you sketch a basic skeletal code?
In my case, the ON or OFF pulse can last anywhere from 500 us to 10 ms and the
pulse width carries the information.
There are built in functions that use the CPU to measure the widths. These
follow the PBASIC PULSIN function.
As these consume the CPU, they don't work for all applications.
The LPC2103 also has timer/counter hardware that can be engaged to capture a
count when pins transition. With BASIC you can read/write these registers
directly.
HWPWM uses this hardware to generate pulses, but we have not written an example
to show pulse capture.
In addition the BASIC compiler now supports general interrupts, so they can be
used when the capture occurs.
Details on the hardware are in the NXP user manual for the LPC2103.
>What is the best way to measure pulse widths - ON pulse width and OFF pulse
width - in a pulse width modulated stream? Can you sketch a basic skeletal code?
In my case, the ON or OFF pulse can last anywhere from 500 us to 10 ms and the
pulse width carries the information.
There are built in functions that use the CPU to measure the widths. These
follow the PBASIC PULSIN function.
As these consume the CPU, they don't work for all applications.
The LPC2103 also has timer/counter hardware that can be engaged to capture a
count when pins transition. With BASIC you can read/write these registers
directly.
HWPWM uses this hardware to generate pulses, but we have not written an example
to show pulse capture.
In addition the BASIC compiler now supports general interrupts, so they can be
used when the capture occurs.
Details on the hardware are in the NXP user manual for the LPC2103.