How can I turn on a Raspberry PI GPIO pin based on presence of ~22vdc?

TL;DR version:
I have a pair of wires with ~22vdc across them, and I want to use the presence or absence of this voltage to trigger a GPIO line on my Raspberry Pi in order to tell my program to do something. I know nothing about electronics. How can I do this?

I am working on my never-ending Seeburg 1000 project, with the goal of putting a Raspberry Pi inside to give some cool modern upgrades to the device.

Inside the machine there is an electromechanical timer that is designed to trip on once every 30 minutes, and trip off an arbitrary number of minutes after that, controlled by a knob. This allows you to set an “on time” of ~5, 10, 15, 20, 25, or 30 minutes every half hour. In short, it sets the duty cycle of the machine.

In normal operation, this will control how many songs play every half hour, and it has a clever circuit that listens to the music and doesn’t actually shut off power until it hears a gap in the record.

I want to use this timer to control my Raspberry Pi, so that even though the Pi is playing music (and injecting it into the Seeburg’s amplifier), the electromechanical timer will still start and stop the music. I don’t want to modify anything–I am using the existing jacks of the device for everything.

There is a RCA jack on the back (labeled J103C on the schematic below) that is for externally controlling the timer switch in case you have an external audio feed you want to use and don’t want the record turning. If the jack is shorted with a jumper, the timer functions normally. If you unplug the jumper, the machine turns on, the timer turns, but the motor relay never closes and the record doesn’t turn–this is the normal “external audio” mode.

I would like to hack this jack. Though it is really intended as an input control, I believe I can detect the timer’s current on/off state from the jack. It appears to have ~22 vdc present when “on” and 0 vdc when “off”.

Here is a highlighted schematic showing what I’m looking at. I have drawn lines showing where I think the voltage is coming from.

Here’s the parts list, if the resistor values are relevant.

I will leave the jumper off, since I don’t want the record to turn, but I want to detect the ~22v that appears when the timer is in the “on” cycle. I will use this to enable a GPIO pin that will be sensed by my code and start or stop the music, just as if I were actually playing records on the machine.

Use an optoisolator, or a transistor with the correct base resistor.

Remember, I know nothing about electronics.

Would an optoisolator be a drop-in part with no other components needed? What about the transistor, which kind and how do I determine the resistor, and which legs hook up to where?

A link to a photo of a rough pencil sketch of this on a napkin would be helpful.

OK, hang on.

What’s the allowable range of the high signal on the GPIO? I’d use a simple regulator that had at least a 22 volt input but outputs whatever the GPIO high is.

For example, if 5 VDC works, you could use this:

It will output 5 volts at inputs up to 35 volts.

Do not do that, please.

Here you go:
Shared with CloudApp

The grounds can probably be connected, but since you are optically isolating, it might be nice to keep everything separate.

The right way is beowulff’s optoisolated circuit. The quick-and-dirty way, if you have connected grounds, is to just use a resistive voltage divider:
22 V signal → 100k resistor → GPIO input → 10k resistor → gnd

That divides the 22 v down to 2 v, which is compatible with the RasPi input. But it does require the ground to be connected, which you may not want.

Now that is helping a friend out. Very cool.

With my meager electronics knowledge I had been thinking of either a simple voltage divider or some kind of regulator approach (with a little hand waving added), but just don’t know enough to understand the pros and cons.

I’ll use the optoisolator approach and keep the grounds disconnected for a couple of reasons: For starters, the voltage on the Seeburg is -22vdc with respect to ground, so as long as I don’t have to connect the grounds, I just call that “ground” and use the chassis ground as the +22vdc.
The second reason is that the voltage appears to be directed to the coil of the motor relay–the jumper on the jack provides a path to ground for the current coming from the coil–so I just don’t want to worry about inadvertently letting enough current flow to trip the relay or having any weird stuff happening with the Pi because of that coil.

Thanks to everyone who answered, it’s awesome when folks with knowledge in the field give solid advice to a hobbyist like myself.

It’s always good design practice to isolate delicate electronics from older, high-voltage ones. It only takes a few µS at 5-7v to destroy the port pin (and possibly the entire processor) of the Pi.
Also, if you are dealing with audio, it’s nice to isolate the digital part to keep potential interference at bay.

I want to congratulate the OP on the most specific question I have ever read here, and on beowulff ’ and others very specific fast answer. My hat is off!

:astonished: :cowboy_hat_face: :clap: :+1:

That stuff is cheap as chips. I just ordered a handful of resistors, optoisolators, and a few old-school terminal lug strips. Looking forward to getting this up and running!

I can tell you MIDI connectors use opto-isolators. I have used them too as part of some DIY laboratory electronics.

Yes - the qty 1 price for the optoisolator is under $0.60.