This article describes the repair of the “source selection circuit” of a 27-year old
Sansui AU-X517R audio amplifier, using an Arduino Nano.
For those sceptics who shall ask immediately why spend so much time and effort to engage in such an endevour, I am responding right away that the goal is to prove now and again the capabilities of a micro-controller in supporting any application that requires any form of logic, as well as exercise control over both digital and analog circuits alike.
In addition, I present two “innovative” ideas which could be found useful in any project that requires a sequencer, such as washing machines, industrial transfer belts etc.
Ageing is a nasty thing, applying also to electronics equipment. In a properly designed circuit where proper thinking has been exercised in avoiding thermal stress and excessive vibrations, components such as resistors, ceramic capacitors, transistors etc. may survive for several decades. Unfortunately, every equipment also needs to incorporate plastic parts, moving parts (gears, elastic rings), parts that contain chemicals which degrade over time (such as electrolytic capacitors, transformers etc). Mechanical wear, corrosion, oxidization of one single part (and some times a very inexpensive one) may cause the death of an entire system.
This was the case for a 27-year old audio amplifier. It came from the age when HiFi systems were composed of discrete elements, such as a turntable, a CD player, a radio, a cassette player and an audio amplifier. The buyer would select the best (according to his criteria) in each category, mixing and matching components of various manufacturers. Back in the nineties, integrated systems did not exist. Actually, there were some but were usually neglected by HiFi enthousiasts as low quality equipment. How to pack several functions in a single box, at the time when surface-mount components did not exist and keep a true HiFi experience?
HiFi systems started coming to market with remote control capability as an extra. Personally, and in relation to the audio system, I have never, ever used any of those individual remote controllers, which just occupied storage space.
The reason for mentioning the remote control is because the design of the system for supporting remote control was the main reason for the failure.
The problematic behaviour of the audio amplifier started to manifest itself when the user attempted to change the input audio source, e.g. from CD to tuner. The AU-X517R is equipped with a rotary selection knob. You select the source by turning the knob left or right to the desired position, you hear the sound of movement of a motor for a couple of seconds and finally the audio of the selected source is heard from the speakers.
The problem started to appear when the system started to skip some sources and seemed to rotate through all possible audio sources, before settling to the selected one. After several months, the selection of audio source became impossible, rendering the system inoperable.
The Sansui AU-X517R is a 2x65W audio amplifier, manufactured in the early nineties. There are no SMD components inside. Only through-hole components, mounted on several single-layer PCBs. Yet, it is a computer controlled systems. Its heart is a Toshiba
TMP47C440AN 4-bit micro-controller, which contains several digital I/O pins, as well as eight analog-to-digital channels with 8-bit resolution. Programs are stored in a 4096×8 bit ROM and variables are kept in a 256×4 bit RAM. This single-chip computer performs several functions in supporting the operation of the audio amplifier. Here, we shall concentrate only on the functionality that is associated with the solution of our problem. The simplified block diagram of the amplifier was located online and is shown below. Please note that the contact numbers are different than what I experienced. Perhaps there were multiple versions of the amplifier, or it is just another mistake like the spelling of
The “INPUT SELECTOR CONTROL” is the front-face rotary knob, through which the user may select an audio source. The amplifier has inputs for PHONO, TUNER, CD, LINE, TAPE1 and TAPE2. The knob controls a rotary switch which is connected to a resistor ladder. Turning the knob cycles the output of the resistor ladder through the following voltages: 0V, 0.7V, 1.4V, 2.2V, 2.9V and 3.5V. The voltage is applied to one of the A-to-D channels of the TMP47C440AN micro-controller, on pin 3.
Upon identifying the requested audio source, the controller orders the “INPUT SELECTOR DRIVE” motor to rotate left or right. The controller software is clever enough to identify the shortest path to the new position, even if the user moves the knob through several positions. Two of the controller pins are used to control the motor. When pin 13 is HIGH and pin 14 is LOW, the motor rotates clock-wise. When pin 14 is HIGH and pin 13 is LOW, the motor rotates anti-clockwise. When both pins 13 and 14 are LOW, the motor is in a braking state.
The signals from the controller are applied to an
LB1641 bidirectional motor driver, which subsequently provides voltage with the appropriate polarity to the motor to force it rotate to the desired direction.
The motor assembly is an
ALPS (Japan) module which is composed of a motor and three 12-pin rotary switches. The two switches are connected to the Left and Right channel of the audio sources, respectively . The third rotary switch provides an indication of the current position of the switch. This is achieved using another resistor ladder, having the same resistor values as the “INPUT SELECTOR CONTROL”. The output of the resistor ladder is connected to another A-to-D channel of the micro-controller, on pin 4.
After all the above, we understand that the system works like this:
The controller implements a safety mechanism regarding the position control. If the requested position is not achieved in a reasonable amount time (a few seconds), the motor brakes in order to protect itself and the rest of the circuitry.
We also need to remember that the infrared remote control can also be used to select an audio source. In that case, the system will implement the above actions starting from step 3. This operation has a significant implication: If the audio source selection takes place via the remote control, the knob remains at its original position, supplying the same voltage at the output of its resistor ladder. This means that the absolute value of this resistor ladder cannot be used to indicate the selected audio source. It is only used by the controller to indicate movement to the left or right of a number of positions. The voltage of the resistor ladder of the motor may be at a totally different level, because it is moved by the commands of two different controls (the knob and the remote control).
It is worthwhile to note at this point that the TMP47C440AN micro-controller is powered from a 5V power supply which remains always on, while the amplifier is connected to the mains. This happens because it remains at a standby mode, allowing to be powered-on completely via the remote control. In contrast, the motors are powered via another 7.8V power supply.
The amplifier was placed on the surgical bed of the lab. After removing a huge amount of screws, the top and bottom panels were removed as well as the front face. The ALPS rotary switch was identified. Trying to rotate the axle manually with a screwdriver, it became evident that the axle was rotating freely, without feeling the resistance of the motor.
Next step was the removal of the ALPS assembly. I removed several more screws and freed the PCB on which the assembly was soldered. I had to remove several connectors which wired the PCB to other boards. Very important, I labelled all the cables in order to place them back again at re-assembly. Have also taken several pictures.
De-soldering a 3×12 contact could prove to be a nightmare without having an advanced de-soldering station. But the beauty of the nineties, with the single layer PCB and the fully leaded solder, was that I managed to de-solder all 36 contacts only with a simple hand-operated solder sucking pump. All PCB holes were beautifully exposed with just a single action of the solder pump in each of them!!! The fumes were of course ventilated, since we may become happy with old memories but cannot forget the nasty nature of the old materials.
After removing the plastic cap of the ALPS module, the problem became apparent.
A plastic gear which was originally transferring the movement from the motor to the axle of the rotary switch was broken in four pieces. The teeth in one of the pieces were worn, as shown in the picture where all pieces are “assembled”. This is the reason that before the complete failure, the control skipped positions. The worn-out teeth did not move the switch properly, forcing the controller to try to rotate the motor until some tooth finally grabbed.
Now, it is becoming obvious why I mentioned at the beginning of this article that the remote control was the main reason for the problem. Without the remote control, the audio source selection would be accomplished via a simple rotary switch, controlled directly from the front panel. Even if the switch would need to be placed in the far back side of the equipment, there have been designs where a long rod transferred the rotation from the front knob to the back switch. To support control from both the knob as well as the remote control, designers had to use this motor-operated switch. This design selection caused an additional bad behaviour of the system, in the sense that in order to select an audio source which was not at the immediate next position, the system had to pass through other audio sources and hear them at the speakers for a small amount of time. Contrast this behaviour with the selection of an audio source via buttons. You press the desired button and you hear what you want! Yet, it seems that no better solution than the motor-operated switch could be found at the time.
An online search showed that a replacement module does not exist in the market. A similar motor-controlled switch from the ALPS company was found but the physical distance between the three sets of switches was different than the original.
Another option would be to search for a used component. But such an old mechanical switch may also suffer from corrosion problems, which could appear as audio “scratches” when moving to another audio source, in some positions one or both the two audio channels could not play. Regarding the position control switch, an oxidized contact would cause the controller to be blind to the switch current position etc.
Another option would be to build a gear with a 3D printer or order a gear online. Unfortunately, I do not have access to a 3D printer and the online order will take a lot of time and money. If anyone wants to go this way, the broken gear had 40 teeth, outside diameter 16 mm, hole diameter 4 mm and width 1.5mm.
All the above, along with the desire to replace electromechanical components with digital components, led me to design the complete replacement of the ALPS assembly with a set of relays controlled by an Arduino Nano. The new module would be controlled by the original TMP47C440AN micro-controller, mimicking as precisely as possible the ALPS assembly. Replacing entirely the TMP47C440AN micro-controller was not even considered, because this controller performs several other duties which I could not invest so much time to reverse-engineer.
Finally, the list of tasks to perform the repair will be:
Starting from the selection of the audio sources, we use six digital I/O pins of the Nano to control the six relays. I happened to have in my laboratory several 5V relays and decided to use them. Each of them requires 75mA to remain armed, so I started to have second thoughts regarding providing power from the continuously-on 5V supply. I therefore decided to use the 7.8V supply which is ON only when the amplifier is out of stand-by mode and since it operates the motor, it is capable of providing a higher amperage. I also wired the circuit so that the Nano may receive power from the 5V source and the relays from the 7.8V, but did not implement in the final version, for reasons that I will present below.
In order to drop the voltage from 7.8V to 5V, and due to the lack of space for the placement of a proper circuit, I went with the dirty way of placing a few diodes in series. Relays are forgiving if a bit higher voltage is applied. In addition, only one relay is active at a time because only one audio source can be enabled and therefore the current through the diodes will be constant and so will be the voltage drop.
The Arduino Nano is powered by the 7.8V source through the
Vin pin. This is entirely within the Nano specifications. A diode in series is a precaution to block feeding current back, in the case we modify our circuit to be powered through the
5V pin. See the discussion regarding the Arduino Nano powering issues here.
In order to receive orders for movement from the TMP47C440AN, I used two digital Arduino pins,
D11. Although I expected HIGH and LOW from the controller outputs to comply with the TTL specifications, because of external circuitry of the amplifier, the HIGH was limited to about 2.5V and was not recognized by the Nano. The simplest solution is to activate the pull-up resistor in the Nano I/O pin and use a diode in the configuration shown in the schematic. The LOW appears in the Nano pin as 0.7V and is recognized as logic LOW, whereas any higher voltage is recognized as logic HIGH.
Finally, for the position control we could use SPST relays to control the resistor ladder. Since the current passing through the ladder is really small, a better solution to relays would be to use the Arduino pins as outputs and source current through them, effectively acting as a ground connection. This will save a lot of space and power in contrast to the relay solution. I decided to use the A0 to A5 pins for this task.
The pins will not operate in a normal LOW-HIGH manner but will operate in two states:
Our Arduino software will activate the
A0-A5 pins in a rotary fashion, causing the output voltage of the resistor ladder to change and this will fool the TMP47C440AN to believe that the motor is rotating.
An additional benefit of using the analog pins is that we are able to use the
analogRead() function and read the output voltage of the resistor ladder in pin
A5! I used it only in the original prototype but not in the “production” version.
I also wired pin 3 of the TMP47C440AN to analog input
A6. The plan was to use the voltage upon start-up in order to set the initial audio source. See the discussion at Grey areas, below.
That's about it in terms of functionality. The schematic is shown below:
Header pins J1 are used to power the Arduino board. Pin 2 is connected to the 7.8V power supply. A set of four diodes drop the voltage to make it more suitable for the the operation of the 5V relays. Pin 3 is wired to pin 2, but could be used in the future to power the Nano independently of the relays. A 1N4007 diode is placed between pin 3 and Vin, to block current going back to the amplifier circuits, when the Arduino is programmed and subsequently powered via the USB port.
Header pins J3 are used to receive the motor control orders from pins 13 and 14 of the TMP47C440AN. Two 1N4148 diodes are fixing the voltage mismatch and provide the proper TTL voltages to pins
Header pins J4 and J5 are the Left and Right audio channels. Each source signal comes into pins 2 to 7 and when one of the six relays RL1 to RL6 is activated, the signal is connected to the common which is wired to pin 1 of the header of the respective channel. The normally-closed pin of the relays is left unconnected. All common relay pins of each audio channel are wired together and are connected to pin 1 of J4 and J5.
The schematic shows two of the source control sub-circuits, connected to Arduino pins
D9. Four additional sub-circuits are implied, connected to Arduino pins
D8. Each subcircuit consists of a 2.2K driving resistor, a BC337 transistor, a 1N4007 flyback resistor and the relay.
Header J2 pins 1 to 7 are used for the input selector resistor ladder, where the motor reports its position. Pin 8 of J2 is used to read the input control resistor ladder. Perhaps the decision to place this pin along with the others was rather unfortunate, but was dictated by the grouping of analog signals in a wire strip. Probably it would fit better along with the other signals in J3.
I placed all components in a perforated all-purpose 7x9cm board, from which I cut a few cm to make it fit into the space available in the amplifier rack. The new board dimensions were a bit larger than the ALPS module, but I managed to squeeze it in.
The most time consuming action was the preparation of the strip wires connecting the Arduino PCB to the original amplifier board, in place of the direct connections of the 3×12 pins of the ALPS module. I used male-female headers in order to be able to remove the wires for service. Yes, of course I am aware about crosstalk and other audio problems with parallel strip wires, but when you are dealing with such a situation, those problems are of minor importance.
As shown in the picture below, the cable strips have a female header at one end. The other end is stripped from insulation in each of the wires and will be soldered to the amplifier board, in the holes of the ALPS module.
Since there is no numbering on the ALPS connectors, I used an arbitrary numbering scheme, considering as number 1 the common pin in each of the three rotary switches of the module. The wiring is the same to all three rotary switches. Pin 1 of J2, J4 and J5 is wired to the common pin of the amplifier board designated as pin 1. In the audio channels, pins 3, 5, 7, 9 and 11 of the rotary switch are connected to the analog ground. Since our board does not use the analog ground, we do not connect anything to them. We have tried of course to keep the length of the strips to the absolute minimum to avoid any interference between the audio sources.
From the 12 contact of the third part of the rotary switch which is used for the motor position control, pins 3, 5, 7, 9 and 11 of the rotary switch are not connected. Pin 1 is the common and pins 2, 4, 6, 8, 10 and 12 are connected to the on-board resistor ladder. As with the audio signals, a 7-wire cable strip is used to connect our Arduino circuit to the amplifier board.
Please note that the motor position control rotary switch is the one which is more close to the motor. The traces on the amplifier board are really easy to follow and identify the purpose of each pad.
The board along with the soldered cable strips is shown below:
Finally I placed the Arduino board on top of the amplifier PCB and used plastic spacers to maintain the distance between the two boards. To avoid drilling holes on the amplifier board, I kept everything in place with a few drops of hot glue, using a glue gun. If, in the future, we need to move the Nano board, the glue material can be removed easily. I also made sure that the Arduino Nano USB socket is easily accessible from the top side, so that I can re-program if necessary by only removing the top cover of the amplifier.
Writing the code was an experience. Since I did not know the exact code programmed in the TMP47C440AN, I have found sometimes that this code was competing to the Arduino code. My first version was a very elegant masterpiece which rotated the motor very well in the back and forth direction. Unfortunately, it worked only when the audio source selection knob was moved one position at a time. If the user moved the knob two or more positions in one blow, the internal Sansui code tried to locate the shortest path to the new location in a way that I could not replicate, resulting in several “rotations” around the full perimeter before reaching stability to the final position.
I finally realized that in order to mimic a “stupid” behaviour, you need to be smart enough to copy every single detail of “stupidity”, in every single time interval! To cut a long story short, the position control switch cannot be modelled as something that only provides six distinct connections. To achieve the functionality duplication that the software designers of the nineties had to cope with, the rotary switch must be modelled as something that “makes” connection at several points in time and “breaks” at other points in time, rolling smoothly and in a predicted manner from each state to the other. Probably the Sansui engineers have utilized the transient from one condition to the other as a synchronization signal. Kudos to the Sansui designers who managed to squeeze a highly effective code into this 4-bit micro-controller.
There are cases when the switch does not link any contacts. At those times, the resistor ladder provides the highest voltage. Therefore, when moving from 0.7V to 1.4V, there is some time while the output continues to remain at 0.7V, then, when the connection is broken, the ladder output raises to 3.5V, then we have a new contact and the voltage goes to 1.4V, and finally, the motor continues to move in order to reach the middle of the new contact keeping the voltage to 1.4V.
To simulate this behaviour, I wrote the code as a contact going through each of the 360 degrees of the circle. Our six audio sources are modelled as 6 segments of 60 degrees each. In each of those areas and considering that our switch has 12 pins from which only 6 are connected and the other six are left floating, our model behaves like this:
Actually, our 12-pin switch has one common and 11 contacts, so we would have to divide the circle in 11 parts of 32.7 degrees each and the position where the physical contacts start and end, as represented by integers, would not be easy to replicate in each of the 6 segments. In addition, the physical construction of the rotary switch is not known in detail because the contacts are not visible and I have noticed (just a feeling, with no proof) that the rotation from an active pin 12 to an active pin 2, takes more time than rotating from pin 2 to 4. Yet, the model above with the six 60-degree segments is within the error limits allowed by the TMP74C440AN and works perfectly.
UPDATE: I found some time to place the ALPS module on the surgical bed to have a deeper look on the contacts. After removing the axle, I was able to remove the rotating part of each switch and see what happens inside. The two pictures below show the stator and rotor of the switch.
In the stator, the common pin is wired to a metal ring near the center. Twelve contacts are placed around the perimeter. One contact is a bit wider than the others and is electrically connected to the internal ring. The rotor has two contacts, which are wired together. One maintains contact to the ring and the second rotates around the stator contacts, connecting with each one of them while rotating. This means that my conceptual 12-contact model was mostly accurate, including the “feeling” that the rotation from an active pin 12 to an active pin 2 takes a bit more time. This happens because the common contact is connected to itself during part of the rotation. In addition, the stator part of the common contact is a bit wider than the other contacts. Although the code works well at its current version, in order to be absolutely precise, I must set the output voltage of the resistor ladder to 0V instead of high-Z, when the rotor passes through the common contact, i.e from circle position 352 to 7 which is the last half of the last segment and the first half of the first segment. In addition, I could set the width of the “gap” sections a bit larger than the width of the contacts, as shown in the stator photo.
END OF UPDATE
The software model moves through each of the 360 positions, one step at a time. The delay between each step can be programmed so that a full rotation is achieved in approximately two seconds, as the physical motion of the original motor allowed. The ROTATION_SPEED constant is set to 5 milliseconds, leading to a full rotation in 5*360=1.8 seconds.
The code is documented well enough to present what happens in every step and can be found and downloaded here.
As we have described above, the “INPUT SELECTOR CONTROL” and the “INPUT SELECTOR” resistor ladders may be set at different positions. With the original ALPS switch, the TMP47C440AN would only have to read the voltage of “INPUT SELECTOR” resistor ladder and deduce the current position of the rotor. It would then light the proper LED at the “INPUT SELECTOR CONTROL” knob and would start to monitor the movements of the knob, as well as the orders via the infrared remote control.
In our case where we have no memory upon start-up, which source would be selected as the initial one? We could hard-wire one in our code. A more intelligent option would be to read the current position of the “INPUT SELECTOR CONTROL” and set the output accordingly. I have used this approach and wired the resistor ladder to Arduino pin
Unfortunately, testing this functionality is really troublesome, as it requires turning on and off the amplifier which results in turning on and off the Arduino which results in changing the USB device (e.g. from
/dev/ttyUSB1). In addition, having the USB cable from the PC connected to the Arduino, keeps it powered and does not perform a clean start-up. As a result, we loose debugging visibility at the crucial stage where we need it. Probably it will be an investment to create an interface which uses
Rx pins at TTL levels and avoid using the Arduino USB port for Serial Monitor. I may use a converter between 5V and 3.3V and use a Raspberry Pi console cable.
Anyway, the problem is really minor. Just turn on the amplifier and select the desired audio source. It may be different than the one selected when we turned off the amplifier, but it is not a big deal.
Another solution would be to write the current position to the EEPROM but that would cause extensive wear to the memory and should not be considered at all in a “production” version
A rather peculiar behaviour was experienced in the
setup() procedure. We first read the analog value from the source selection knob in pin
currentSourceIndex = selectorPosition(); , we set the proper pin of the resistor ladder with
setControlIndex(currentSourceIndex); and finally we activate the relay of the associated audio source with
The problem was that the
setControlIndex(currentSourceIndex); failed to activate the digital output. The code was running properly and activated another audio source at the knob movement, but it seemed that the first
digitalWrite(audioControlPins[index], AUDIO_ACTIVE); was ignored by the ATMega328P processor!!! After adding a delay of more than 15 milli-seconds between the second and third command, the problem was solved.
Although the code now behaves perfectly at this point, the incident is rather suspicious and requires further investigation by anyone who likes to dig deeply. Unfortunately, I was not able to reproduce it outside the circuit which was installed inside the amplifier.
As described above, in the current version the Nano is powered by a 7.8V power supply which turns off upon setting the amplifier to standby. We could leave the 7.8V to power the relays and use the 5V power supply to power the Arduino itself. This would maintain a complete synchronization between the Arduino and TMP47C440AN.
In such a case, we could use the ATMega328P sleep mode to minimize power consumption. Instead of using pins
D11 to identify movement control, we should use pins
D3 to wake up using interrupts. We could also make a small hardware modification and create the interrupt on pin
D2 in any movement rotation, and leave the current functionality of
D11 as is. Instead of the Nano, another Arduino module type would be used to avoid the extra power consumption of the USB chip.
Again, this improvement has not much of practical significance (unless we powered the amplifier from a UPS) and can be implemented simply as an exercise from anyone who feels conscious in power consumption matters, but requires electronics to remain on standby.
All design decisions, in spite of having been taken to resolve a problem, they have a tendency to create another problem or to be subject to a condition that may be a disaster waiting to happen. Remember that one problem with the rotary switch was that when switching audio sources, you needed to pass through them and you heard them at the speakers momentarily. A solution with buttons which would select an audio source (or in our case with individual relays) would not present this problematic behaviour. Unfortunately, buttons may be subject to another problem. What happens if you press two or more buttons at once? A proper design should handle such a problem in two modes:
In our circuit, the software disables all relays before switching to an audio source. In addition, during the start-up of the Arduino, we should make sure that the ports which control the relays do not provide enough current when they are in the start-up phase or when they are in the high-Z state since the ports are configured by default as Inputs. So, the first mode is covered. Yet, any software modification should always take proper care to avoid having two relays on at the same time. Actually, it should provide sufficient time after the de-activation of one relay before activating another.
Regarding the second mode, the amplifier itself will not complain if its input receives a composite signal from several sources, provided that the aggregate voltage of the sources is within the specifications. In contrast, connecting the output of several sources means that the output stage of each source is somehow short-circuited to the output stage of another source. The lower the output impedance of each source, the bigger the problem. A solution would be to place a resistor in series with each source. In case two relays were active at the same time, the current from one source to the other would be limited by the sum of the two resistors. Actually the AU-X517R has made a provision for such resistors on the PCB, but unfortunately, wire bridges are installed at the place of the resistors. We could replace the bridges with the resistors if we like. The input impedance of the amplifier is specified as 47K, so a resistor of maximum 4.7K would not modify the specs considerably, yet it could provide the additional protection that we need.
This project gave additional life to an audio amplifier that in normal circumstances would have been recycled several years ago because of an inexpensive plastic gear. Sometimes, it is not the cost of the repaired equipment that is the driving force behind such an endevour. Imagine the case when your enclosed washing machine stops functioning because a simple plastic element in the mechanical timing sequencer has failed. There is no replacement part, so you need to buy a new washing machine. The new machine is a bit larger than the previous one, so you need to replace the entire enclosure, including the washing bin and the entire plumbing. The new bin does not match aesthetically with the old bathroom elements, including the tiles. Perhaps a renovation of the bathroom and subsequently the entire home is in order!!!!
Well, the above example, is not so far from reality and at some extent it has happened to real people I know. Imagine now that such an incident happens in an industrial line, where the chain of replacements that is activated by a simple inexpensive component may cost millions. Ingenious engineers should possess in their toolbox the knowledge to design and implement effective solutions to cope with such problems.
If not persuaded about the practical usage of such an application, simply consider that we do it, first because we can, and second because we have fun doing it!
If you have any feedback, please contact me via this contact form