Electronic – Current-sense for NES/SNES gamepad detection – getting a voltage spike

analogtransient-suppression

I'm in the process of designing a wireless controller receiver for the NES/SNES game consoles. My wireless receiver consists of a bluetooth module and an AVR microcontroller, with the microcontroller connected to the controller's control lines. It's designed to be installed inside the console itself, but I don't want to break support for normal controllers, so I need some way of detecting when a controller is plugged in.

The controllers themselves aren't designed with this in mind, so I've been looking into a couple of options. The NES/SNES controllers are basically nothing more than a parallel-to-serial shift register (the NES controller just uses an off-the-shelf CD4021, the SNES has a custom chip that is basically just a 12-bit version of the same thing) with pull-up resistors and membrane switches to ground on each of the parallel inputs, and the latch, clock, and data (bit 8) signals connected to the cable between the console and the controller.

Monitoring the data line doesn't do any good, because there is no way to discern between having a controller plugged in with no buttons pressed vs. no controller plugged in, so the controller isn't detected until after a button has been pressed, and there's no way to detect that the controller has been disconnected, because it appears just the same as if the controller was connected but idle.

My next option is a high-side current sense circuit, using the controller as the load. With the controller disconnected, no current flows through the sense resistor, so no voltage is dropped across it. When the controller is connected, current flows, voltage drops, current sense amp outputs a voltage. This is working fine with one exception. When I first apply voltage to the circuit, or when I connect the controller, there's a momentary voltage spike on the monitor's output line that hits roughly double the supply voltage, so that's no good. I'm not even sure how exactly that's possible, since the spike goes above the supply rail, but it's pretty clear on the multimeter.

Analog really isn't my thing so I have a feeling I'm doing something wrong. I've attached my current schematic, can anybody suggest a good way of suppressing this voltage spike? I'm not sure if a zener diode would be fast enough to handle it, and adding an RC low-pass filter onto the output doesn't help either, and just ends up lowering the output voltage. I need something, I'm pretty sure 10V will blow the ADC pin on the microcontroller. Any thoughts?

Looking at the schematic, I realize I forgot to add decoupling caps on the INA282 supply line as per the datasheet. I have them in the circuit, but I still get the spike.

Schematic

Best Answer

It seems a lot of trouble to go to when quite possibly a single resistor might work. The data output from the CD4012D shift register in the game pad will offer an impedance to the data line when it gets plugged in.

Based on this "theory", if you had a pull-up resistor in your detection module (the bit you are adding) then when the game pad is not inserted the data line will be high and, when the game pad is inserted the line will be low or, show low approximately 50% of the time it is producing data.

If you are unsure about data being high or data being low then two resistors forming a midpoint between logic rails should work - without the game pad connected, the voltage will be 2.5 V (assuming 5 V logic), and with the game pad connected, the voltage will be 0 V or 5 V.

Maybe I'm missing some subtlety?

Related Topic