Sep 222018

So, I’ve gotten back to this project having spent a lot of my time on work, the Yarraman to Wulkuraka bike ride and the charging controller #Solar-powered cloud computing — just to name 3 things vying for my attention.

In the test board, I had wired up some LEDs for debugging, dead-bugged 0805s, which were hooked between the output of the octal latch and 0V.  I omitted the series resistor, as I presumed that, given the output was PWMed with a maximum duty cycle of ⅛, the LEDs shouldn’t burn out.

Turns out I had forgotten a property that all diodes exhibit, that is the desire to clamp the voltage across them.  Today I was testing the board, and wondering why some channels were dim, others didn’t work at all, but one worked so much better.  Did I accidentally put the wrong current limiting resistor in series with the drain?  No, all checked out as about 12 ohms.

I put a program on the MCU that just turned a channel on when the button was pressed.  No music, no fancy PWM stuff, just turn on a LED when the corresponding button was pressed.  Measuring the gate voltage showed about 2V.

Even with the PWM output forced low, the output was still 2V.  Moreover, I was using my new bench supply, and with nothing running, the circuit was drawing ~300mA!  Why?

Turns out, the LEDs I had dead-bugged in, were trying, and succeeding, in clamping the output voltage.  2V was just barely enough to trigger the output MOSFETs, but clearly this was borderline as some worked better than others.  I was likely in the linear region.

Snip out the common connection for the LEDs to 0V, and the problems disappeared.  I’ve dead-bugged a 1kOhm resistor in series with the lot, and that’s got my debug LEDs back and working again.  The MOSFET outputs now work properly.

The bigger chunkier MOSFETs I bought by mistake could have worked just fine: maybe I was just driving them wrong!

Two prospects have crossed my mind:

  • Getting the MOSFET board made professionally
  • Getting a board that combines all components onto one PCB made professionally

The version that is shown was really designed for the home PCB maker to be able to produce.  The traces are wide and the board is fundamentally single-sided: when etching, you just etch one side of the board and leave the other side unetched.  When drilling the holes, you just countersink the holes a bit on all pins not connected to 0V.

A smaller board with everything in one would be worth making now that I’ve proven the concept.  Not sure there’s a good reason to go to SMT at this stage: I still want to make assembly simple.  The thinking is the all-in-one would have some headers so you can conceivably break things out for other projects and just omit parts as required.

This could theoretically be entered into the #The 2018 Hackaday Prize as part of the musical instrument contest, as that’s what it is: it’s a musical instrument for the severely physically handicapped.  There is a video of a slightly earlier prototype in this post .

Code wise, I’ve done little.  The basic functionality is there, it makes noises, it flashes LEDs, that’s about what it needs to do for now.  I did have to increase the start-up delay so that the buttons were detected properly, as without this, if I used my bench-top supply, it would fail to see any inputs.  People aren’t going to notice 100ms boot-up delay vs 1ms, but it makes a difference if the power supply is a little slow.

Jun 112016

So, I’ve built the controller. The design was pretty simple. Using an ATTiny24A, I’d monitor the voltages of the battery and two power inputs, and code would decide which input to use, if any. It also could use the in-built temperature sensor to control cooling fans. This is the schematic I knocked up this morning.

The values of most resistors are not critical. I found I needed 1kOhm resistors into the bases of the transistors as the MCU was not happy driving them directly. The transistors I’m using are BC547Bs controlling AUIRF4905 MOSFETs.

The only components that are critical are the voltage dividers on the ADC inputs. I’ll be using the built-in 1.1V reference in the MCU as that’s what’s needed for the temperature sensor anyway.

This was a bit of an exercise in reviving old brain cells as it’s been some time since I’ve done a proper PCB myself. This is a one-off prototype with mostly larger components, so no point in getting boards fabricated. I did it the old fashioned way, using a dalo pen then etching in a bath of Ferric Chloride.

That gives you an idea of what the board looked like prior to population. The underside was covered with tape to prevent it from being etched. It took a while, and I think I could have upped the concentration of the solution a bit, since it did leave some tracks un-etched.

Perhaps my solution is getting a little old too… the logo on the bottle really dates it. I found I had to attack the gaps between some tracks with a knife since the etchant didn’t quite get it all.

There are no tracks on the bottom, it’s just one piece of un-etched copper, to act as a ground plane. I guess the construction style is a cross between Manhattan and groundplane (dead-bug) construction. The constructed board looks like this.

I’m not sure what all the LEDs will be doing at this point. Three share pins with the ICSP header, which means they flash as the board is being programmed… useful for troubleshooting ICSP issues. The IC socket is a cheap 14-pin one, I just bent the pins to mount it flush to the board. The 10uF tantalum on the output of the 5V PSU is possibly a 10V one. Where the electrolytic is, is where I had the 330uF tantalum mounted, and it went bang when I gave it 12V.

I tried the following program on the board which just steps through all the LEDs and MOSFETs:

/* board.h */
/* LEDs */
#define LED_U1_BIT		(1 << 7)
#define LED_MOSI_BIT		(1 << 6)
#define LED_MISO_BIT		(1 << 5)
#define LED_SCK_BIT		(1 << 4)
#define LED_U0_BIT		(1 << 3)
/* MOSFETs */
#define FET_MAINS		(1 << 0)
#define FET_SOLAR		(1 << 1)
#define FET_FAN			(1 << 2)
/* test.c */
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdint.h>
#include "board.h"
uint8_t heartbeat = 10;
int main(void) {
	PORTA = 0;
	PORTB = 0;
	/* Test sequence */
	while (1) {
		PORTA = LED_U0_BIT;	_delay_ms(1000);
		PORTA = LED_U1_BIT;	_delay_ms(1000);
		PORTA = LED_MOSI_BIT;	_delay_ms(1000);
		PORTA = LED_MISO_BIT;	_delay_ms(1000);
		PORTA = LED_SCK_BIT;	_delay_ms(1000);
		PORTA = 0;
		PORTB = FET_MAINS;	_delay_ms(1000);
		PORTB = FET_SOLAR;	_delay_ms(1000);
		PORTB = FET_FAN;	_delay_ms(1000);
		PORTB = 0;
	return 0;

That seems to prove the hardware is alive, and now I just have to get the software working. Now to try out the toolchain I built!