Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Pulse duration measurement

Status
Not open for further replies.

koshary

Newbie level 6
Joined
Aug 11, 2008
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,359
How can i measure the duration of three pulses all start at the same time but each with different duration ?.
In other words how can i make three counters each start at the same time and then scan for three bits of say portA made as inputs
such that a LOW on certain bit will stop its corresponding counter and a HIGH keeps it counting.
If in mikrobasic that will be fine ,i am just a beginner that uses flowcode and starting to use mikrobasic.
 

you could connect the three signals to digital inputs and enable interrupt on change for all three.
Have a single timer running with three counters (volatile variables) which you increment (e.g. using the ++operator) on each timer interrupt.
When you get low/high transition zero the corresponding counter, when you get a high/low transition copy the corresponding counter to a variable to hold the number of timer interrupts. Knowing the timer interval you can calculate the pulse width.
 
Last edited:

There are not so many micros with 3 free timers. The solution is simpler - you have one running timer and you don't stop it. When the start of the pulses appear you read the timer value and when the end appears you read again the value. Then you subtract 2 values and you're ready. You need one start value and 3 end values in order to measure 3 different times. If you put some compensations for the reading instructions you could get all 3 times from single timer.
 

At PIC platform from Microchip, capture-and-compare module ( CCP ) can be used to achieve that feature.

+++
 

Thank you for your replies.
If i use single timer,read its value at start of pulses assigned say x then
read three values at the end of each pulse a,b,c hence durations will be a-x ,b-x ,c-x. OK
how will be the compensation or actually what is it ? (i am a beginner) pulse duration is in order of 10 ms and an error of 100us is OK if the compensation is for the delay error due to program steps.
 

How can i measure the duration of three pulses all start at the same time but each with different duration ?.

when the pulses start you start the timer no need of X
and when first goes done not timer value in A and do same of 2nd and third pulse
 

...how will be the compensation...if the compensation is for the delay error due to program steps.

If you use microcontroler built-in HW modules ( as the Capture-compare one ), the error can be minimized due to main program loop timing.
Even using I/O interrupt, such precision can be increased.

+++
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top