0
\$\begingroup\$

I'm looking to build a simple DC voltage comparison circuit that outputs a logic high or low depending on the input, say when it rises above 2V.

From my admittedly rudimentary understanding of op-amps, if I put my input signal at Vin, a 2V source at Vref, a 5V source at Vcc+, and ground Vcc-, Vout should output between 0 to 5V.

What confused me though is in all the examples I've seen of this setup, Vcc+/- are always equal but opposite (i.e. +5V and -5V). Is it possible to achieve this effect with Vcc- grounded, or am I misunderstanding how this circuit works?

Thank you for your help.

comparator circuit


Clarification - So to summarize my overall project, I'm trying to add "Turbo Button" functionality to an old Sega Nomad (the handheld version of the 90's Sega Genesis/Mega Drive). "Turbo Mode" was a feature on some third party controllers; when enabled, you could hold down a trigger button (A/B/C/X/Y/Z) and the system would act as if you were rapidly and repeatedly pressing it (good for shooters where "mashing" the fire button would fire faster than just holding the button down).

Note that I haven't been able to confirm exactly how the original turbo controllers work; info online is scarce, and the three controllers I own (all by different manufacturers) all use chip-on-board circuits, so there's nothing to see inside but a big blob of epoxy.

Sega Nomad (left), 6-Button turbo Controller (right)

To quick explain the system's controls, there are a total of 12 buttons (4-way D-Pad, 6 "triggers"(A/B/C/X/Y/Z), START and MODE) which are all simple membrane buttons that short their respective signal line to ground. These signal lines feed into a multiplexer, which has a "select" line that is pulsed by the CPU either once or three times per frame depending on the game. The Genesis originally released with a 3-button controller (A/B/C), but late in its life had an updated controller with 6 buttons (A/B/C/X/Y/Z) which used three "select" pulses. The MODE button was included for the small handful of games that had compatibility issues with the 6-button controller; holding it down at startup would force the controller into 3-button mode. This is important because the MODE button is otherwise unused, and is thus a free signal line for modders.

My original design uses an SPDT switch at each button to individually enable/disable turbo mode; one switch leg goes to ground for normal button functionality, the other leg connects to ground through an analog switch IC, controlled by the multiplexer's select line via a T flip-flop. The select line's pulse should toggle the flip flop, opening/closing the analog switch every other frame, thus "pressing" the button as fast as the system can possibly read it:

Basic turbo btn mod idea

I haven't tested this idea yet, but it seems pretty sound. I've ordered a cheap oscilloscope and should have it soon so I can verify the multiplexer's select line (the Nomad uses a proprietary chip for it, so no datasheet is available - all I have to go off of is this pinout).

The problem with this design is the physical SPDT switches: I don't want to cut holes in the system and have a bunch of ugly switches sticking out. My work-around idea is to use analog SPDT switch ICs, and toggle each button's turbo mode by using a combination of the system's existing buttons; i.e. MODE and the respective trigger button (A/B/C/X/Y/Z). I can use a NOR logic gate to detect when the buttons are pressed (both lines will go low), but the problem is once turbo mode is enabled, the trigger button's line will be connected to the clock and the pulsing will immediately shut turbo mode right back off, since the user won't reliably be able to press the button for a short enough period of time (at 60FPs, it'll be a 30Hz 50% duty cycle square wave).

The rough idea I have is to convert the clock signal to a steady logic high/low before it goes to the NOR gate (based on this post with a similar problem), in order to prevent it from immediately toggling turbo mode. A WIP sketch of the solution is below, but it's not right, there would need to be an inverter after the "clock converter" since it's passing logic high when A is pressed... I'm still working on it.

turbo enable via soft switch wip

Even if it does work though, it's really not an ideal solution. It adds a lot of extra parts when you consider it needs to be duplicated to all 6 trigger buttons... If I could find an SPDT IC that has a built-in toggle feature though (instead of requiring a continuous signal to stay closed), I could eliminate all the flip-flops and greatly reduce the component count, but I haven't found anything like that so far.

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

First, you want a rail-rail device. These are pretty common these days.

Second, you've already used the key word in your question title: you want to use a comparator, not an op-amp. They're common, and not every op-amp is mild-mannered when you ask it to be a comparator. A comparator will do what you expect, because it's made to be exactly that.

Note that, as drawn, you want a comparator with a push-pull output -- they also come with open-collector (or open-drain) outputs; as drawn, that wouldn't work in your circuit (but might, if you equipped the thing with a pullup resistor).

Better yet, get a comparator with an output that matches the logic you're going to drive with it. These days that usually means a CMOS output (older comparators would have a TTL, open-collector, or odder things).

Any of the on-line vendors will have a good selection of comparators.

\$\endgroup\$
8
  • \$\begingroup\$ Hi, thanks for the quick reply! So if I'm understainding correctly, I want a push-pull output type as they don't need a pull up resistor, and rail-rail types have outputs closer to VDD/VSS, so maybe one like this? digikey.com/product-detail/en/microchip-technology/… \$\endgroup\$ Commented May 30, 2019 at 17:08
  • \$\begingroup\$ The rail-rail term can be misleading. For op-amps, rail-rail can either mean the input or the output, and if it's just stated to be "rail-rail" you need to look at the datasheet carefully. For comparators, rail-rail usually means that the inputs are good from rail-rail. Both op-amps and comparators can suffer from not working if the inputs are outside of some voltage range (known as the "common-mode range"). "Rail-rail input" means that the common mode range extends from -VCC to +VCC. \$\endgroup\$
    – TimWescott
    Commented May 30, 2019 at 17:16
  • \$\begingroup\$ I've edited my answer to give guidance for the output type. \$\endgroup\$
    – TimWescott
    Commented May 30, 2019 at 17:17
  • \$\begingroup\$ No need to apologize -- op-amps and comparators seem to be simple, but there are all sorts of complexities lurking under the surface. You haven't mentioned what you want to drive with the comparator, so I can only assume you want rail-rail output. "Logic low" and "Logic high" are not at the rails -- the chips are built so that an input that's close to, but not at, the relevant rail still counts as a definite one or zero (speaking of hidden complexities). If you want to be sure, read the data sheets of all the parts. \$\endgroup\$
    – TimWescott
    Commented May 30, 2019 at 17:55
  • \$\begingroup\$ I deleted my response and was about to rewrite it, but you already responded ;). I think I understand; so in my case, since my input signal will always be within 0-2.5v (which I didn't originally specify), rail-rail input would be acceptable. The comparator will ultimately be driving an analog switch. My overall project is a modification to an old handheld game system to add "turbo button" functionality (the ability to hold down, say, the "A" button, and the system treats it like you're pressing the button repeatedly). I can add a diagram of my current plan if desired, comments are too short \$\endgroup\$ Commented May 30, 2019 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.