Pulse width measurement and time measurement

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

For a distance sensor I plan to use, I need to measure the width of a pulse that the sensor will output that is proportional to the distance. In general, is there some way for me to measure elapsed time with a resolution of micro or milli seconds? I will probably need to measure time for a related application. I couldn't readily find anything in the WICED SMART SDK documentation.

Any pointers are greatly appreciated.

Thanks!

Arvind

0 Likes
1 Solution
Anonymous
Not applicable

Thanks JT and boont! I'll play around with the options above, but I suspect I'll need some hardware changes.

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable

Hello Arvind,

  1. The proximity app and the hello_sensor app are great places to start in the SDK
  2. Using a rtc_sample with an external 32K xtal should be used when accurate time is needed.

Thanks

JT

0 Likes
Anonymous
Not applicable

Thanks, JT. I couldn't find anything useful regarding accurate time measurement in proximity or hello_sensor-- please point out anything I may have missed there.

Looking at the rtc_sample, I found this function rtc_getRTCRawClock() which seems to return a 48-bit value. The exact meaning of this value is not obvious. I'll need to solder a couple of shorts on the eval board to test what the raw value represents. Also from the 32 KHz frequency, I'm assuming the highest resolution I will get will be around 1/32e3 ~ 31 us. Does that make sense?

Arvind

0 Likes

This thread explained a little on the use of rtc_getRTCRawClock.

Resetting RTC internal counter

0 Likes
Anonymous
Not applicable

Hello Arvind,

After checking with the developers, this is the summary they provided:

1.  Unfortunately there is no easy or accurate way to address your particular use case.

2.  If the edges are many mS apart, then it may be possible to use a state machine and associate rising/falling edge interrupts and different RTC time stamps.

3.  If the pulses from your sensor are short, you could poll the GPIO state, but this will not be very accurate

4.  The scenario mentioned in number 3 above would involve something like polling a GPIO value for a while until level changes twice every fine timer callback.

We hope this gets you started.

Thanks

JT

0 Likes
Anonymous
Not applicable

Thanks JT and boont! I'll play around with the options above, but I suspect I'll need some hardware changes.

0 Likes