sunnuntai 10. heinäkuuta 2016

Modding car stereo head unit with Arduino and Raspberry Pi: Part 2

Now that the Arduino (Nano 3.0) is able to control everything that we need, I wrote some software on it.

I think I'll publish the source code later, but here's what the connections ended up being:

const int PIN_LED = 13;
const int PIN_MAIN_POWER_CONTROL = 4;
const int PIN_LCD_CE = 7; // <- LC75854E
const int PIN_LCD_CL = 8;
const int PIN_LCD_DI = 9;
const int PIN_LCD_DO = 10;
const int PIN_ENCODER1 = A0; // <- The digital potentiometer
const int PIN_ENCODER2 = A1;
const int PIN_VOL_CE = 11; <- LC75421M
const int PIN_VOL_DI = 12;
const int PIN_VOL_CL = 13;
const int PIN_STANDBY_DISABLE = 5;
const int PIN_RASPBERRY_POWER_OFF = 2;
const int PIN_IGNITION_INPUT = A2;


MAIN_POWER_CONTROL powers up the volume controller and LCD backlight. These controls were originally 5V, so they can be just wired directly to the Nano. It goes through some resistors and transistors which turn on the beefier regulators on the original circuit.

STANDBY_DISABLE disables the TA8272H power amplifier standby mode (that is, it just goes to the STBY pin).

IGNITION_INPUT senses the incoming "ignition" signal which is controlled by the ignition key, so that things can be automatically turned on and off with the rest of the car.

The Nano is fed constant power from battery voltage, and is never switched off (*). It has three modes: POWER OFF, AUX and RASPBERRY. The modes are cycled by pressing the power button, which is queried from the LCD controller which also stays powered in all modes - just like it originally does; it uses a fraction of 1mA even in full operation. When in POWER OFF mode, the Nano switches everything off, and in other modes it switches everything on.

(*) This results in a shutdown power consumption of like 20 to 30mA, which will drain the main battery in a couple of weeks. It's fine enough for now, but in the long term I should probably remove the power LED from it and use the maximum clock divider when in POWER OFF mode; this should result in just a few mA for the AVR. What would then remain is the Nano's CH341 USB serial chip which is always powered on and probably takes something like 5 or 20mA. Not sure. In any case, it might be possible to cut some of the PCB traces to it to make it only powered when USB power is present. This might be a future subject.

...

What now? Well, we have to be able to control this thing somehow.

And actually not just somehow; I want a better user interface than is commercially available in this price range. Take a look at the front panel here:


Now, here, importantly, the previous functions of the buttons are completely irrelevant. We can do *anything*, and I have specific preferences when it comes to this:
  • The knob must control volume in the default state in all modes
  • Pressing the knob must be always related to whatever turning the knob does
  • Track switching must be allocated to large buttons
  • Album switching must be allocated to large buttons

It is wise to split the controls statically into two parts, one of which will control the Nano, and the other part will control the Raspberry Pi.

As the Nano will control of the volume, we allocate the digital potentiometer to it, and also the button that is pressed by pressing the knob. And that's it; nothing else is needed except the knob and the power button. There will be an options menu that comes up with a long press of the knob for bass, treble and some other special options.

After writing more software, what exists at this point can be described as an Arduino controlled car stereo that is able to power on and off, select the AUX input and has working volume control. It's cool, but just a subset of what the original MCU did. You can show custom texts on the LCD though, which is fun:



The rest of the buttons will be mapped in software running on the Raspberry Pi, but I already noted that there isn't much doubt that the best mapping will be to switch tracks using the original up-down track switch lever, and switch albums using the huge buttons above and below it.

Before that can happen, the Pi has to be wired in somehow.

Next: Part 3

Ei kommentteja:

Lähetä kommentti