Counting negative pulses - Page 1
Forum section: electronics / beginners

author: rdagger
author_rank: Contributor
timestamp: October 31, 2022, 04:28:23 am
content: 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?

author: MasterT
author_rank: Frequent Contributor
timestamp: October 31, 2022, 08:25:20 am
content: Comparator that supports input voltage range below ground level, for example MCP6561/2 :"Rail-to-Rail Input: VSS – 0.3V to VDD + 0.3V"

author: rdagger
author_rank: Contributor
timestamp: October 31, 2022, 06:07:58 pm
content: Quote from: MasterT on October 31, 2022, 08:25:20 amThanks for your help!Here's the sample inverting circuit from the datasheet.It's obvious how I could set a positive trigger voltage. Here's the Thevenin equivalent circuit:Where R23 and V23 are:The equations for trip voltages are: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?

author: AndyC_772
author_rank: Super Contributor
timestamp: October 31, 2022, 06:42:38 pm
content: Can the signal be AC coupled, with a positive DC bias applied on the ADC side?

author: MasterT
author_rank: Frequent Contributor
timestamp: October 31, 2022, 06:56:12 pm
content: 1. You can generate negative voltage using PWM pin,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 comparatorBut 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

author: rdagger
author_rank: Contributor
timestamp: October 31, 2022, 07:57:08 pm
content: 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.3VADS7142-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:

author: MasterT
author_rank: Frequent Contributor
timestamp: October 31, 2022, 08:51:11 pm
content: 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.

author: Benta
author_rank: Super Contributor
timestamp: October 31, 2022, 10:48:36 pm
content: 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.

author: MathWizard
author_rank: Super Contributor
timestamp: November 02, 2022, 09:23:04 pm
content: 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.

author: Terry Bites
author_rank: Super Contributor
timestamp: November 06, 2022, 11:50:53 am
content: 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.

author: rdagger
author_rank: Contributor
timestamp: February 15, 2023, 07:17:13 pm
content: I ended up going with theTI 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!

author: MasterT
author_rank: Frequent Contributor
timestamp: February 15, 2023, 08:07:35 pm
content: 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

author: rdagger
author_rank: Contributor
timestamp: February 16, 2023, 01:53:01 am
content: Quote from: MasterT on February 15, 2023, 08:07:35 pmThat'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.