Interfacing Microcontroller to controller W/ Common Ground

Started by Waterbury, April 13, 2010, 05:30:35 PM

Previous topic - Next topic

Waterbury

I'd like to interface a microcontroller to controller that has a Common Ground.  When the I/O output pin on the microcontroller is high, I don't want it to feed into the button signal I'm tapping into as usually that signal line is N/C.

My question is, will a simple diode with the cathode end at the I/O pin of the microcontroller be enough to make the output like an open-drain?

ulao

Guessing your concern is, when pressing the buttons it may draw current.  I most non logic controller its not much of a concern ( assuming your mcu has built in protection, as most do ). I have had a few controller with this occur and not harmed them. But anything with a micro controller or other delicate components in it will.  The first question is why are you setting the direction to out and hi if there is no need to?  Assuming you have a good reason for it, yes a diode should do the trick.

Waterbury

I think you misunderstood what I meant. When the I/O output is driven low, I expect it will cause a button press as it is driving the button input low. I don't expect too much current will be sunk by the microcontroller as the button input is designed to be driven low by button presses.

What I am concerned about though is the only other state of the I/O pin is high, and I want to avoid sourcing 5v+ into the button input. So I was wondering if a diode could simply allow the microcontroller to sink button presses when the line is driven low and prevent current transfer at all when the output is driven high.

ulao

Your right I did, Maybe a zener with a very low value would be better then a normal diode. I'm Interested to see what others think.

Hojo_Norem

#4
Waterbury, you don't mention what micro you are using.  By the sound of things you are wanting the I/O pins on your micro to be active low/HighZ high.  On the Atmel AVRs this is quite easy to do without the need for extra parts.  For the active low just set the relevent pin's DDR to output and it's data register to 0.  For the highZ state you set the pin to input and disable it's pullup resistor via it's data register which I think is also 0.

So in other words you can switch between the two required states by setting the pin's data to 0 and then just toggle the relevent DDR register.

When I was designing my Super Supergun I didn't know you could do this so I ended up using extra logic ICs to buffer the outputs.  Now I guess the design could be simplified greatly down to possibly just the uIC (but one with more I/O like the Mega8581)
Formerly 'butter_pat_head'

Waterbury

I'm using a PIC and I've checked through the datasheets, the best I could do is switch an output line to an input, to create a high impedance state. However, on all input pins on a PIC, a weak pull up or pull down is needed to prevent the input pin from floating. floating pins on a PIC apparently could damage the device...so back to square one.  ???

ulao

QuoteWhen I was designing my Super Supergun I didn't know you could do this so I ended up using extra logic ICs to buffer the outputs.
- ouch, I think I take my mentors teachings for granted then.


Waterbury , PIC's are week, try an avr ;) Will make things much better for you and in the feature projects to come.

Waterbury

I plan on using a different series of microcontroller in the future, but I'd like to not have to reinvent the wheel just yet.  :'(

micro

I have to admit that I've got zero experience with PICs but I've just had a quick look into the datasheet of the PIC16F690. (that's the PIC you're using for your 360 adaptor, right?)
It says that if you set the bits in the tri-state register for port a, b & c the according pin will be configured as a tri-stated input pin. And that's exactly what you want to achieve.

I also don't believe the pins will be floating as they are connected to the button input pins on the 360 controller and each button input is pulled up if the button isn't pressed (I assume)
So I don't see any problems :)

l_oliveira

Your idea of putting diodes is excellent. The controller has internal pull up resistors on the controller chip, which allows for the diode to operate correctly.

When I connected my Saturn to JAMMA interface to a common ground XBOX360 wireless controller, I needed 5v to power the Saturn controller decoder and the controller itself so I removed all battery related circuits and will use it aways connected to an Play and Charge lead, effectively making it into an sort of "faux" wired controller.

Each axis potentiomenter was replaced by a pair of 1kohm resistors. LT and RT buttons were replaced by an pair of 10k resistors to the GND. That effectively centered all the analog axis while allowing me to remove the mechanical parts to use on other controllers repair.

Because I only intend to play fighting games on that pad, it's perfect as an digital only pad.

Now, I just rigged my TTL logic board to the controller board and only a .2 volts voltage increase was measured by me on the button signal lines. So I decided to not include any kind of safety measures such as diodes or resistors. If I have problems with this setup (such as blown controller board or blown TTL chips) I'll let you know. But honestly I believe nothing will happen as no part is heating out of spec here.

In case you're still wary about this, you can just design your system around a 3.3v PIC chip, which will operate at the proper/lower voltage which I'm sure at least SNES and NES (CMOS 4021 chips) can surely deal with.