Teensy Load is a project based on the Contextual Electronics Current Sink Or Swim course. The idea here is to develop a programmable load that can be used for for battery discharge experiments, tracing battery I/V curves, and so on. The Teensy Load extends the Current Sink Or Swim design by connecting to a Teensy microcontroller board to allow for programmatic setting of current and voltage levels and recording of the actual current and voltage levels provided by the device under test. Very simple firmware on the Teensy deals with the level setting and data collection, and a couple of Python GUI applications running on a PC talk to the Teensy over a USB serial connection to provide a nice interface for using the thing.

Current status: waiting for boards. Software development stalled a bit because it's less interesting to do that without the hardware in my hands.

## Design

Click on any schematic image for a full-size version.

At the top level, there are some pin headers to connect the Teensy and a connector to attach the device under test. The idea is to power everything from the Teensy's 3.3V supply. That can provide 250 mA, which seems like it ought to be enough, but I'm not sure how you might estimate accurate power requirements for a circuit like this. I started trying to do that, but realised I didn't know what I was doing...

Following the approach in the Current Sink Or Swim course, there's a current programming section, which in this case is driven by an I2C DAC to set the programming voltage that controls the current draw (with limits of 0 - 10A, set by a resistor divider between the DAC and the op amp input). As the FET used to draw current from the device under test, I'm going to use the Infineon BTS141, which has a pinout like a FET but has all sorts of protection features built in (overcurrent, thermal, etc.). Seems like a good part for someone who isn't quite sure what they're doing! There's also an additional op amp unit used as a current level sense, with its output fed to one of the Teensy's ADC inputs (they have a relatively low input impedance, hence the op amp as a buffer). That gives a way to monitor what current the device under test is really providing. (I'm using a TI TLV4333 quad op amp here, which seems quite jellybeanish, but ought to do the job.)

Finally, there's a voltage limiting section, which sinks current from the FET gate if the total voltage across the device under test is too large. The voltage limit level is set by another DAC through a voltage divider to the input of an op amp used as a comparator, with the other comparator input coming from a voltage divider connected across the device under test. A final op amp buffers that voltage level for input to a Teensy ADC input for voltage monitoring. The way the voltage divider between the DAC and the op amp is set up limits the voltage range to 0 - 20V, but the idea is to control the maximum voltage setting depending on the current demanded to keep the total power dissipation in the FET below 20 W, which is what I think the heatsink I'm using will handle.

This is the first electronics design I've done where a substantial part of the design is stuff I've made up myself, so there are a few open questions about it all:

1. Is this a reasonable approach to this kind of thing? Am I missing anything obvious? Have I done anything that's just plain wrong? I think it's mostly OK, and it's good to be able to take the Contextual Electronics design ideas and extend them a little, rather than starting from a completely blank slate.

2. Is there any way to get a reasonable estimate of the power requirements of something like this to work out whether driving it all from the Teensy 3.3 V supply is going to work? I'm guessing that the only way to do this is to do a detailed component-by-component power budget. That ought not to be too hard in this case, since there aren't lots of modes of operation, but it would definitely be much harder for a more complex design. Are there tools to help? I don't know yet.

3. Should I add any extra protection components? For example, is it worth putting a Zener diode (with Zener voltage somewhere between 2.1 and 3.3 V) between the negative input of U102C and ground to protect the op amp input from excessive voltage from the device under test? I don't know about this. Presumably I'll find out when I have the thing on the bench!

4. Is using a pair of DACs to set the current and maximum voltage levels overkill? Would it be simpler to use a couple of PWM outputs from the Teensy with low pass filters? Originally, I didn't go that way because I didn't know how to calibrate the resulting voltage levels, but a bit more thinking makes it obvious that they're just linear in the PWM duty cycle. Still, I like the idea of using the DACs.

5. Generally, are the component choices OK? The BTS141 seems solid, the DACs were chosen to have predictable zero output at power on reset, the op amps don't seem to have very demanding requirements, and the heat sink was chosen to handle 20W of power dissipation in the FET.

## Layout

It took me two tries to get a board layout I was reasonably happy with. This is the first project that feels like "uncharted waters" where there are a few things where I'm really not sure what I'm doing.

I think that the critical bits of the design are OK: fat traces (with 2 oz. copper) for the high current loop (and the loop made physically as small as possible given the sizes of the components), power ratings for the sense resistor and FET should be OK (I think the heatsink might be overkill: the 3D render looks pretty ridiculous anyway...), and everything else pretty vanilla.

There is some "safety by design" using voltage dividers to make the full range of the DACs used for setting the current and voltage limits correspond to the maximum ranges of those things that I want. The only limit that needs to be managed in the Teensy firmware then is the overall power limit, done by capping the voltage limit to make sure the power limit isn't exceeded.

OSH Park's 2 oz. copper service for cheap boards is slower than their regular service, so now the long wait begins...

## Assembly

Waiting on boards from OSH Park. Free shipping from the US to Europe has been disrupted recently, so they're taking a lot longer than expected!

## Firmware

The Teensy is connected to a PC over a USB connection, appearing as a USB serial port on the PC. The user interface software PC and the firmware on the Teensy communicate using a simple ASCII protocol. All messages from the PC to the Teensy just give values for the Teensy ADC sample rate (setting this to zero stops sampling) and the current and voltage limits to use (as integer values in the range 0-1023 for the 10-bit DACs).

The firmware on the Teensy just loops waiting for commands from the PC (setting the current and voltage limits if it gets a command) and sampling the current and voltage values for the device under test at the requested sampling interval, writing the resulting values on the serial connection to the PC. There's not a whole lot to it, since I decided to put most of the "interesting" bits of the software side of things on the PC.

One thing I did do, which makes life a bit easier, is to organise the firmware to make it easy to use it in a simulator mode, where the Teensy generates data itself without needing to be connected to the Teensy Load hardware. This makes developing the Python software to run on the PC much easier. All the main loop code is shared between the firmware for connecting to the hardware and the simulator, as is all the serial event handling for talking to the PC. The only part of the firmware that's unique to the hardware side or the simulator side is the actual level setting and data sampling.

## Software

This is only at an early stage of development, but the idea is to have three separate applications, all written in Python using the Gtk UI toolkit, and all using the Glade GUI builder to lay out the user interface. I've not used Gtk before (though I've done a lot of GUI programming using other toolkits), but at least with Python and Glade it's quite a pleasant experience.

The three applications are:

• tl-meter: a real-time "meter" view of the current and voltage values from the device under test;

• tl-iv: a utility to automatically trace out I/V curves for batteries and power supplies -- you set up some ranges of load currents you want to look at, and the software samples enough data to make a useful I/V curve;

• tl-discharge: utility to record discharge curves over time -- set the current draw and voltage limits, and the software regularly samples the current and voltage supplied by the device under test, stopping when the voltage falls below a given limit, and generating voltage and current versus time plots.

So far, I've done a bit of work on the tl-meter application (mostly just the user interface), but haven't got much further. Once I have boards in my hand I'm hoping this stuff will go more quickly!