MightyWatt: Lessons learned

Smart people learn from mistakes of others. And now you have an opportunity to learn from mine :-)
When I was developing MightyWatt, the Arduino Electronic Load, I had to change a lot of things from the first desing on breadboard.

Using FET in linear mode is generally a bad idea. But these devices are so much more convenient at high currents than BJTs. During development, I learned what is FBSOA and that all datasheets are not created equal. FET experience thermal instability in linear mode at high Vds and Ids. This instability is known (now even to me) as the Spirito effect:

P.Spirito (M. IEEE), G. Breglio (M. IEEE) V. d’Alessandro, N. Rinaldi (M IEEE)
Dept. of Electronics Engineering, Universita di Napoli “Federico II”, Via
Claudio 21, 80125 Napoli, Italy. 0-7803-7318-9/02 IEEE paper 2002

But not all datasheets account for it in their FBSOA curves. Mostly International Rectifier datasheets do have this kind of information.
So during testing, I fried three FETs in linear mode before finding the correct device. Luckily, IXYS semiconductors manufactures an entire series of FETs designed to operate in linear mode. The series is designated "L2" and is the kind of FET I finally settled on. The drawback is that they are more expensive at the same Rdson/Ids/Vds combinations than the standard "switching" FETs.

Measuring the temperature
Knowing the juction temperature of a FET is very important for the "load" kind of project. It directly determines the maximum safe power you can dissipate. But how to measure it? There are some articles that use the intrinsic diode as a temperature sensor. Fine, but it would probably need calibration of every single FET. The principle is basically this: You heat the FET in linear mode, then switch the load off and immediately measure the forward drop of the diode. It is proportional to junction temperature so you should be able to estimate it. I didn't go that way.
Thermal imaging is a convenient way of measuring the surface temperature. Provided you know the emissivity of the material and you actually have access to a thermal camera. I am lucky enough to have access to Flir i7 thermal camera at the institute where I study. But such technique is of course only good for calibration of other temperature sensor. The case temperature is lower than the junction temperature but not that much. Yes, there are thermal resistances from junction to case in the datasheet but they relate to the metal pad that is connected to the heatsink and hence not visible to the thermal camera. And you won't be able to accurately calculate the heatflux from the side of the FET to the surrounding air unless you do a lot of mathematical modelling. So an educated guess and a healthy safety margin is necessary. 

Here are the techniques I tried for measuring the case temperature:
1) Mounting a TO-220 digital thermometer in the same fashion as the FET, thus measuring the heatsink temperature. This turned out to be the slowest method. The TO-220 package has high thermal capacity so its thermal impedance is high.
2) Gluing a through-hole thermistor on the side of the FET using a thermally-conductive epoxy. This turned out to be faster than the TO-220 thermometer but also quite slow. The reported temperature was also a lot lower than the actual (thermal camera) case temperature. The good thing is that this method is cheap but you have to mess with epoxy.
3) Gluing a small PT100 thermistor on the side. This was faster than the regular thermistor because the PT100 was much smaller. But then again, there is the epoxy and you need at least one precision op-amp to convert the resistance to useful voltage for the ADC. Good method but expensive.
4) Using a thermocouple. Very fast response because the thermocouple is very small and very well thermally conductive. But needs even more expensive circuitry than the PT100 and epoxy again.
5) Placing a tiny (0402) thermistor beneath the FET and coupling it using thermal grease. This turned out to be faster than the PT100 but slower than the thermocouple. It lagged behind the thermocouple by just a couple of seconds. The advantage is very low cost and no need for epoxy. This method is the one I finally settled for. Easy, cheap, and adequetely fast response. The temperature is still different from the one from thermal camera but it can be easily recalculated. In fact, when the thermal camera reported 105 °C, the themistor was at 92 °C. If you know this, you only have to adjust the thermal limits. Say, if the junction temperature is 10 °C above the case temperature, then it was 115 °C. Ambient was 22 °C so it was 93 °C more. The thermistor reported 92 °C, 70 °C above ambient. 
This means that the actual difference is 1.33 times the measured difference. Recalculating to 25 °C ambient and 150 °C junction, the thermistor would report 119 °C. I set the maximum temperature to 110 °C to give me some safety margin. This would imply 94 Watts maximum power so the 70 Watts is very conservative.

Measuring the current
I was already convinced to use INA210 series current shunt monitors but my first attempt was with a 2512 power resistor acting as the shunt. It turned out that in the recommended layout, with sense traces heading to the centre of the resistor, a part of the current being measured goes through solder. And you know what? Solder has a horrible thermal coefficient for resistance. I got extremely unstable current values, differing up to 10 % from the real values. Because the resistor is directly connected to FET, you don't have to worry about power rating very much. It is thermally coupled to the heatsink so it is cooled by it. But it is also heated by the FET. I had to replace the resistor with a more special "four terminal" model from Vishay Dale. Now no solder would be between the measuring and power "terminals". Problem solved.

Preventing oscillations
FETs have large gate capacitance and that means oscillations when driving them with op-amps. I knew that but the actual solution to prevent the oscillations was the winner of a trial and error contest. What works on breadboard does not necessarily work on PCB. I tried various models of snubber circuit (RC, R-RC, ETC, I mean, etc.) but finally, the best solution was to actually increase the gate capacitance by placing a large, 10 microfarad, capacitor from the gate to ground. Without resistor, just utilizing the op-amp's output resistance. The oscillations only occur when the load capacitance is large enough than some threshold (different for different op-amps) but they fade out when the capacitance is very large.

Boosting the voltage
Gate voltage of such a power FET is more than the 5 V (more like 4.5 V) the USB can provide. I opted for swichted capacitor voltage doubler because the op-amp does not need a very large current or precise voltage. Anything between 7 and 20 Volts is OK. The first one I tried was LM2767 but it turned out to be too noisy, with its 11 kHz switching frequency. I replaced it with LM2766 with much less switching noise but unfortunately, the pinout is different so I had to change the PCB too.

Selecting thermal grease
High-performance thermal grease is a must for such an application. Luckily, thanks to the overclockers of the world, there is a big market for performance non-conductive thermal greases. I chose Arctic Silver 5 and it is perfect. But the wide selection thinned after I tried to get the service temperature range of the greases. The PC-modding industry does not produce datasheets. They produce PR leaflets. And CPUs run at much lower temperatures than I was planning to utilize. The Arctic Silver 5 was amongst the three greases I was able to get the service temperature for.

These were the major obstacles in my design efforts. I hope the knowledge will help someone, maybe you, to save some design time, components and swearwords.


MightyWatt Arduino Electronic Load

Update: Improved version now available on Tindie

Every now and then I was testing some batteries and power supplies. Usually by loading them by a BJT attached on heatsink and controlling the current by potentiometer. I read the current and voltage on two multimeters and estimated the load characteristics. But because I am naturally a lazy person, I decided to build something more automatic. An electronic load. I call it MightyWatt :-)

The basic idea is pretty simple. I connect the device under test to a FET and shunt resistor to measure current. The gate of the FET is driven by an op-amp that maintains either constant voltage across the load or constant current through it. It all attaches to Arduino Uno R3 as a shield. Simple as that. And now for some details:

The main transistor is IXYS L2 series FET that is tailored for linear applications such as this. I use TO-247 package but any through-hole version will do. IXTH75N10L2 has 21 mOhms Rds on and IXTH110N10L2 has 18 mOhms but is also more expensive.

I chose 50x50 mm BGA-style heatsink with 5V fan because it suits the Arduino's outline. It can easily sink 70 Watts. The transistor is mounted on the board upside down so the heatsink can be attached from the top. To get a good thermal contact, the transistor sits on a 1mm silicone pad compressed to about 0.8 mm. There is also Arctic Silver 5 thermal grease, which, at these heat fluxes, is very important.

Measuring the temperature
Underneath the transistor, there is a tiny 0402 thermistor. I cut out a window in the silicone pad for the thermistor and filled it with electrically non-conductive thermal grease. In this way, I get fast response and I don't have to glue anything on the transistor. The measured temperature is, however, lower than the junction temperature so a healthy safety margin is necessary. See the thermal image at the end…

A simple resistor divider between the inputs is used for voltage measurement. Its output is buffered by an op-amp before being measured with Arduino. There is also a selectable 5.7x gain for low-voltage inputs, accomplished by an analog switch. The full-scale is 30 V but the FET can actually handle 100 V.

Current is measured by voltage-drop method across a 4 milliohm power resistor. INA214 current shunt monitor amplifies the signal 100x for a 10 A range. The load would easily handle 20 A and probably could be extended to 30 A if needed.

To set the desired current or voltage, a 12-bit DAC is used. I chose MCP4276 from Microchip. It is cheap and reasonably accurate.

Modes of operation
The load can be operated at constant current (CC) or constant voltage (CV). At CC, the signal from ammeter goes to the inverting input and the DAC signal to the non-inverting input. At CV, the signals are switched so the DAC goes to the inverting input and voltmeter signal goes to the non-inverting input. The signals are switched using an analog DPDT switch. The same style as the voltage gain is controlled.
Because the FET's gate voltage needs to be larger than the 5 V supplied by Arduino, there is a switched capacitor voltage doubler which powers the op-amp.

Other stuff
The load also has some protection against ground loops (PTC) and voltage spikes (TVS). There is a reference voltage of 2.495 V and a single red LED that can be used for whatever is needed but it was thought as an overheat indicator. However, with good software, overheat is very unlikely.

The load as very variable but my version has these specifications:
  • 70 W
  • 10 A
  • 30 V / 5.25 V
  • 25 milliOhms minimum resistance
  • Constant current and constant voltage modes in hardware
  • Constant power and constant resistance in software
So here goes the schematic:

This is the (hand) assembled PCB:

  • Top: DAC.
  • Top right: Voltage reference.
  • Bottom right: Fan connector, red LED.
  • Bottom middle: Screw-clamp terminal, PTC fuse.
  • Bottom left: Current shunt monitor.
  • Left: Switched capacitor voltage doubler.
  • Top left: Op-amp for gate driving and voltmeter buffering. Two analog switches for voltmeter gain and CC/CV switching.
  • Centre: The main FET lying on a 1mm silicone pad with thermistor underneath. Between the FET and the terminal is a 1.5kW transient voltage suppressor.

Nothing much on the bottom except the current measuring resistor and pinheads to connect the load to Arduino. The pinout is for UNO R3, the connection for I2C is different from earlier Arduino versions and it was convenient for me to put the I2C pins to the new location.

And the whole unit with heatsink & fan running:

The sketch I programmed uses serial communication to send status and receive commands. The Arduino's ADC is oversampled to 12 bits for voltage and current. Temperature was left 10-bit. The ADC sampling takes the most time from all the processing.
Voltmeter, ammeter and DAC all need calibration because of some offsets and part tolerances. But a simple linear calibration curve is sufficient.
CC and CV modes are hardware so the control loop is only measuring. But there are also constant power and constant resistance modes, which are software and performed at constant current hardware mode.
There is a watchdog in case commands stop arriving, the load resets itself in few seconds. That means there has to be a constant stream of communication, which brings me to the PC side of the program:
The Windows application was made using C#. It maintains a constant monitoring of voltage, current and temperature and can send commands to set the load. It has also some datalogging capabilities. The only trick was to make it in two threads so that one is constantly communicating with the load and the other is for GUI.
If you were so brave to read up to here, you can have all the source files from my public Google Drive folder.

Some measured data
Two fresh Ikea Alkalisk AA batteries connected in series and measured with increasing current over approximately 30 second:

Single GP ReCyko+ AA accumulator discharged at 1 A. Freshly charged but been in service for 3 years. Still, it had some 80 % of its rated capacity.

The heat of the battle
I run the load at 70 Watts for 30 minutes and tried to find the hottest spot on the case. The ambient temperature was 22 °C and the thermistor reported 92 °C. The case temperature on the sides is quite close to the junction temperature so at 105 °C there is still a healthy safety margin. If the junction temperature was 10 °C higher than the case temperature, it would mean a thermal resistance of 1.33 °C/W. The maximum power dissipation at 25 °C ambient temperature would then be 94 W with the junction temperature at its maximum – 150 °C. But I wouldn't go there for a long amount of time.


Connecting Kern balances to PC

So we got an idea in the lab: Let's monitor how a sample dries out by continuously measuring its weight. Because all the balances were taken, we bought two new cheap balances from Kern. They were cheap but they also had a pretty decent resolution of 1 mg. Not bad for 300 €. We thought. But you know what they say, you get what you are paying for.
The balances (series PFB) have RS-232, aka serial port connector so we bought a RS-232 to USB adaptor based on one of the FTDI chips. We connected them, used Realterm for communication and guess what: nothing happened. We tried about five different adaptors we could find lying around the lab but none of them worked. Even more strange was that our analytical Ohaus balances were working fine with the adaptors. So the problem was somewhere within the new Kerns. The manual did not help much. The company is a german one but I suspect the work has been done far more to the east. The english in the manual somehow has a dodgy feeling. The manual did not help us at all. Especially the parts of menu which were documented in the manual as "not documented". Thank you very much Kern!

Partly desperate and partly angry we decided to buy the original Kern software and cable. For a hefty 175 €. We thought that if it wouldn't work, we return it all as defective and if it would work we have to find out why.
After many weeks, a CD and a cable arrived. Earlier, I said that you get what you pay for. But sometimes, you get far, far less. The Kern original balance software is a piece of shit. Honestly, it looks horrible as if some high-school guy made that over a weekend (after getting pretty high on Friday). And the cable was a simple RS-232 to RS-232 cable. Not even a USB we asked for. But it worked with our RS-232 to USB adaptor and now it was time to do a little hacking and find out why.

Well, have you ever heard of a null modem? In the times when emails were delivered by homing pigeons, there was a machine called a teleprinter. I have no idea what that was and I don't want to know but apparently, to connect them to modems, you had to use a null modem cable. Which is a crosslinked RS-232 cable. And for some nostalgic reasons, our Kerns are using this null modem thing. So the only trick was that the TX and RX lines had to be crosslinked in the cable. Damn you, Kern! I found it after disassembling the cable, which itself costs an outrageous 45 €. Finally, for the second balances, we ordered a cable and two connectors on Conrad and assembled the second cable for about 5 €.

But that shitty day wasn't over yet. We decided not to use the Kern software (which we practically wrote off) but rather Realterm which was now working. So we set Realterm to send weight command (ASCII "w") every 10 seconds and log the response so over a few days, we would get the drying curve. But every few hours, the balances with the non-original cable tared themselves. We had no idea why. The cable was the very same that Kern uses and the connectors too. The only limitation RS-232 should have is a 2500pF capacitance which we would hardly exceed with two meters of cable. But to be sure, I salvaged a CAT5 UTP ethernet patch cable and used one of the twisted pairs for the TX/RX and one cable for ground. Also, I trimmed the cable to 30 centimeters. The situation improved, the balances stopped taring themselves but every now and then, there is a missing measurement. The balances just do not respond sometimes. After analysing the file created by balances with the original cable, I found out that they too have some missing measurements. For me, it looks like the communication feature is really shitty. These Kerns are good as budget lab balances but only if you don't need the connectivity.



Measuring temperature is a common task. Luckily, many electrical quantities change with temperature. Well, luckily… sometimes it is a big bugger. Diodes change their forward voltage, resistors change their resistance and thermocouples their voltage. There is a plenty of temperature sensors out there but not all are created equal. I was always fascinated by contactless themometers. Heck, I use IR themometer when I cook all the time. And that is why I ordered this:

The TMP006 is a contactless temperature sensor from Texas Instruments, an infrared thermopile. Unfortunately in tiny BGA package with 8 balls and 0.5 mm pitch. It has a thermocouple inside which is heated by the radiation of the measured object. But because it has to be connected to the rest of the die somehow, it is also heated by the die/board itself. So there is another temperature sensor, this time sensing the local temperature. Then, from the difference between these temperatures, you can calculate the temperature of the measured object. It is not very straightforward but TI have provided a user guide with the necessary equations. Some specs? Well, the range is -40 to 125 °C and it is connected via I2C. It can make 4 readings per second but it is more recommended to take just one per sec (lowering the noise of course).

How to solder
For a casual diyer its BGA package is a problem. Furthermore, there is a recommended layout which I reckon would be good to follow to get the best accuracy. There are breakout boards from Sparkfun as well as from Adafruit both for 15 $. I decided to design my own breakout board and have it manufactured in a local PCB company. I followed the TI's guidelines and made a small breakout with the TMP006 and one bypass capacitor of 0603 size. And with such a board, it is actually not so hard to solder the chip.
Silkscreen is necessary to precisely align the chip. And a magnifying glass. But before doing so, you have to use a good flux because the little balls on the bottom do not have any. I used some tacky Chipquik flux. 
The bypass capacitor makes a good indicator of the reflow process. If you use a lead-free solder paste, it will reflow at about the same time as the balls on the BGA. I use a crude hotplate for reflow soldering – a 4 mm thick duralumin plate heated by a regular gas stove. I am at the reflow temperature after 3–4 minutes. It is a poor-man reflow setup but so far it worked every time. The plate is covered with Kapton tape so I can take temperature readings using an infrared themometer (the duralumin has a hard-to-determine emissivity).
Maybe i was just lucky but it reflowed correctly. Unlike larger BGAs, you can check all the connections visually because they are on the sides (you only need a microscope or magnifying glass). Finally, I soldered the pinheads and was almost ready to go.

After soldering
For the best accuracy, you have to clean the board thoroughly, preferably in ultrasonic bath. I am lucky to have one industrial ultrasonic bath in my lab so it was no problem. But you can get a cheap ultrasonic bath for less than 30 € these days. TI recommends demineralized water. The final product of my effort was ready…

TMP006 on a very basic custom breakout board.

I used Arduino for I2C communication and it went with no problems. So I got it connected and now for calibration… yes, the chip is not factory-calibrated. You have to DIY. And it is not that easy because it measures surface temperature, which tends to be different from the bulk temperature. Calibrating it with a contact thermometer could lead to serious errors. Just make a cup of coffee/tea and measure its surface temperature and its bulk temperature. They can easily differ by 10 °C.
So it is best to calibrate it with another IR themometer. Or thermal imaging camera. I have access to both so I used Flir i7 because it is just more fun than an IR thermometer. But both will suffice.
For calibration, I used a cup of tea (65 °C) and a bottle of Becherovka from the fridge (-14 °C). And a piece of paper for the ambient temperature (22 °C).
After some math magic, you are supposed to get a linear correlation and finally calculate a single value which is then used for calculation of the temperature of measured object. However, to my surprise, the calibration values weren't on a straight line. 

The catch
It turned out the sensor had a major flaw. The object being measured does not only change the thermocouple's temperature but also the board temperature so the final calculation is inaccurate. Very inaccurate until some kind of equlibrium is established. And that can take a loooong time. It is obvious if you think about it but it is not so obvious why TI didn't account for this. And apparently, I am not the only one who noticed so TI published a workaround paper that shows how to compensate for the change in board temperature. It is done by processing 4 consecutive samples. I did that and it worked. 

The bottom line
So finally, I got a sensor that was measuring temperature with about +/- 3°C uncertainty. Which is nothing special but remember this is a (relatively) low-cost contactless sensor. So after all, it is not that bad.
There is actually a pretty cool project using the TMP006 available on Instructables – an Arduino controlled coaster which changes backlight according to the cup's temperature. So, would you use this sensor?