\documentclass[11pt]{article}
%Gummi|065|=)
\title{\textbf{Car Stereo Replacement}}
\usepackage{graphicx,caption}
%\author{Steak Electronics}
\date{02/13/20}
\begin{document}

\maketitle
\tableofcontents

\section{Car Stereo Replacement}
Replacing a car stereo. I could just go to ebay, and buy a used car stereo, but where's the fun in that? Let's DIY a car stereo from a PCB used as a frontplate, a connector for my vehicle, and an audio amplifier. I'll connect in signal from an audio player.
\\

\includegraphics[scale=0.4]{../pics/DSCN2180.JPG}
\captionof{figure}{PCB rev 1}

\subsection{Items Included}
I thought I would include the following:
\begin{itemize}
\item Arduino Nano
\item Voltage and Gnd Breakout
\item I2C Display
\item Voltage Readout (of BAT)
\item Current Readout (being drawn)
\item Amplifier ``Lvpin LP-838''
\end{itemize}
I also wanted to have the connectors that eurorack and synth designers use for mono audio cables, but the cables turned out too expensive. The current readout didn't work initially, and I haven't gotten to fixing it yet.
\subsubsection{I2C OLED display}
Just for fun, I bought an I2C oled display and am going to use it to display something.\footnote{It's an Arduino Uno, you can put almost anything on this.} Notes on this:
Using the adafruit SSD1306 and GFX library (this procedure is well covered in other places), you can load an example sketch and get it running. First thing to change is to remove the Adafruit logo and replace it with my own. Let's do that.

From https://design.goeszen.com/convert-image-for-oled-display.html
\begin{verbatim}
I'm on Linux here and found that the readily-available 
ImageMagick package will do the trick for you without
 any scripting. And runs on the CLI! Simple as that:

    convert some_image.png some.image.mono
\end{verbatim}
That's efficient. But it didn't really work out. Too much work, I don't need it that bad. Have to convert it to something the c compiler can read. I instead, just deleted their logo. Good enough for now.
\subsubsection{Internal AVR Temperature Sensor}

I setup the code to read from the internal temp sensor on the duino. However there is also this:

https://thecavepearlproject.org/2019/02/25/no-parts-temperature-measurement-with-arduino-pro-mini-to-0-005c-or-better/

This would be something to do for more resolution. The built in sensor is not very good, so this above link would be great. Hack a day also covers it. 

\subsection{Wiring Pinout is wrong on Internet - Cable has labels}
I looked at the picture I have detailing the pinout of my car connector (Delco Delphi radio wiring diagram.jpg in resources). It's close, but not 100\% correct. I found that the cable itself has small text labels on each wire which explain which everything does. I didn't notice earlier, as I didn't look close enough (and no one mentioned this).

\subsection{Arduino VReg Blowout}
I had a knock off Arduino Nano, and the vreg blew out. I have some other vregs to replace it. I didn't have this problem with an Uno that I use as a ceiling dome light. Although that one is not left on as long, usually. 

\subsection{Amplifier}
The amplifier I used is one of the cheapest avialable on ebay. I'm not proud. I'm poor. I had to take it apart, and reseat the amplifier ICs as the tab was not making contact with the chassis for one of them. I also added thermal paste. This amp is underpowered for my car, and may need replacing. It gets a bit hot.

Some other issues with this amplifier are that the output connectors can get pushed back, there is only one output connector option, and it must run on battery power, as a 12V 1A or 2A will not power it. Finally, there is a 6V DC bias on output. No output audio isolation, which means you get car noise.

\subsection{AC Audio Coupling to Remove DC Noise from Auto}
I had some fun with this one. Many videos on this in the video folder. I started with the speakers being directly fed by the amplifier. This worked, but there was some noise coming through. Cars are noisy, this is not surprising. I would've preferred the amplifier to isolate the outputs, but no luck... At this point, I considered two options to block DC and allow AC. 1) Use a transformer. 2) Use capacitors.\footnote{A third option would've been to use a second set of batteries, but that would be laborious.}

\subsubsection{Ground Isolator}
I had been given a Ground isolator, which was two small transformers on a pcb intended to pass audio from a car powered signal source into the car speakers. I tried this isolator on the output of the speakers, and while it worked, the volume was lower, and it was impractical. I knew as soon as I heard the volume, that the issue was an impedance matching problem. The transformers were too small. They were intended for signal sources, not amplifier outputs. Onto option \#2.
\\

\begin{center}
\includegraphics[scale=0.35]{../pics/DSCN2610.JPG}
\captionof{figure}{Ground Loop Isolator.}
\end{center}
\subsubsection{Capacitor Audio Coupling}
My initial thoughts here were: ``Let's be careful and use non polarized caps''. I bought some 0.22uf and 0.022uf polyester film capacitors at Electronics Plus, the local radioshack replacement, and tried them. No sound. After adjusting the connectors on the amp (which were admittedly loose - it's easy to push them back on the amplifier if you are not careful) I found that the capacitors didn't work. One problem was evident in the oscope. I only used one capacitor on the + output of the speaker amp, but the Amp biases the signal 6 volts. So I needed two. After that was resolved, the signal came through on the output of the capacitor, as viewed on the scope, however there was no sound output. I tried the safe way. It's time to break some rules. 

I grabbed some 1uf (electrolytic polarized) caps I had, and tried these. Again, no sound. Not giving up, I grabbed some 1000uf 'lytics, and tried once more. Now it worked.

\subsubsection{Impedance / ESR of capacitors failing to pass enough power of signal}
Capacitors are rated for impedance. Some data sheets also call this ESR, it appears after a quick look. It's either in there as impedance or ESR. It's not initially an issue if you are using the capacitor as a DC reservoir, but if you use it in an AC coupling situation then things get interesting. A high impedance, or ESR will block what a low one won't. In this example, it's as simple as the Amplfier either being able to power a speaker or not. Higher capacity caps will have lower impedance. See the picture. Other brands put impedance in a graph, or just call it impedance. 

\includegraphics[scale=0.5]{../pics/esr_impedance_capacitance.png}
\captionof{figure}{Notice how impedance jumps very fast with a 1uf cap, compared to the higher values. Additionally, different brands will have different impedances for a similar value cap.}

\subsubsection{Wikipedia on Impedance}

\emph{In general, a capacitor is seen as a storage component for electric energy. But this is only one capacitor function. A capacitor can also act as an AC resistor. Especially aluminum electrolytic capacitors are used in many applications as a decoupling capacitors to filter or bypass undesired biased AC frequencies to the ground or for capacitive coupling of audio AC signals. Then the dielectric is used only for blocking DC. For such applications the AC resistance, the impedance is as important as the capacitance value. }
\begin{verbatim} https://en.wikipedia.org/w/index.php\title=Aluminum_electrolytic
_capacitor&oldid=940281525
\end{verbatim}
Essentially, what I learned today.

\subsection{DIY Amp}
I was flipping through Practical Electronics for Inventors\cite{Scherz}(page 959), when I came across an audio amplifier. He also gives one at the chapter on Semiconductors (pg. 467), although the former is more detailed. With a reasonably simple schematic available, and a high likelihood of it working, I say why not: let's build it up.

I've noticed that the ``Lvpin LP-838'' amplifier I'm using is underpowered for my two front speakers \footnote{Although it seems it would work for one channel, so two of them might be enough. It's rated for 20W, so that is about 15-20W per channel req'd. It works at 20W for both, just that it heats up too much. Multiple ebay sellers have it misquoted at 200W. Just an extra 0, no biggie. Based on all this, it appears each channel of my car speaker needs about 15 watts to be on the safe side. The example schematic is 16 watts. Two should suffice.}, so I will make two of the provided 16 watt amps.

\subsubsection{LM383 is Obsolete}
That explains why I haven't heard of it. The chip is obsolete. Some sell it on ebay for about \$5 each.

As a different route, could I use some other power amplifier op amp, with the same pinout? Hm... Aha, the LM1875 has the same pinout. Let's use that.\footnote{How did I find this? I searched Digikey for the LM383 sold by rochester, noted it was it the category of Linear - Amplifiers - Audio, chose that, then searched for everything in the same package (TO220-5). Came right up. If this hadn't worked, I would've wanted to try other sites: Farnells, Mouser, etc...}

Will it work with the same schematic? Questionable. May still need to buy a LM383, along with the LM1875, as backup. I might also try a generic power op amp.

Amplfiers are the expensive bom item here.

\subsection{Noise remains with Speaker Isolation}
I've isolated the speakers from DC with the caps, but noise remains. My next idea was a DC-DC isolated supply. But, I found two threads on eevblog forums\cite{eevblog}, and they recommend a power line filter (they also mention the isolated supply). A filter with a coil and cap (2200uf even low enough) I can quickly build up.

I also want to fix up my portable CRO, I obtained the other day. That needs batteries.

One thing I noticed, is that the amplifier seems to no longer heat up, since the caps were added. Perhaps the DC bias was the cause. I need to confirm this.
 

\section{References}
\begin{thebibliography}{99}
\bibitem{Scherz}
  Paul Scherz, and Simon Monk,
  \emph{Practical Electronics for Inventors}, fourth edition - 2016, McGraw Hill.

\bibitem{eevblog}
  Various, \emph{https://www.eevblog.com/forum/projects/dreaded-alternator-whine-in-car-stereo/25/} Retrieved 2020-02-21. see also https://www.eevblog.com/forum/beginners/car-engine-signal-interference-with-cell-phone/

\bibitem{partofthe}
  \emph{https://partofthething.com/thoughts/building-a-low-pass-filter-to-remove-alternator-whine-in-my-car/}. Picture guide and showing basic build in project box. Eevblog users mention you may be able to use the secondary of a transformer, to avoid building the coil.
  \end{thebibliography}

\end{document}
