EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: rdagger on October 31, 2022, 04:28:23 am

Title: Counting negative pulses
Post by: rdagger on October 31, 2022, 04:28:23 am
I have an existing device that generates negative voltage pulses (about -55 to -100 mV).  Between pulses there is about +/-25 mV of noise.  I’m trying to count the time between pulses using an ESP32 microcontroller.  I tried an ADS1115 ADC, but the sampling rate was too slow.  The pulses cross the negative trigger threshold of -55 mV for only about 25-50 microseconds. 
Please recommend an op-amp, comparator, ADC or other IC for the job?
Title: Re: Counting negative pulses
Post by: MasterT on October 31, 2022, 08:25:20 am
Comparator that supports input voltage range below ground level, for example MCP6561/2 :
"Rail-to-Rail Input: VSS – 0.3V to VDD + 0.3V"
Title: Re: Counting negative pulses
Post by: rdagger on October 31, 2022, 06:07:58 pm
Comparator that supports input voltage range below ground level, for example MCP6561/2 :
"Rail-to-Rail Input: VSS – 0.3V to VDD + 0.3V"
Thanks for your help!
Here's the sample inverting circuit from the datasheet.
[attachimg=1]
It's obvious how I could set a positive trigger voltage.  Here's the Thevenin equivalent circuit:
[attachimg=2]
Where R23 and V23 are:
[attachimg=3]
The equations for trip voltages are:
[attachimg=4]
The IC does support input voltages below ground but assuming Vdd is 3.3 V, how would I set the low-to-high threshold to be a negative value such as -55 mV?
Title: Re: Counting negative pulses
Post by: AndyC_772 on October 31, 2022, 06:42:38 pm
Can the signal be AC coupled, with a positive DC bias applied on the ADC side?
Title: Re: Counting negative pulses
Post by: MasterT on October 31, 2022, 06:56:12 pm
 1. You can generate negative voltage using PWM pin,
https://www.eevblog.com/forum/projects/charge-pump-vs-lmc7660-for-negative-voltage-inverter/ (https://www.eevblog.com/forum/projects/charge-pump-vs-lmc7660-for-negative-voltage-inverter/)
 2. Use differentiator circuits at the comparator input, AC coupled as says above, biasing one input to ground and another to +54mV just slightly less than expected negative pulse. Arriving pulse would overwrite via C-R  state and trigger comparator
 But to do so we need to know more about signal and how it looks like. Diferentiator may be more complex solution than #1, with some analog wizardry
Title: Re: Counting negative pulses
Post by: Zero999 on October 31, 2022, 07:18:11 pm
(https://www.eevblog.com/forum/beginners/counting-negative-pulses/?action=dlattach;attach=1628398;image)
Title: Re: Counting negative pulses
Post by: rdagger on October 31, 2022, 07:57:08 pm
Coupling the signal with a DC bias sounds like a good idea.

I'm also looking at a couple of ADC IC's:
MCP33131D - 16-bit SAR ADC, 1-Msps, -0.3V to VREF+0.3V
ADS7142-Q1 - 12-Bit SAR ADC, 140-Ksps, -0.3V to VREF+0.3V (Programmable thresholds & hysteresis per channel.  Available breakout board.)
I like the ADC approach because it can easily be tuned in software.  Ideally the ADC would be fast, high resolution and have a comparator with threshold registers.  A programmable amp, breakout board and at least 1 software library would be nice too.  I haven't found any perfect matches.

Here are some pics of the signal:
Title: Re: Counting negative pulses
Post by: MasterT on October 31, 2022, 08:51:11 pm
For ADC route you should check out MCP39xx or ADS131mxx , both could accomodate +-1 V at inputs. They belongs to "Analog Front End" - power measurements.
Title: Re: Counting negative pulses
Post by: Benta on October 31, 2022, 10:48:36 pm
The obvious choice would be a classic signal/data slicer.
I attach an example, which is not complete in any way.
It works like this:
C1 AC-couples the input.
R1 injects a DC level from VBIAS (say, 0.3...1 V) to let the comparator work correctly (R=high-value).
The input signal is averaged by R2/C3 and sets a DC averaged input level for the comparator.

To complete the circuit. you'll need to add positive feedback (hysteresis) to the comparator, plus generate a VBIAS voltage. Both simple and a question of pennies/cents.

Cheers.
Title: Re: Counting negative pulses
Post by: MathWizard on November 02, 2022, 09:23:04 pm
I'm looking at a Grid Dip Meter schematic, and they used an oscillator that made negative pulses, and then DC coupled that into an emitter-follower for positive voltages for the MCU. They were way larger voltages than the few mV the OP is dealing with, but I bet in the old days it would be done with a couple of BJT's.
Title: Re: Counting negative pulses
Post by: Terry Bites on November 06, 2022, 11:50:53 am
An opamp differentiator (with some gain) will find the pulse edges.
Note that comparators do not like working near 0V. Ground noise, bounce and such.

See attached idea.
Title: Re: Counting negative pulses
Post by: rdagger on February 15, 2023, 07:17:13 pm
I ended up going with the TI ADS8671 (https://www.ti.com/product/ADS8671).  It's a 14-Bit, 1-MSPS, 1-Ch SAR ADC with programmable bipolar (±12/±10/±6/±5/±2.5V) input ranges.  It requires a 5V supply but the logic can run at 3.3V.  It also has an alarm pin that can fire at programmable high or low thresholds.

I couldn't find any software for it so I wrote my own libraries, and I couldn't find any breakout boards, so I designed my own.  It's working great for my project!
Title: Re: Counting negative pulses
Post by: MasterT on February 15, 2023, 08:07:35 pm
only about 25-50 microseconds. 

You can't relialble detect 25 usec pulse having 15 kHz LPF in front of the detector, since 15 kHz -> 66 usec .
At least not very accurately, 14-bits is just 0.25 mV resolution, and 55 mV pulse that is "skewed" by LPF 'd produce less than 7-bits in the noise
Title: Re: Counting negative pulses
Post by: rdagger on February 16, 2023, 01:53:01 am
only about 25-50 microseconds. 

You can't relialble detect 25 usec pulse having 15 kHz LPF in front of the detector, since 15 kHz -> 66 usec .
At least not very accurately, 14-bits is just 0.25 mV resolution, and 55 mV pulse that is "skewed" by LPF 'd produce less than 7-bits in the noise

That's a really good point.  I didn't notice but it looks like it is dropping about 5 pulses per 1000.  It probably won't affect my project, but I would like to see if I can do better.