How to make a high-speed window comparator that doesn't mess with my head?
ElectricAye
Posts: 4,561
Hi all you wizards out there,
I'm thinking how to make a high speed window comparator that will look at a single pulse and provide me with a SINGLE output pulse if and only if the pulse is within the window. It seems like basic window comparator circuits could possibly output double pulses if the input pulse rises well above the upper limit of the window. For example see the image I attached. Output pulses can happen on the rising edge and falling edge of a single pulse that is too large. I only want a single output pulse if the input pulse is inside the window.
I thought about some kind of latch circuit that would require a certain amount of time to set the latch so the first pulse would be avoided if the input pulse's leading edge climbed through and out of the window, and then such a latch would also latch for a length of time long enough to prevent the output of a second pulse as the same said input pulse's falling edge fell through the window. But I have no idea what I'm talking about here, obviously.
So is there a simpler way? The pulse widths I'm looking at are around 1 microsecond wide. The voltage heights are somewhere from 0.1 volts to maybe 5 volts or so. Any ideas would be greatly appreciated.
many thanks,
Mark
I'm thinking how to make a high speed window comparator that will look at a single pulse and provide me with a SINGLE output pulse if and only if the pulse is within the window. It seems like basic window comparator circuits could possibly output double pulses if the input pulse rises well above the upper limit of the window. For example see the image I attached. Output pulses can happen on the rising edge and falling edge of a single pulse that is too large. I only want a single output pulse if the input pulse is inside the window.
I thought about some kind of latch circuit that would require a certain amount of time to set the latch so the first pulse would be avoided if the input pulse's leading edge climbed through and out of the window, and then such a latch would also latch for a length of time long enough to prevent the output of a second pulse as the same said input pulse's falling edge fell through the window. But I have no idea what I'm talking about here, obviously.
So is there a simpler way? The pulse widths I'm looking at are around 1 microsecond wide. The voltage heights are somewhere from 0.1 volts to maybe 5 volts or so. Any ideas would be greatly appreciated.
many thanks,
Mark
Comments
What are the rise and fall times for the pulses that you're going to be getting? What are the voltage limits of your window? Does the width of the output pulse from the comparator matter? Are any of the pulses multimodal (i.e. having more than one peak)? Does the area under the pulse correlate well enough with the peak value that it could be used instead? This sounds like another particle detector project ... am I right?
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 7/7/2009 5:25:49 AM GMT
Here's a circuit (untested) that should work:
When the input voltage rises above the lower limit (U1b), the comparator output's rising edge clocks U2a, which drives its Q output low. If the input rises above the high limit, U1a pulses low, which instantly sets the Q output of U2a high again. When the voltage goes below the low limit, U1b's inverted (U3) output clocks whatever is on U2a's Q output into U2b. When a low is detected on U2b's Q output, it can be counted, then the /Reset input pulsed low to set it again for the next pulse.
I didn't show any pullups on the comparators. At these speeds you will probably want comparators with totem pole outputs.
-Phil
Addendum: If you were to attach the output to U2b's /Q output instead, you'd get a high-going pulse. This would be advantageous with a Propeller, since you could use a counter with feedback both to count the pulses and to perform the reset operation automatically. That way you woudn't have to watch the pin to count the pulses or do the reset in software.
Post Edited (Phil Pilgrim (PhiPi)) : 7/7/2009 6:39:00 AM GMT
To Prettybird: Thanks for the suggestion on the comparator. It looks like a good one. However, my problem is not the speed of the comparator; it's all the fun and games that must happen around it to create a window. Phil's suggestion provides some evidence that the solution is not as straightforward as I had wished.
To Phil: Oh my gawd. I'm eternally grateful for your solution. Something tells me this is the light I need to live by. But it's going to take me a while to walk through how it works. To answer your earlier questions: yes, this is another particle-type detection attempt. But I have yet to characterize the pulses just yet. All I know right now is that they're about 1 microsecond wide. I'm hoping to count up to maybe 200,000 per second or thereabouts, so output pulse width is critical insofar as the outputs do not get so long that they mess up the Propeller's ability to register them in its counters. I never dreamed I'd ever be so happy to see a flip-flop. In my one and only electronics course, the day my professor stood up and explained flip-flops was the day my eyes rolled into the back of my head and I started snoring in class. I kick myself now.
bless you all,
Mark
Seems to me that if the outputs of the comparators were sent to an AND gate, a single output pulse would be generated equal to the common "overlap' time of the two inputs.
Did that make sense?
Granted - no latched output, but a little simpler circuit.
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·
Well, my present design utilizes the Prop's counter registers, which the main program reads after exactly one second of accumulating counts. In my present design, I've maxed out the pins on the Prop, so I don't have pins left over to issue reset commands, etc. I get the impression from Phil's Addendum that his design might be able to somehow reset itself(?) after evaluating the window, but I have yet to sit down and grok the intricacies of his proposed solution. Mind you, electronics is unfamiliar territory for me, so I have to take it slow.
thanks,
Mark
How many input channels for different energy levels are you going to have? If more than one, there are ways to rearrange things to share comparators among them.
-Phil
Hi Phil,
actually my present (not so great) design has two photomultiplier modules (PMTs) with each PMT feeding its signal to a single comparator which then feeds to its own pin (counter register) on a Propeller. To scan energy levels of the pulses, I've been varying the threshold of each comparator with a digital pot and varying the high voltage (gain) of each PMT with its own digital pot controller. I had hoped the combined effort of varying the threshold and PMT high voltage supply would give reasonable resolution, which it kinda does well enough for my original project. But two things have happened: first, I've become greedy and I want a full blown gamma-ray type of spectrometer to spin out of this. Everyone has one so I want one, too. Second, I found out the hard way that simply subtracting bin averages doesn't give a decent spectrum unless I'm willing to wait around for years and years for the statistics to smooth things out. The source of that problem: just plain ole ignorance and willingness to damn the torpedoes on my part. So my new religion dictates I would do better if I had a real bona fide hardware window and not some bogus statistical kluge of my own design that chokes on the reality of Nature and her danged outrageously wild standard deviations.
thanks for your help,
Mark
Here's a revised circuit that does its own reset, rather than requiring feedback from the Prop to do it, thus saving a pin. The output pulse width is determined by the delay circuit comprised of the RC network and inverter. I've also reverted to positive logic, which makes the design a little easier to understand. Finally, I've indicated a 74F74, which is faster than the 'HC variety.
If you really wanted a deluxe spectrometer, you could use a flash A-D converter and stream 8 bits of data into the Prop in parallel, letting your Prop program interpret and bin each pulse. That way you'd have 256 channels of counts without having to acquire them one at a time. But it sounds like you don't have enough pins to do that. What are the other pins used for that you need so many of them?
-Phil
thanks for the enhancement on the flip flop window gadget. You've got me motivated to learn how this works!
As for the rest of the pins, I've got the Prop doing a lot. It has to drive 4 digital pots, a VGA output, a mouse, an SD card, provide a link to some digital thermometers, an SD card swap out switch, a Real Time Clock, EEPROM, plus 3 pins are inputs coming from the PMTs (one for coincidence counting). Most likely, though, if I follow through with the gamma spectrometer, I'll make a new PCB just for it so I'll lose a lot of the baggage the pins are now carrying.
man, you are too generous.
Thanks again,
Mark
The circuitry to do this is actually somewhat simpler than the window circuits in this post.
kwinn,
that's very interesting. It's good incentive to break down and force myself to learn how to work with ADCs. Probably I will work in baby steps at first, though, using Phil's suggestion with my present configuration, before learning about digitizing signals in a serious way. I'm also guessing that, by the time I'm ready to work with ADCs, the next generation Prop will be ready for use. Maybe Santa will read my letter and build ADCs directly into Prop2???
thanks for your help,
Mark
kwinn,
what about getting coincident counts? Would using an ADC still make it possible to somehow count when two pulses happen at the same time? Also, could the Prop be doing other things besides just holding hands with the ADC or could the main program still go off and perform other operations? Since I've never used one, I have no idea how complex an ADC system would need to be for microsecond pulse measurement.
thanks very much,
Mark
To use a "flash" ADC, as I suggested in my previous post above, you'd need at least eight pins, plus one for a clock; for coincidence counting, sixteen. So I didn't pursue it further when you revealed your tight pin budget. A serial ADC or any other kind that uses successive approximation would not be fast enough. Flash ADCs are typically used to digitize video and would work well in your app if you could eiither spare the pins or add a second Prop chip.
One thing you could do to limit processing would be to add an analog peak detector ahead of the ADC. That way, for each pulse, you'd have only to read the pulse once, rather than several times to determine the peak value in your program.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 7/8/2009 4:31:59 PM GMT
Cool. I'll keep this flash ADC concept taped to my headboard and, when time comes to get down and dirty with the spectrometer, I'll dive right in.
a thousand thanks from a perpetual newbie,
Mark
That's clever. I wonder if I'd be stomping on somebody's patent if I used that method. Any idea? I still have no feel for what makes something patentable in electronics as I have no sense of what is "somebody versed in the prior art" ...since I am not that somebody.
thanks for the input,
Mark
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Watching the world pass me by, one photon at a time.