Using a Photo Interrupter with a game controller.

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
Hello all, let me preface this by saying that my knowledge of electronics is rudimentary at best. I build arcade machines as a hobby and in doing so have learned how to solder and have messed with simple circuits and leds and what not. But I cannot read circuit diagrams well ect... So with that being said. Here is what I'm looking to do.

I would like to wire a photo interrupter to work as a button (momentary switch) on a gamepad. Basically if the path is interrupted the button is pressed or closed and if the path is clear the button is not pressed or open. What I'm trying to figure out is the wiring. I have attached an image of the interrupter I will be using.

It has 3 pins. VCC, GND and OUT. I know that VCC is 5v, GND is ground and Out would be the signal line.

Here comes the issue. The gamepad is USB thus I can tap the 5v off of that. But the ground for the 5v usb coming in and the ground to complete the button circuit are not the same...

I'm assuming to power the interrupter I must use the 5V+ form the usb cable and the black ground wire to power the unit. So then I assume the OUT pin on the interrupter would be used for the signal pin of the button I want to use.

Can I connect the ground of usb power and the ground for the button on the same pin without causing an issue? Would this be the right way to wire this?
I have attached a crude drawing of what I mean...

Thanks.

diagram.png
 

wayneh

Joined Sep 9, 2010
16,384
Can I connect the ground of usb power and the ground for the button on the same pin without causing an issue?
You're right to ask, because there is a possibility that the answer is "No". I'd say the odds of a problem are low, but connecting the grounds of power supplies is not 100% safe when both supplies are not completely isolated from mains power. That ground connection might complete a circuit and allow a large and damaging current to flow.

This cannot happen if one of the supplies is fully isolated, such as battery powered. But if both supplies are mains-powered, I always like to test by first making the connection with a 1KΩ resistor and looking for a voltage across that resistor. If you don't see more than a couple millivolts, go to a smaller resistance value, maybe 470Ω and look again. If little or no current is flowing, then it's probably OK to make the connection. I say probably, because I think there can still be issues with the voltage regulators of two supplies putting noise on the ground line that can confuse each other. Hopefully someone here can educate us on that issue.
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
Hey thanks for the response! So if I were to power the Interrupter with batteries then it shouldn't be a problem? Not that I want to. But if its an option as a workaround I would consider it...
 

wayneh

Joined Sep 9, 2010
16,384
Hey thanks for the response! So if I were to power the Interrupter with batteries then it shouldn't be a problem? Not that I want to. But if its an option as a workaround I would consider it...
Correct, connecting a battery ground to that existing circuit would be risk-free. I really think you could get away with the USB power as well, but there is a risk of damage the instant you make the connection. If you test as I described, you can virtually eliminate that risk. It just depends how badly you want to use the USB power source instead of a battery. Personally, I'd be tempted to make it work first with a battery and then see if replacing the battery introduces any problems.
 

MaxHeadRoom

Joined Jul 18, 2013
20,403
If you have a separate GND for the P.B. then where is the associated power for this P.B. GND coming from? It implies two supplies? Or is it not really a GND or common?
Max.
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
If you have a separate GND for the P.B. then where is the associated power for this P.B. GND coming from? It implies two supplies? Or is it not really a GND or common?
Max.
Its one power supply, just the power from the USB cable that is powering the controller. However, if I connect the ground wire (black) from where the USB cable comes in to the controller to a signal pad for one of the buttons I do not get a connection for that button. So I may be using the terms incorrectly. Each button has two pads one for the specific button signal and a second one which I'm calling a ground as they are the same on all of the buttons. When touching a signal pad (circled in blue in the diagram) to what I'm calling a "ground" (Circled in red in the diagram) I get a connection for that button. But connecting a signal to the ground wire from the USB cable doesn't not make a circuit...

Please forgive me if I'm explaining this poorly, its hard to put into text...
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
Each button signal pad has a corresponding "ground" pad. And the ground pads are all the same. Meaning I can connect any siganl pad to any "ground pad" and get a connection for that signal pad. However the ground pad on these buttons is not the same ground as the black ground wire coming in from usb...
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
What polarity does the PB GND have WRT to USB 5v?
Can you see what device the PB signal is connected to?
Max.
Sorry buddy some of your abbreviations are lost on me... PB= Push Button? What does WRT mean?

I did notice when connecting the Green wire coming in from the USB cable to the signal from the buttons. I get a connection... I think the green wire on usb is either data+ or data- depending on the diagram I look at online... Don't know if that helps. I'm at work right now and the controller is at home so I can test polarity on anything right now...

Thanks for trying to help though...
 

MaxHeadRoom

Joined Jul 18, 2013
20,403
Push Button- With Respect To>
If there is no other source of power, it has to come from the USB 5v from the source (PC? etc).
Max.
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
Thanks. Yes its a game controller connected to a PC via a usb cable. The controller is a standard Microsoft xbox 360 wired controller.
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
So I experimented with this last night. I hooked the 5v (VCC) and ground (GND) from the USB cable to power the Interrupter. I connected the Signal line (OUT) from the interrupter to one of the buttons signal pads. If I connect the "ground" of the button to the USB ground as I put in the diagram above... the controller errors and resets so we know that wont work...

But I tried simply hooking the 5v and ground from the USB cable coming in to power the interrupter and then simply hooked the signal line (out) to the signal line of one of the buttons and oddly enough the photo interrupter works as a switch only it works Normally closed instead of normally open. When I connect the two signal wires the button goes on and stays on until I interrupt the beam. This is the opposite of what i'm looking for.

When I bought these interrupters they said they were normally open, perhaps its the way it wired that's making it behave this way...
 

Thread Starter

Chubbyboy

Joined Feb 4, 2020
10
Thanks for all the help guys. Seems this is just more work than its worth. I was going to try to use the interrupter to detect a coin passing through for an arcade machine. I thought a photo interrupter would be more reliable... But I think I'll try to make a simple leaf switch that the coin will trigger when it hits it instead.

Thanks for the time...
 

MaxHeadRoom

Joined Jul 18, 2013
20,403
The interupters themselves are usually ON or conducting until the window is blocked.
There is a IC on the board you have so it could be inverted?
What is the part No. of the actual interrupter on the board?
Max.
 

Bernard

Joined Aug 7, 2008
5,460
Measure voltage across a push button switch & note polarity & voltage. If there is V a logic level
FET might work as a SW if driven with bare bones interrupter. Let's call SW "ground" -common.
 
Top