This is a small project log that I decided would be a good start for the wiki.
Short description
For this project I purchased a ready made circuit that can identify and measure various electronic components, soldered some pins and used Arduino as ISP (In-System Programming) to update the firmware.
A bit of history
A few years back I replaced the screen in an industrial computer that had gone blank when the cooling fan failed. The original screen had a 19" resistive touch panel and controller that were still in good condition but I wanted to get it working again as a challenge. The screen consisted of an LCD TFT panel with LVDS socket, an FPGA buffer board, the controller board, a power supply board, the CCFL back light driver and some push buttons on another PCB. Thinking it was a fault in the controller board I purchased a similar one that didn't work so I got the exact same board only to realise that there's a chip in it that contains a different firmware so it didn't work as expected (or it works as long as I swap the chip between boards) but that proved that the LCD was fine. However, I also realised by chance that the original board was working fine too at that point. I must be missing something...
After watching Dave Jones (EEVBlog) checking some capacitors that had gone bad in a few videos (like this one) I read a bit more about the ESR (equivalent series resistor) in electrolytic capacitors and how to measure it. The chances of a faulty capacitor were pretty high and since I had two boards to play with I could swap the capacitors over and get it working reliably.
What's the ESR?
An ideal capacitor doesn't allow current to flow through it but in reality that's not the case and depending on various parameters there's a small resistive component in the total impedance (or capacitance). This is usually represented as a series resistance (ESR on wikipedia). In the case of electrolytic capacitors, my understanding is that it's most likely due to the free electrons in the electrolyte and the reaction that takes place in the electrodes when the voltage is applied (more info in this video from James Lewis at Kemet Capacitors). When the electrolyte dries out or there's a perforation in the electrodes this ESR increases and that usually has adverse consequences in the rest of the circuit.
Measuring the ESR
In my case, I wanted to find out if that was the case so I started by following a few tutorials for using the oscilloscope and a function generator to measure the ESR. Basically, if a high frequency (200kHz) and low voltage (< 1Vp-p , peak to peak) square wave is applied to a capacitor with a resistor in series, the capacitor won't have enough time to charge before it's discharged so the capacitive part can be ignored, leaving the resulting signal as a linear function of the voltage applied. Using Ohm's law and knowing what the external resistor value is we can calculate what the ESR must be. Unfortunately, my oscilloscope has a minimum range of 2mV and at that frequency I couldn't get repeatable readings even though I managed to identify two faulty capacitors using this method.
TransistorTester project
I realised that this was very tedious and I was probably going to find myself troubleshooting capacitors in the future both as a hobby and most likely at work. A quick search on Google came back with some results and one of them was a review on Hackaday http://hackaday.com/2015/04/24/review-transistor-tester/ regarding some cheap Chinese electronic components tester that I had also seen on Dave Jones' desk at some point. With a bit of research I realised that these boards are clones of a project called TransistorTester https://www.mikrocontroller.net/articles/AVR-Transistortester which in turn was also based on someone else's work.
Hardware selection
I went for the LCR-T4 board from China with the blue button (seemed like the yellow button model was a bit older and I could see in the pictures that this one had the same ATmega328P microcontroller as in the Arduino Nano. I didn't order a box but instead I would source my own.
First test and concerns
After I had the chance to inspect it I found some common issues with the Hackaday post like the screen flapping in the breeze, scratched and looking like a second hand or repurposed item even though the rest of the board was looking pretty good and had good quality soldering. Something was missing and that was the programming port. At that point I noticed some six through holes that looked a lot like the ISP header in the Arduino boards. A couple of years ago I managed to upgrade the bootloader in my Arduino Mega using an Arduino Nano as the programmer and then I did it the other way around through this header so perhaps I could do the same with this. A continuity test between these proved that the pins in the microcontroller were in fact connect to these holes so I soldered the missing pins in place and double checked against the TransistorTester manual and the ATmega328 datasheet to be sure that the board was compatible with the original project. Turns out that the pins were upside down but no big deal, at least I didn't have to remove the screen.
Why would I want to mess around with reprogramming the board if it was working fine? Well, if you are familiar with microcontrollers and PCBs you'll know that they don't like electrostatic charges and they tend to "forget" their program with time. Unlike FPGAs, these devices have a high probability of losing their program and are only specified to hold it for some ten years. This timeframe is not exact and it changes drastically with use. My first concern was to backup the memory so that I could put it back in case something went wrong and the second concern was not knowing what version of the firmware was actually being used. The project is still alive with contributions at the time of writing of less than two weeks old so chances are that the new code has a lot of improvements that I'll find useful.
Upgrading the bootloaders
First things first, before trying to upgrade the firmware on this unit I should refresh my memory on the procedures for using the Arduino boards as programmers. In order to do that I searched for a few schematics and examples of circuits until I came out with a solution that worked:
Arduino as ISP
In order to burn the bootloader on an Arduino using another Arduino we need to connect them together and upload to one of them (the programmer) the Arduino sketch called ArduinoISP. Since I had two Arduino Nano this is the procedure I followed:
Arduino Nano sending bootloader to Arduino Nano
1. Connect the first Arduino Nano (Ard1) to the USB port of the PC, start the Arduino IDE, select the board to be used and the COM port.
2. Open the Files->Examples->ArduinoISP->ArduinoISP sketch and upload to the Ard1. Confirm that there are no errors.
3. Disconnect the USB, select the Tools->Programmer->Arduino as ISP option in the Arduino IDE. In this case we are connecting two Arduino Nano so there's no need to change the board.
4. Connect the following pins between the two boards:
Ard1 ISP | Ard2 | |
---|---|---|
Pin | D10 | ICSP 5 |
Pin | D11 | ICSP 4 |
Pin | D12 | ICSP 1 |
Pin | D13 | ICSP 3 |
Pin | 5V | ICSP 2 |
Pin | GND | ICSP 6 |
5. Place a 10nF capacitor between RST and GND on Ard1. This will prevent the Ard1 programmer from resetting itself when the COM port is open in Linux and only the Ard2 will be reset.
6. Reconnect the USB cable and select Tools->Burn bootloader from the Arduino IDE. Check the progress and confirm there are no errors.
7. Done. Disconnect USB and remove the cables and the capacitor.
Arduino Nano sending bootloader to Arduino Mega 2560
1. Connect the first Arduino Nano (Ard1) to the USB port of the PC, start the Arduino IDE, select the board to be used and the COM port.
2. Open the Files->Examples->ArduinoISP->ArduinoISP sketch and upload to the Ard1. Confirm that there are no errors.
3. Disconnect the USB, select the Tools->Programmer->Arduino as ISP option in the Arduino IDE. Select the Arduino Mega 2560 in the list of boards.
4. Connect the following pins between the two boards:
Ard1 ISP | Ard2 Mega | |
---|---|---|
Pin | D10 | ICSP 5 |
Pin | D11 | ICSP 4 |
Pin | D12 | ICSP 1 |
Pin | D13 | ICSP 3 |
Pin | 5V | ICSP 2 |
Pin | GND | ICSP 6 |
5. Place a 10nF capacitor between RST and GND on Ard1. This will prevent the Ard1 programmer from resetting itself when the COM port is open in Linux and only the Ard2 will be reset.
6. Reconnect the USB cable and select Tools->Burn bootloader from the Arduino IDE. Check the progress and confirm there are no errors.
7. Done. Disconnect USB and remove the cables and the capacitor.
Arduino Mega sending bootloader to Arduino Nano
1. Connect the first Arduino Mega (Ard1) to the USB port of the PC, start the Arduino IDE, select the board to be used (in this case the Mega) and the COM port.
2. Open the Files->Examples->ArduinoISP->ArduinoISP sketch and upload to the Ard1. Confirm that there are no errors.
3. Disconnect the USB, select the Tools->Programmer->Arduino as ISP option in the Arduino IDE. Select the Arduino Nano in the list of boards.
4. Connect the following pins between the two boards:
Ard1 Mega ISP | Ard2 | |
---|---|---|
Pin | D53* | ICSP 5 |
Pin | D51 | ICSP 4 |
Pin | D50 | ICSP 1 |
Pin | D52 | ICSP 3 |
Pin | 5V | ICSP 2 |
Pin | GND | ICSP 6 |
5. Place a 10nF capacitor between RST and GND on Ard1. This will prevent the Ard1 programmer from resetting itself when the COM port is open in Linux and only the Ard2 will be reset.
6. Reconnect the USB cable and select Tools->Burn bootloader from the Arduino IDE. Check the progress and confirm there are no errors.
7. Done. Disconnect USB and remove the cables and the capacitor.
Now that I was able to burn all the bootloaders I was confident that I could recover the TransistorTester even if I was to use it as an Arduino in case I couldn't put the proper firmware in.
Uploading the newest firmware
Following the instructions in the TransistorTester web I navigated through the SVN folders and found the tree that matched my hardware. In this case, my screen was an ST7565 so the software I had to use was "mega328_st7565". I was using Linux so installed the build-essential and the gcc-avr packages as well as avrdude and the necessary libraries avr-libc:
$ sudo apt install build-essential gcc-avr avrdude
Changing folder to the location where I saved "mega328_st7565" SVN and then compile with "make".
$ cd Downloads/mega328_st7565 && make
According to the instructions the next step is to type "make upload" but unfortunately that make is configured for a different programmer so it wasn't going to work. Had to figure out how to upload using the Arduino as ISP instead.
I first used the Arduino IDE to simulate the command that would send to the ArduinoISP if I was to burn a bootloader. To find out what command it was, I went into the preferences of the IDE and I selected the option to "show verbose output during upload" and copied the command. I also copied the command of "make upload" and combined them together. I connected one of my Arduino Nano boards to the header in the LCR-T4 board as per the first example Nano-to-Nano above and issued the combined command:
$./avrdude -C/home/tomas/Downloads/arduino-1.8.3/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyUSB0 -b19200 -e -B 1.0 -U flash:w:./TransistorTester.hex:a -U eeprom:w:./TransistorTester.eep:a
This command is basically running avrdude (which I copied first from the Arduino folder to the "mega328_st7565" folder to save me from incompatibility issues between the version installed and the one that comes with the IDE) using the Arduino configuration file, "-v" for verbose output, "-p atmega328p" for the chip to be programmed, "-c stk500v1" for the programmer that in this case corresponds to the Arduino as ISP, "-P /dev/ttyUSB0" for the COM port where the Arduino Nano is connected, "-b 19200" is the baudrate (I tried higher values but failed), and the rest of the parameters are coming from the "make upload" command and are described in the avrdude manual (I'm not that bothered about them to be honest).
So after a couple of minutes it flashed the chip with some minor issues like the screen was upside down from the original firmware and with a bit of an offset. There's a mention in the manual about certain parameters that can be configured for this board so found them in the "Makefile" within the folder. These are clearly commented so I won't go into detail, just changed the horizontal offset from 4 to 0 and vertical flip screen from 1 to 0 in order to get things working properly, "make" once more, upload again and working fine.
One of the things I noticed straight away with the new firmware was the test leads capacitance compensation and initial calibration that can be performed which in turn gave very accurate readings on various capacitors when compared to my multimeter.
To finish off, I got a small container box and some mounting screws and brackets to put it all together with a 9V battery inside so here is the result. I hope you found this useful and entertaining.
PS: I found the faulty capacitors to be effectively faulty and after replacing them the 19" screen is working like a charm