Tapping Car Stereo 5V Rotary Encoder

Hello,

I am trying to connect a standalone Atmega328P-PU circuit to my car stereo's rotary encoder. I've disassembled the stereo to solder two wires onto the rotary encoder's contacts already, and I've measured with a multimeter what that rotary encoder does when the car stereo is connected to the car and in normal operation; at HIGH, it's on 5 volts, and at LOW, it's on 0V.

Given that the car stereo probably already has its own built-in protection circuits, I am assuming that that means that no (transient) overvoltages or overcurrents are to be expected between the rotary encoder and the Atmega's input pins; so theoretically, I could just connect the rotary encoder directly to my Atmega, right?

Or would you still try to limit the current, or maybe step down the voltage a little bit (with a voltage divider) as well?

All I want the rotary encoder to do is trigger one of the Atmega's hardware interrupts on CHANGE.

There is a danger in having devices connected together by flying cables in a car. You need to be careful about ensuring there is a good connection between the grounds of the two.

Put 22k resistors in series with the connections (except the ground) in the radio - this will protect the radio circuitry from problems in the interconnecting wires. The radio costs (way) more to replace than the Arduino.

I have no clue what "rotary encoder " means in this context. I know what one is, but no part number was given so I wouldn't mess with it without the part number.

raschemmel:
I have no clue what "rotary encoder " means in this context. I know what one is, but no part number was given so I wouldn't mess with it without the part number.

Think about the rotary encoder-knob in the car-radio. The volume-button. A simple mechanical encoder:

// Per.

Think about the rotary encoder-knob in the car-radio. The volume-button. A simple mechanical encoder:

What ? Now we're calling potentiometers "Rotary Encoders ' ? What kind of BS is that ?

Why are you not calling it a pot-switch combo ? or a Pot with integrated switch ?

THIS is a "ROTARY ENCODER"

raschemmel:
What ? Now we're calling potentiometers "Rotary Encoders ' ? What kind of BS is that ?

And you are a dick today. Go to sleep, man!

IT'S AN ENCODER - FOR CRISTS SAKE!

// Per.

Ok, that's what I'm talking about.

Given that the car stereo probably already has its own built-in protection circuits, I am assuming that that means that no (transient) overvoltages or overcurrents are to be expected between the rotary encoder and the Atmega's input pins; so theoretically, I could just connect the rotary encoder directly to my Atmega, right?

I wouldn't. It's digital so it's compatible with opto couplers.

Rotary Encoder

Note: the logic would have to be inverted in s/w because a high input to an opto coupler yields a LOW output. The other alternative is a 7404 series logic inverter chip.

Hi,
So what you want to do is;

  • connect a 328 to the encoder output of your car wireless control (volume?).
  • use the quadrature output to measure the direction and size of any encoder movement.
  • the 328 will then depending on its input, control various outputs.

I hope you realize that you can only detect the direction of rotation and the size of the rotation.
Not the actual position or volume(?) level.

Tom... :slight_smile:

TomGeorge:
I hope you realize that you can only detect the direction of rotation and the size of the rotation.
Not the actual position or volume(?) level.

carguy:
All I want the rotary encoder to do is trigger one of the Atmega's hardware interrupts on CHANGE.

I read that as saying he only wants to see if the encoder is moved, not to see how it is moved.

Now if he wanted to actually determine in what way it is moved, I would of course tell him he should not be using interrupts for such a task. :astonished:

Hello again,

and thanks for the replies so far; I was away the last one and a half days and couldn't post.

So to clarify: I really only want the rotary encoder to trigger the hardware interrupt so that the Atmega knows that it is being turned at all. I don't want to analyze the signal from the rotary encoder, I don't want to know which direction the knob is turned. Hence, in my source code, I will put "CHANGE" as the interrupt event.

The Atmega is part of a standalone circuit that switches the radio to mute (using the radio's phone mute pin on its back side, which the Atmega will simply switch through to GND using a relay). The Atmega does this when the car is in reverse, so that the beep of the rear parking sensors can be heard better (most modern cars have this as standard). The Atmega also leaves the mute on for 30 additional seconds when the car is back out of reverse, and the mute can also be deactivated using the radio's rotary volume knob when the car is at standstill or slow speed.

And that's where connecting the radio's encoder to my Atmega comes into play. It's still in experimental stage, and my test rig so far has been to connect one of the positive terminals of the rotary encoder to the Atmega's interrupt pin. I used a 30K 0.25W metal film resistor and an 1N4004 diode on a breadboard. The diode mainly to protect the car stereo from any stray currents from my circuit board to the stereo, as the radio would cost hundreds to replace (factory sat nav with color screen).

This test rig is working. I'm only wondering if I can leave it this way, or if there's other or additional measures that I should take so it'll be well thought out.

I would use an opto coupler to provide isolation.

raschemmel:
I would use an opto coupler to provide isolation.

Not a bad idea.

And for this, it clearly is inappropriate to use an interrupt.

raschemmel:
I would use an opto coupler to provide isolation.

I am not sure the pullup-resistor on the encoder is strong enough to power the LED in the optocoupler.

You would need to buffer the signal with a transistor before the opto-LED.

// Per.

Paul__B:
And for this, it clearly is inappropriate to use an interrupt.

I forgot to mention that I want the interrupt to count the number of times the rotary encoder produces a CHANGE event. So that you have to turn the knob ten notches (which is about 1/2 revolution) within five seconds before the Atmega switches the relay off, in order to prevent accidental triggering. Time is kept using the millis() function, and the ISR routine calls a function which counts up the interrupt's change events.

I've decided to do this using one of the hardware interrupts because the Atmega is already busy constantly monitoring the car's speed signal on the other hardware interrupt, and I want the rotary encoder to have the power to override all other commands and functions if certain conditions are met. And because I've got so much other stuff going on within the loop function that it's just easier to use an interrupt for the rotary encoder to make sure the Atmega doesn't miss when the knob is turned.

If you say so then ...