Shop OBEX P1 Docs P2 Docs Learn Events
How to make a high-speed window comparator that doesn't mess with my head? — Parallax Forums

How to make a high-speed window comparator that doesn't mess with my head?

ElectricAyeElectricAye Posts: 4,561
edited 2009-07-09 16:38 in General Discussion
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. shakehead.gif
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
592 x 543 - 10K

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-07 05:14
    Mark,

    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
  • PrettybirdPrettybird Posts: 269
    edited 2009-07-07 05:48
    · The LM 311 is a good choice. Used in EDM·machinery for tunable 0n/off times··before. Pretty fast.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-07 06:21
    Mark,

    Here's a circuit (untested) that should work:

    attachment.php?attachmentid=62082

    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
    560 x 273 - 4K
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-07 13:38
    WOW! I went to bed in a grumbling despair and woke up to find these precious gems in the Sandbox.

    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
    smile.gif
  • davejamesdavejames Posts: 4,047
    edited 2009-07-07 14:33
    ...dipping my toe into the discussion.

    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)
    ·
  • kwinnkwinn Posts: 8,697
    edited 2009-07-07 15:01
    Mark, if you are using the prop to count the pulses you can get away with using only the two comparators and one flip flop, or possibly only the two comparators. The prop is fast enough to read the state of the flip flop or even the comparator outputs several times in a microsecond and reset the flip flop afterwards.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-07 15:49
    kwinn said...
    Mark, if you are using the prop to count the pulses you can get away with using only the two comparators and one flip flop, or possibly only the two comparators. The prop is fast enough to read the state of the flip flop or even the comparator outputs several times in a microsecond and reset the flip flop afterwards.

    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

    smile.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-07 16:00
    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
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-07 17:03
    Phil Pilgrim (PhiPi) said...
    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
    smile.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-07 17:36
    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.

    attachment.php?attachmentid=62094

    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
    613 x 300 - 4K
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-07 17:48
    Awesome, Phil,

    thanks for the enhancement on the flip flop window gadget. You've got me motivated to learn how this works!

    Phil Pilgrim (PhiPi) said...
    ....What are the other pins used for that you need so many of them?

    -Phil

    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
    smile.gifsmile.gifsmile.gifsmile.gifsmile.gif
  • kwinnkwinn Posts: 8,697
    edited 2009-07-08 13:09
    ElectricAye, if you are going to make a new PCB for the gamma spectrometer you may want to consider replacing the window detector with a 10 or 12 bit ADC to give you a full spectrum (multi channel analyzer). There are quite a few 10/12 bit parallel ADC's available for less than $10.00 that are more than fast enough (10-20MHz) and the prop can easily read in the ADC value and increment the memory to produce a spectrum.

    The circuitry to do this is actually somewhat simpler than the window circuits in this post.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-08 13:19
    kwinn said...
    ...There are quite a few 10/12 bit parallel ADC's available for less than $10.00 that are more than fast enough (10-20MHz) and the prop can easily read in the ADC value and increment the memory to produce a spectrum....

    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. smile.gif Maybe Santa will read my letter and build ADCs directly into Prop2???

    thanks for your help,
    Mark

    smile.gif
  • kwinnkwinn Posts: 8,697
    edited 2009-07-08 13:37
    The hardest part of working with a high speed ADC is dealing with the input signal. Using a prop makes the digital part of it very easy.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-08 14:42
    kwinn said...
    The hardest part of working with a high speed ADC is dealing with the input signal. Using a prop makes the digital part of it very easy.

    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

    smile.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-08 16:26
    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
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-09 01:54
    Phil Pilgrim (PhiPi) said...

    ....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.....

    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

    smile.gif
  • kwinnkwinn Posts: 8,697
    edited 2009-07-09 03:12
    The liquid scintollation counters I worked on did coincident counting. The signal from each PMT was connected to 2 resistors, one resistor from each PMT went to a summing circuit, amplifier, and then to the ADC. The other resistor from each PMT went to separate threshold comparators which went to an and gate that triggered the ADC. This way only pulses that were seen by both PMT's simultaneously were analyzed.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-07-09 16:03
    kwinn said...
    The liquid scintollation counters I worked on did coincident counting. The signal from each PMT was connected to 2 resistors, one resistor from each PMT went to a summing circuit, amplifier, and then to the ADC. The other resistor from each PMT went to separate threshold comparators which went to an and gate that triggered the ADC. This way only pulses that were seen by both PMT's simultaneously were analyzed.

    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. smile.gif

    thanks for the input,
    Mark

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Watching the world pass me by, one photon at a time.
  • kwinnkwinn Posts: 8,697
    edited 2009-07-09 16:38
    I doubt there is a patent on that any longer, assuming there ever was one in the first place. Nuclear Chicago had a lot of the early patents on nuclear/radiation measuring instruments, and I started working for Searle Instrumentation shortly after they bought Nuclear Chicago and renamed it. That was more than 20 years ago, and I believe (but am not absolutely certain) that patents are only good for 20 years.
Sign In or Register to comment.