Updated 05/13/17: It is possible to use an Arduino to upload new firmware to the HB transistor tester. I added a tutorial on using the Arduino clone from HB #16 to upload firmware to an ATmega328P. Also, the GitHub project for the transistor tester seems to have two main authors – Markus and Kübbeler. This tutorial for the USBTiny uses the firmware build by Kübbeler while the tutorial using the Arduino uses the build by Markus.
This is a short tutorial on how to change or update the code used on the MCU for the Transistor Tester included with HackerBoxes #18. This involves a few steps to get it working, none of which are particularly difficult, but it is a bit of a pain in the ass because there a lot of information online to sift through. The HB kit appears to be a Chinese kit that uses a ST7735 color display, so my starting point was the project directory for the ST7735 in the GitHub repository for the Transistor Tester.
A few disclaimers – there is the risk you will brick your MCU. Also, the functionality found in the GitHub projects may or may not exactly match what came on the kit’s MCU. For those reasons, I did not reprogram the AT328P MCU that came with the kit. Instead, you could re-use the AT328P that came with a prior HackerBox or just order some off Amazon. They’re reasonably cheap, and there’s no reason to risk bricking the original MCU.
Also, my working environment is Linux, and I used a USBTiny programmer to communicate and program the MCU (which worked great). It may be possible to use an Arduino as ISP to do this, however I didn’t test it – YMMV. You’ll also need a few various components from your parts bin – a crystal or resonator (something like a 8 MHz or 16 MHz), a couple of 22pf caps, a 10K resistor, and a 100nF or so cap to smooth out the power. Last, you’ll need to be sure you have the proper libraries installed. I installed the following:
- sudo apt install binutils-avr
- sudo apt install avrdude
- sudo apt install avr-libc
- sudo apt install gcc-avr
My goal here is just to provide enough information to help someone else get started with programming a new MCU for the HackerBox #18 component tester and not get too bogged down in details:
Download the Transistor Tester repository from GitHub and make a few changes
Download the GitHub repository for Transistor Tester and extract it to your local machine. The project folder I used is located in Software/trunk/ST7735/. Open the Makefile and check that:
- line 26: PARTNO = m328p
- line 285: OP_MHZ = 8
- line 376 (approximately), add your programmer info here. Mine looks like:
- Save the changes.
Move up one directory to: /Software/trunk/ and change setup.mk:
- line 6: EFUSE_VAL = 0xFC
- Save the changes.
Move back to the /Software/trunk/ST7735/ directory. Typically, I issue command lines for clean and make at this point:
- make clean
This will generate object files as well as the two main files TransistorTester.hex and TransistorTester.eep.
Setup for programming the new MCU
As I mentioned, I used an ISP from Sparkfun – the AVR Pocket Programmer. avrdude supports a lot of programmers, and I’m sure others will work too. It’s possible someone could get this to work using an Arduino, but I didn’t test this out. If you need a better wiring diagram than the crappy one I made, it’s all over Google and very easy to put together. Just be sure you have your header pins attached to the correct pins on the MCU. Here is the pinout for the AT328:
This is a picture of my breadboard with the wiring labeled. RST, SCK, MISO, MOSI, GND, and VCC connect to the corresponding pins on the 6 pin header for the USBTiny programmer.
Programming the MCU
Be sure your AVR programmer is plugged into your PC and that the breadboard is powered up. You can check your connection using avrdude from the command line using your AVR (mine is usbtiny): avrdude -c usbtiny -p m328p. If you’re connected, you should see a response that looks like:
If you’re connected, you can go ahead and program the MCU. Be sure you are in the /Software/trunk/ST7735/ directory, and from the command line enter: make program.
It will take several minutes to complete. My usbtiny gave me a few errors that looked like: avrdude: error: usbtiny_receive: error sending control message: Protocol error (expected 4, got -71) which apparently can be ignored most of the time and didnt seem to affect me at all.
At this point the new MCU should be programmed and ready to use with the Transistor Tester.
Your MCU may need to have its fuses set. Without the fuses set properly, the MCU will not run the board correctly, not run at all, or will not program. To set the fuses, move to the /Software/trunk/ST7735/ directory, and enter the following on the terminal command line: make fuses-crystal. You should see something similar to:
There is a possibility that you already have a bootloader installed on the MCU and that some of the fuse settings are set incorrectly. I had this happen with one MCU, and running the make fuses-crystal ran with an error but did get the MCU working.
Changing the C files
The C files for the project will be in the /Software/trunk/ directory. It’s worth mentioning that it’s a real pain to do any serious programming this way, and having an ISP header on the board is a lot more effective than pulling the chip out, reprogramming it, and then replacing it. An easy starting point with changing the code is to alter one of the message strings defined in Transistortester.h as well as the main loop in main.c. Be careful not to make the strings too long.
I think my next task will be try to create a proper header on the board. Hope this helps someone else out – good luck!