### Author Topic: ADC measurement - Amplitude of Pulse Width in PIC uC  (Read 685 times)

0 Members and 1 Guest are viewing this topic.

#### arul

• Contributor
• Posts: 40
• Country:
##### ADC measurement - Amplitude of Pulse Width in PIC uC
« on: March 30, 2019, 01:05:11 pm »
Hi All,

I want to measure the amplitude of the given input pulse using ADC of PIC18F57K42 microcontroller.
The period time of the pulse is 1ms (1kHz). The pulse width can be varied from 1us to 1000us.
The sampling frequency of the ADC is 1391.3043kHz. The conversion time of ADC is 718.75ns.

I read the ADC in 50 times. After that I took one of the ADC value for ADC conversion. Because sometimes some noise will be present. So i took one the best ADC value using in the manner of ascending order, mode method.
If I put 100us pulse width and more mean, I got a near by ADC value. But below that pulse width of 100us mean, i didn't get the ADC value within 50 times reading of ADC. But my task is to measure amplitude of the pulse width starts from 1us onwards. Right now I got ADC value of 1us pulse width above 1000 times of ADC reading. How will I measure the amplitude of pulse width 1us within 50 times of ADC reading?

#### NorthGuy

• Super Contributor
• Posts: 2121
• Country:
##### Re: ADC measurement - Amplitude of Pulse Width in PIC uC
« Reply #1 on: March 30, 2019, 01:24:28 pm »
What is the nature of the pulse? If you only want pulse width, may be it's a good idea to digitize it with a comparator instead of ADC?

The following users thanked this post: arul

#### arul

• Contributor
• Posts: 40
• Country:
##### Re: ADC measurement - Amplitude of Pulse Width in PIC uC
« Reply #2 on: March 30, 2019, 01:39:34 pm »
Thank you #NorthGuy...

I want to measure the amplitude of the pulse width, like 100mV to 5V not pulse width... The time period is 1000us. But the pulse width (ON time) will be varying from 1us to 1000us.

#### NorthGuy

• Super Contributor
• Posts: 2121
• Country:
##### Re: ADC measurement - Amplitude of Pulse Width in PIC uC
« Reply #3 on: March 30, 2019, 02:05:40 pm »
Thank you #NorthGuy...

I want to measure the amplitude of the pulse width, like 100mV to 5V not pulse width... The time period is 1000us. But the pulse width (ON time) will be varying from 1us to 1000us.

I see. You have square pulses and need to measure amplitude of them.

Then you need to sample continuously. You need to come up with some sort of criteria which tells you if you're currently within the pulse or outside it. While within the pulse, you collect the data (say sum them up to get an average). As soon as you move out of the pulse, you calculate the final value (say by dividing the accumulated sum by the number of samples you had while within the pulse).

Your PIC's minimum TAD (from the datasheet) is 1 us. You need at least 2 TAD for sampling - 2 us. There's no way you can catch 1us pulse with this, yet alone measure the amplitude. You need a faster ADC.

The following users thanked this post: arul

#### mikerj

• Super Contributor
• Posts: 2539
• Country:
##### Re: ADC measurement - Amplitude of Pulse Width in PIC uC
« Reply #4 on: March 30, 2019, 09:52:56 pm »
Consider using a peak detector circuit to hold the peak value until it is converted, and then reset the peak detector.

The following users thanked this post: arul

#### David Hess

• Super Contributor
• Posts: 11730
• Country:
• DavidH
##### Re: ADC measurement - Amplitude of Pulse Width in PIC uC
« Reply #5 on: March 31, 2019, 02:50:25 am »
Fast discrete analog peak detectors are that fast.  It is actually easier to measure the area under the peak using a fast integrator.

The following users thanked this post: arul

Smf