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.


  • \$\begingroup\$ @PeterJ thanks for the edit, sorry about the wall of text. It's 2:30am, I wasn't really paying attention to little things like formatting... \$\endgroup\$ – qwertymodo Nov 17 '13 at 10:37

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?

| improve this answer | |
  • 1
    \$\begingroup\$ The data line is already pulled up inside the console. The console, and by extension, the games, have no way of knowing whether or not a controller exists, which is why no controller is treated the same way as a controller with no buttons pressed. This is a polled system, so driving the data line to an undefined state is just begging for random "button presses" as a result of the undefined logic level potentially reading as logic low at random intervals. \$\endgroup\$ – qwertymodo Nov 17 '13 at 12:22
  • 1
    \$\begingroup\$ Maybe I'm still missing the point, but if your micro is in charge of detecting either rf or local game pad then your micro holds all the cards and can choose to let data through from the local game pad or let data through via the rf link. You detect the analogue voltage falling or rising to a logic level and activate an AND gateto let data through from the local source. \$\endgroup\$ – Andy aka Nov 17 '13 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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