Simple audio mixer


I have one low cost TPA3116 amplifier which has got more usage than I initially thought. I ended up using it in the living room, it provides enough power and burns only 0.7W from the mains while ON, with no signal. So low that I don’t need to worry about shutting it down when there is no signal, so it’s on all the time. So on to the problem: I need to use it with 2 sources and having an additional one for the fellow guests to plug in the phone is useful.


While the idea of a multi source automatic selector has crossed my mind, I found a better solution: mixing. Since all sources have their own digital volume control, I don’t need individual, analog, volume control. So I added 2 more stereo inputs.

Note: there will be signal attenuation, however this still gives me ample output power for my needs. I pretty much leave this thing on max and just use the digital controls.

Opened the case up and drilled 2 extra holes

Disconnected the original signal lines

Add three resistors for each input. 6.5 K ought to do it..they were right there on the table.

Connect the initial RCA jacks to one set of inputs

And as you can see there is room for not one Jack, but 2 extra Jacks 🙂

Make connections, also use shrink tube

All complete



Bosch glue pen teardown


My cheap plug in hot glue gun died and looking for a replacement I found this: the Bosch GluePen

What does it do? it’s a hot glue gun for 7 mm glue sticks that warms up in 15 seconds. Charges via micro USB.

Much better than my old one that needed ~5 minutes to warm up for probably half a minute of gluing. I am very happy because of the fast warm up, wireless operation and small size. Battery should last 30 minutes and you get the low warning when there is 1/3 left, which I find enough.

You can grab one from or or or paying the same low price and helping support my website.

What’s inside?

Two screws later

The whole “mechanism” detaches from the sides

Let’s look in more detail on the PCB

The whole thing is controlled by an ATTINY24A microcontroller.

On the left side next to the micro USB there is a charger circuit labeled ‘3303’. On the top of the micro there appears to be a NTC used to monitor the temperature during charging. The holes are probably there in case a through hole termistor is used.

On the right side we can see the fuse and a IRF3711Z 6mΩ 20V HEXFET driving the heating element. At the glue melting end there is no temperature sensor, they are probably relying on the positive thermal coefficient of the heating element to achieve a rather stable temperature, as the manual quotes “approximately 170 °C”. Also there is a step up converter – used to generate ~12 V to drive the gate of the tranzistor, to keep it in the low ohmic region.

There does not appear to be any form of electronic temperature regulation – even after 3 minutes since I turned it ON the device maintains 12 V constantly at the gate of the tranzistor, no PWM or anything.

The wire going to the heating element is also connected to the micro, possibly to measure something, but what? Also the current through the battery while charging seems monitored by the micro as well, through the 0.22 Ω resistor next to the blue wire.

The battery is a 18650 made by Samsung, 1.5 Ah.

Checking the back of the PCB when…. what? Steinel? There appears to be a similar Steinel glue pen

The device charges via micro USB and does come with a 500 mA charger. While I can understand Bosch including one for comfort, for me this will go into the big pile of chargers that I might find some other purpose for. I simply have plenty of other chargers around the house for randomly charging whatever micro USB device needs to. Not to mention the 10 port Anker one on my desk which you can find at .


The device seems well built, has a good price and I am happy with it so far. It’s much faster to warm up compared to my old one which makes gluing faster.

You can grab one from or or or paying the same low price and helping support my website.

10002 Progress

This article is part of my 1000² Smart Home project. Check out the Architecture and Software and then move on to Hardware. An most importantly, check the Lessons learned and why I did what I did. There are already some first results, connecting all parts of the system.


Finally, enough pieces of the puzzle are starting to fit together in my Smart Home project, so that I can have some end to end functionality: press a button here turn on a light there, while watching the actual slider change a graphical interface. Oh, look the temperature is displayed as well. Hooray. Still need a few “cans of bug spray”, though.

First up, some nodes

Why are they called nodes anyway? Grabbing some old and new hardware prototypes, I made a basic system with a few types of nodes, what I thought was the minimum required to get started.

The node on the right most is the server or gateway node. Still using UART, hence the FT232 adaptor. It sends received packets to the raspberry pi in MQTTish format. It sends over the radio the received commands via UART, again in a MQTTish format.

On the bottom there is a simple remote node, with 4 buttons, which is battery powered.

On the left there is a PWM led driver connected to a lamp.

The left side one with the red antenna is a battery powered temperature, humidity and light sensor, of which I have a couple already.

On the top left there is a spy node, which dumps all traffic on the UART to get a check on the network. I have used this mostly on debugging.

On the top right is another LED driver, hooked up to my previously hacked lamp.


I am running things on a raspberry pi, but one could also re purpose some old computer.

I setup Mosquitto as the MQTT broker, to which Node-RED connects. In fact, I am using Node-RED as a link between the gateway node on the UART and Mosquitto, with everything else inside Node-RED interracting with the MQTT server.

Also built a small dashboard, here’s part of the hierarchy

Of course, one needs a very basic front panel, quite underpopulated at the moment. (there’s also a lesson here regarding halogen lights and temperature sensor placement).

Here are the nodes used to create the interface. With the exception of the function required to get time and date from epoch time, everything else is a normal node already included with Node-RED.

Monitoring the health of the nodes is also simple – since they transmit some parameters: the time since start (uptime), the battery voltage, the gateway RSSI for each and the average time spent in the loop. The number of packets received is also logged. Behind the scenes is very simple, since MQTT allows for wildcard selection of the same parameter from all topics.

Showing below is the time since startup of every node. For now they update this value every 10 minutes, but will change to longer once things are more stable. You can see a couple of nodes were reset some time.

A  tiny bit of “automation” connects 2 buttons from the remote node to the 2 LEDs, sending the ‘toggle’ command so that each press turns the light on or off.

A pair of motion sensor and light

I have a light on the hallway made of a LED strip and a motion sensor switch, pure analog stuff, to turn on when there is motion. I replaced this with a module that drives the LEDs. Yes, ugly and temporary wiring, but it is on top of a door frame where it cannot be seen…unless you are reaaaaaly tall. I have used the combination of the core module and the LED driver module, which means i can easily detach the core and take it for re-flashing, since I have not OTA update yet.

To make things more interesting, this module does not have a motion sensor attached to it. Instead, I made a separate one, attached to the ceiling. The PIR sensor (the new digital type that has no external IC) needs a higher voltage. As I said in Lessons learned, a step up converter is a bad idea. So I used the prototype PCB to build a charge pump (diodes on the bottom) and drive only the motion sensor at double the battery voltage. The charge pump is possible because I can route the internal 32 kHz clock to a pin.

The fully assembled module attached  to the ceiling lamp

The two modules work through the whole system, with node red making the rules and control. I am still playing with the optimal way to control such a setup, but node RED makes things quite easy. The setup has been running flawlessly for a few days now already.

The charge pump is more visible on the motion, light, humidity and temperature sensor I have monitoring my desk. Look at those tiny tiny diodes!


10002 Architecture and Software

This article is part of my 1000² Smart Home project. Check out the Architecture and Software and then move on to Hardware. An most importantly, check the Lessons learned and why I did what I did. There are already some first results, connecting all parts of the system.

Starting with a top down approach – what the system should do, it soon became clear that some devices will be custom and some will be off the shelf. Determining which is a long story in itself, but this heterogeneous environment needs to be administered somehow.


The system architecture is decides based on the requirements:

  • Give the user some interface, which should be accessible from the outside without compromising security.
  • Provide ways to interconnect multiple types of commercial off the shelf devices which can have different interfaces (X, Y, Z).
  • Interface with low power custom devices, called nodes.
  • Provide a simple way to create rules, automate and provide relevant information to the user.
  • Benefit from Artificial Intelligence to save the human from writing custom rules

This brings us the general picture of how things will interact. Briefly: MQTT will be used as transportation, OpenHAB takes care of the user interface as well as interacting with commercial devices. Low power sensor nodes use a gateway (GW) to exchange information. Rules and automation is handled both by Node-RED and openHAB, with a addition of AI later.



The central part of home automation is the control software. While this concept might be outdated in the world of IoT where every manufacturer wants to sell only his own, plenty of open source and commercial option for controller software have emerged. This “controller” type of software is supposes to control, manage, display, graph, talk etc while working with products from multiple manufacturers. This gives the user a nice central interface to control and display, coupled, of course with automation rules and scheduling, as opposed to using multiple applications or panels for each part of the system.

OpenHAB is my favourite of the few I have played with. I have selected it because it is open and has a comprehensive list of devices it can talk to, although I own extremely few such devices. They, of course, have rules for the user to program behaviour, nice graphs and working on persistence. On the negative side, they have multiple user interfaces, with occasional features scattered, making none of them the ultimate winner. I am planning on using Open HAB for the user interface and some rule making.

Node Red

Node Red is a cool new idea, coming from IBM, implementing flow based design. Multiple people use it for home automation and just like Open HAB it has a plethora of ready made possibilities to interface with existing products. It can run quite smoothly on a raspberry Pi offering a web interface for designing the flow. It provides ways to build a dashboard through simple hierarchies and predefined widgets, although some things are more limited than I would like.

At this moment is seems like the best support to try crazy stuff, like making the umbrella blink if it is going to rain tomorrow.


MQTT is something that is not really needed, using either Node Red or Open HAB messages can have any kind of format. But I decided to use it because it provides structure and can interface different software components, as plenty have built in support. The principle of MQTT is simple: there’s a central broker through which all messages go through.  A message is made of a topic, which is hierarchical, (like house/first_floor/bathroom/temperature) and a payload containing the value. I find the hierarchical naming a little bit against human nature but it does provide the benefit of easily selecting similar things through wildcards.

Continue to Hardware to check out the hardware I will use in this project and some first results.

Analog Discovery USB isolation


Back when I was deverloping the PSU burner, I wanted to have the Analog Discovery isolated from the common ground, to avoid noise and other issues. Since I did not have a way to do this, I ended up using a laptop on battery for measurements. But for long term, I needed to have this isolation. Unfortunately, things that can isolate USB at 480Mbps or faster are too expensive to justify.

The solution

The ADUM3160 isolator can provide a magnetically isolated 12 Mbps connection, which proved to be good enough. I grabbed one ready made isolator module from ebay for about $12, cheap enough. Well, it is not perfect: the B0505S DC/DC converter provided can only supply 1W and the Analog Discovery is a hungry beast.

Luckily, these DC/DC converters are cheap and I had some more in my parts bin.  Their internal structure allows them to be connected in parallel, so I used 3, which should cover the 2.5W needed.

Next up, I had to upgrade the input fuse, to allow for higher current, my parts bin provided 0.65A one. Given the efficiency of the converters, this his slightly too small, so I would advice for a 0.9A one, the limit of USB 3 ports. Next up I have used an extra wire to connect the output of the DC/DC converter because the PCB trace was too small, dropping 0.3V on it already. Added an extra 470uF capacitor for decoupling, just to be sure.

The device works, but make sure to power it from a USB 3 or high current USB port, 0.5A classical is not enough. I am using a self powered USB hub.

Performance testing

I fired up Waveforms and set the signal generator to output a 1 MHz sine on a channel and used an oscilloscope channel to observe it. Luckily, the persistence mode does both a time count and a frame count, so I could use that as a method of USB performance. Without the isolator, I could do about 32 acquisitions per second.

With the isolator, the number dropped down to 9 per second. This is not so bad and using the thing without persistence in the normal oscilloscope only way does not show any perceived extra latency.


For about 15 EUR/USD and a couple of minutes of work you can make sure that your Analog Discovery is floating. There is some performance penalty, but there are few situations where this would matter.

RFM69 output power


As I was mentioning in my 1000.1000 Hardware selection, I have opted for the cool RFM69HW radio module. Weirdly enough, in quite a few sources (big distributor and ebay) the higher power HW module is cheaper. So there ie no reason not to get the higher power module, given quantity discounts. But I want it to operate at lower power most of times. The datasheet does not show any differences at lower power, so I had no reason not to go for the higher power module. It even says so on the features list on the front page, I can turn the power down to -18dBm.

What happens?

Unaware of the full details, frustration emerged when I started mixing in both types of modules. The Radiohead implementation I am using (1.71) makes sure no single power value will work for both module types: over 13 dBm and a W module will not work, under 14 dBm and a HW module will not work.  Digging through the code shows no problems, it does not really work as expected, but it should. The datasheet makes things more clear which power amplifier to enable based on the level and the library implements it properly. We can see there is some overlapping in the ranges as well.

A nice graph shows the power levels, from which we can see that the power ranges in the middle are achievable with different configurations.

So doing some digging around the datasheet of the IC, same one present on both modules, we learn that the IC contains 2 types of amplifiers. PA0 is the lower power one and is always directly connected to the LNA input and both to the antenna. For higher power, one has to use additionally the PA1 and PA2 and optionally a BOOST setting to squeeze out the last couple of dB. So how are these connected on the actual module. The RF69 datasheet shows a blurry picture of the module schematic for up to 13dBm output power, on page 76/77. We see that PA1 and PA2 never reach the antenna, just PA0.

Compared to that, the high power RFM69HW uses a switch which is driven by RX/TX pin, after some module reverse engineering. This means that only PA1 and PA2 reach the antenna, and never PA0, during transmission.

Fixing it

The fix lies in understanding how the modules work. Because it uses only PA0,  the RFM69W can only have PA0 turned on and the output power ca be adjusted between -18 and +13 dBm. The high power RFM69HW can only use PA1 or PA2 or both, but never PA0, so the output power range is -2 to +20 dBm. Now the curves on the graph above make sense: the blue one works for RFM69W and the other colors are valid for RFM69HW!

This means that the code used to configure the modules needs to know which type I am using in order to configure the power output within the overlapping range. I fixed the function controlling the output power and will suggest the changes to the Radiohead developers.

With the power setting correctly implemented, the library can properly set a power level, within the limits, for either module. A quick test shows that knowing which module is attached, any power between -18 and +20 dBm can correctly set each module within the appropriate limits. Measuring the RSSI at a nearby node, we can observe that the RFM69HW is capped down below -2 dBm and the RFM69W is capped up above +13 dBm. The measurements were quick and dirty, so take them with a grain of salt.

Hardware  fix

There is a posibile hardware fix: the RF69 IC should make sure not to switch the antenna to PA_BOOST when the power level is set low, but that might require a new chip revision.

The software fix can get the RFM69HW down to -2 dB, with few users wanting to go lower as reducing the output power does not bring much benefit in power consumption.

Code fix for power setting function

Use for whatever other library driving the RFM69, original implementation coming from Radiohead library.

void RH_RF69::setTxPower(int8_t power)
 _power = power;
 uint8_t palevel;
 #ifndef RFM69_HW
 if (_power < -18) _power = -18;
 if (_power > 13) _power = 13; //limit for RFM69W
 palevel = RH_RF69_PALEVEL_PA0ON | ((_power + 18) & RH_RF69_PALEVEL_OUTPUTPOWER);
 if (_power < -2) _power = -2; //RFM69HW only works down to -2.

if (_power <= 13)
 // -2dBm to +13dBm
 //Need PA1 exclusivelly on RFM69HW
 palevel = RH_RF69_PALEVEL_PA1ON | ((_power + 18) & RH_RF69_PALEVEL_OUTPUTPOWER);
 else if (_power >= 18)
 // +18dBm to +20dBm
 // Need PA1+PA2
 // Also need PA boost settings change when tx is turned on and off, see setModeTx()
 palevel = RH_RF69_PALEVEL_PA1ON | RH_RF69_PALEVEL_PA2ON | ((_power + 11) & RH_RF69_PALEVEL_OUTPUTPOWER);
 // +14dBm to +17dBm
 // Need PA1+PA2
 palevel = RH_RF69_PALEVEL_PA1ON | RH_RF69_PALEVEL_PA2ON | ((_power + 14) & RH_RF69_PALEVEL_OUTPUTPOWER);
 spiWrite(RH_RF69_REG_11_PALEVEL, palevel);

Peaktech 6225A review


I got a Peaktech 6225A power supply to power some things, as it seemed like a good deal, going beyond what one might find normally in these types of supplies: more display resolution and supposedly, lower noise. For this price, this supply is a good deal compared to other similar ones on the market. Let’s see how it performs.

You can even grab one on or through affiliate links which helps me support this website, while offering you the same low price.

Voltage and current set

For the first test, I have checked if the supply is really delivering on that 1mA / 10mV precision, using a calibrated multimeter. The results are below: for the voltage setting, the power supply seems to hold on pretty well from about 0.2V and higher, below which it is not that much control. On the current side, things are similar, current cannot be very accurately set below about 50mA. In both cases, the precision starts to be there from about 1% of the full scale and I think it is perfectly fine for this kind of product.

Burn test

First off, the power consumption test: the power supply burns 4.2W while on and with the output turned OFF. If the output is turned ON and set to 25V and no load, it consumes 5.2W, which I think is decent.

Of course, I had to grab my PSU burner to start stressing this guy out. I set the supply for 30V and 5A load and let it run for half an hour. The fan quickly started.

Mains power ON test

I checked what happens when the power supply is switched ON, from the mains switch at the back. With no load, there is a small 0.5V glitch that takes time to die down, due to the high filter capacitors. With a 10R resistor the glitch is surprisingly higher at 1V, but it extinguishes faster. Note: voltage is orange channel and current is blue channel.

With 10R load

Soft power ON test

Setting the power supply to 5V and turning ON results in this waveform. Note that the oscilloscope is suffering from external noise due to grounding.

And powering down, again no load shows quite a long time to discharge the capacitors


Here is the response when the supply is set to 5V and a 1A load pulse is applied. We can see the supply goes back on track within about 100µs. Note the voltage drop with load is not that high, but the Analog Discovery measures it after some wires. Disconnecting the load produces about 1V higher peak which is not that good.

Constant current mode

This is one of the interesting thing to check, as it shows how the supply will perform in case of a circuit fault and limit the current. First test, 5V output with 1oomA limit, checking what happens if the PSU burner tries to pull 1A from the supply. It takes about 6-8ms before the current is limited to the set value! This is quite slow.

Next up, same test, but setting the supply to a 1A limit and trying to pull 2A from it, we see the same response time.

With the same 1A limit trying to pull 5A shows some more details: the response time is now shorter, about 4ms, indicating this is closer to the loop response, and not the discharging of the output capacitors. The oscillations also show the loop stabilization time.

This is further seen as what happens when starting the power supply shorted, but with a 1A limit, which allows the load to pull almost 4A at start.

Conclusion: the supply is quite slow and will allow a pretty high current to pass through a shorted load before the loop reacts, not recommended as protection to delicate circuits.

Noise test

Finally, let’s look at noise test, this time I removed the whole PSU burner and left the Analog Discovery only. Setting the supply to 5V and loading with a 10R resistor, I checked the noise.

The noise is about 80-100 mVpp, which through a slightly incorrect way to judge this, comes down to about 15mVrms, quite more than the 3mVrms quoted in the specifications.

Actually, manufacturers don’t like to measure noise like this, but by having a 20uF capacitor at the end of the load. So doing the same thing, I get about 12Vpp of noise, much better and quite in line with the specifications, which is really pleasing.


Of course the fun does not stop here, so let’s look at a what is inside. Surprise surprise, there’s a big TIP3055 transistor on the bottom, more on that later.

In general we see things that are expected: the input socket contains a fuse and the 110/220V switch, with the power then going through a double switch. Furthermore there is some common mode filtering and your typical NTC to protect from high power up rush in current.

We can also observe the thermostat of the fan is bolted on the middle heat sink which cools the main switching transistor. My non contat thermometer shows the fan turns on at about 35-40°C.

Comparing to other types of these supplies, like the Manson NSP 3630 (a lot of the designs are copies of this more or less) the main board, visible in the middle, appears much simpler.

Actually, the design is rather different. On top there is a regular 50Hz transformer, with 3 secondaries, compared with an auxiliary switching supply found on the Manson. On the bottom, the blue transformer is the main power supply transformer, carrying out the load.

The supply is controlled by an OB2269 switch mode controller, not the typical TL494. The OB2269 has quite a few advantages, it’s designed to drive a MOS which can be more efficient and it is optimised for “Extended Burst Mode Control For Improved Efficiency and Minimum Standby Power Design” which makes it more suitable for this type of application.

Unfortunately, as expected at this price range, the “Chong” filter capacitors are not the strongest point of this device.

The output filter of the main switching supply is a pair of probably low ESR 1000uF/50V 105C SME capacitors. Can you spot anything missing? Yup, no inductor filter on the output.

Looking at the board from behind, we can see some clear demarcation of the high and low voltage regions, which appear to be safely separated. Also here you see an element which is out of place: the wires of the fan are soldered directly on the back, even though there is a connector in place there. While the supply is quite low cost, there don’t seem to be any other elements inside aimed at saving such a tiny amount.

Next to the clandestine fan connection you can see the 3 rectifier bridges generating the 3 auxiliary voltages used for the supply control. The fan is supplied by 10VDC and there is another 30VDC supply and a -6VDC negative supply, all going to the front panel.

Moving on to the front panel, it connects with a ribbon cable carrying those 3 supplies plus another wire going to the base of the TIP3055 transistor on the bottom. There are 3 more thick wires connecting to the banana connectors on the front panel.

Here is an overview of the whole front panel, first the front side. We can see the two 4 digit, multiplexed displays, the 3 LEDs, 2 rotary encoders and the soft ON/OFF button. Across the outputs there is a 100nF capacitor, plus  2 more from each pole to the earth. There is a reverse protection diode as well and the bottom left shows the current shunt.

Moving towards the back now. Voltage seems to be regulated by a couple of TL431 (top, middle) and transistors. The big decoupling capacitors are SME 470uF/50V, 105C each and they are directly in parallel to the output, so the current measured in the shunt will be delayed by the discharge of the capacitors.

The design is much better than the Manson and other supplies, which relied on a lousy ATMEGA micro controller generating quite low frequency PWM signals which are then filtered to generate the voltage references. The readout was then carried out with dedicated voltmeter ICs.

Here we see a more modern approach: there is a micro controller handling everything, which of course has the markup removed.

Starting on the top, the display is controlled with two 74595 shift registers, one drives the segments and the other the digits, through the transistors on the right side. I have not poked around as to why there are only 6 of them and not 8, one for each digit. The buzzer and driving circuits are not populated.

On the bottom side we can see the micro controller and the control loop. Based on the capabilities of the supply, the microcontroller is probably a more modern device featuring 12 bit ADC and maybe a 12 bit DAC. Given the 3.4V supply I measured, I suspect filtered PWM is not involved here. Something like an XMEGA32E5 could do it, but the pins don’t match. The microcontroller is a 32 pin LQFP with 0.8mm pitch, power seems to come from pins 7 (GND) and 8 (VCC), and pin 1 might be reset. Any ideas?

The loop is controlled by 2 OP07C opamps, which feature very low offset (60µV typical) as a requirement to keep things under such high precision. Unfortunately the op-amps are also quite slow, with a unity gain bandwidth of only 0.4MHz, which can be seen as well in the loop reaction time, in the tests above. There is another 4558 opamp which I believe checks if the supply is in CC or CV mode.

Going back to the full view, the opamp near the connector is a good old 741, which I believe drives the transistor next to the connector which in turn drives the big TIP3055 transistor in the supply.

Speaking of which, what exactly is the big TIP3055 transistor for? Well, it is actually used as a linear regulator following the switch mode supply, which is a feature this supply has and not the older designs. I have measured and it keeps about 2.3 – 2.5V across collector-emitter, depending on load current, which means we are looking at about 12.5W of dissipation at max load. This secondary linear regulator allows the supply to provide such low output noise compared to others.

The way it works is that the opamps on the front panel drive this output transistor to the required output voltage. The switch mode supply follows suite and is designed to supply about 2.5V more than the output voltage, as seen by about 2.5V CE on the transistor. This design provides the best of both worlds, the switch-mode supply gives higher efficiency in a lower size and weight, while the following linear regulator can filter out most noise and provide a cleaner output.

I tried poking around the two un-populated headers with both the Analog Discovery digital IOs, a USB-serial adapter and a ST-LINK V2 and could not get any response out of the micro-controller in any way. I don’t intent to spend more time reverse engineering this, since it needs to go to work.


The power supply delivers great results for the price compared to other similar products, I believe it is a good deal to have one of these for general purpose, with the exception of very delicate things. Furthermore, the dual switching and linear regulator achieves a low weight and compact device with low noise, as promised.

However, the supply is not without it’s limits: the high output capacitance and rather slow loop means it is capable of delivering quite some punch before the limit sets in, so not everything is safe to be powered from it. Do note however than linear or not, only much more expensive lab power supplies have a fast acting loop with little output capacitance, as such a feature costs and is infrequently required. Quite a few other small improvements could make it better: screw type bananas are better for connecting wires directly and some sort of proportional to temperature fan control is quieter and welcome in places like a home lab.

Finally, I do recommend this for a well made and great performance for the price this product offers. You can even grab one on or through affiliate links which helps me support this website, while offering you the same low price.


PSU Burner


What does one do when designing a power supply? Well, build a power supply tester, of course. One of the simplest things to build is a constant current load. This will allow for testing of the endurance of the power supply, as most of the designs out there are using slow components.

However, I wanted to make a better one: one that I could hook up to my Analog Discovery and generate a test waveform to be able to connect and disconnect the load fast. This is a weekend project, so all parts are not the best for the purpose, just what I had around.

Warning: The analog discovery is grounded through your PC (unless using a laptop on battery only) so you have to make sure that both the supply being tested and the auxiliary 12V supply are isolated and not grounded. Or use an isolated aux supply and a USB optical isolator if the supply under test is grounded.

Update: Check the PSU Burner being tested with a real power supply in my PeakTeck 6225A review.

Take 1

The simplest of design, one OP-AMP driving 3 MOSFETs. All fine until I made a mistake: with the signal generator connected and turned ON, i connected a 24V 5A supply that was already on, while the signal generator was providing a square wave for 5A current. This caused one of the MOSFETs to blow up (shorting) due to an avalanche event. Finally the power supply went into hiccup mode.

Have you ever seen a fuse pulsating? With the output of the supply shorted and the fuse quite at the limit of the current, it is almost melting each time the power supply tries to restart

Take 2

There are some improvements, so let’s go through the schematic first. The way it works is simple: U1A will drive Q1 such that the voltage across R6 is equal to the reference at it’s positive input. This in effect creates a constant current being drawn from the test power supply.

In “external mode” the constant current load is controlled and read out by the Analog Discovery. Since the control signal can be up to 5V, with R5 being 0.1Ω, I have divided it 10 times using R2-R3, to limit the max current to 5A. In “internal mode” there is a fixed reference generated using RV1 and a 5V regulator, which makes the supply draw a constant, adjustable current.

For  a nicer look, I added 2 meters, they are your typical 3 wire voltmeters, but make sure you get the nicer ones which auto-scale and use all 3 digits for precision under 10V which are also hackable. The current meter needs a 10X amplifier first, since we are reading current on a 0.1Ω resistor.

Finally, let’s look at the extra safety features: first, I am now using 5 transistors instead of 3, of similar type. I have added a rather large,  0.5Ω balancing resistor in each source, made by 2 1Ω/0.6W resistors in parallel (remember, built out of what I had in my component drawers). And second, a Zenner diode between the source and drain. This will serve 3 purposes: if the load is applied with reverse polarity, the fuse will blow and it will also protect the transistors from high peaks  when a load is disconnected. Third, if more than 36V is applied, it will blow the fuse. The nice thing about using a Zenner like this: if a high enough current is passed through, it will melt and become permanently a short: it forms an anti fuse.

Oh, and did I mention I want it to be fast? Well, that is why I used a TL3472 (besides that I had one): it has a rather high slew rate and a high output current capability.

Build pictures

Transistors tanning. Notice how this heatsink has been through a lot…lots of holes.

First tests, including cooling:

Preparing to put things together:

First test. The front panel is 3D printed. Also the knob, I did not have one for perfectly cylindrical shaft multi-turn potentiometer.

Testing the power brick guilty of burning the previous transistors. After a long time, the heatsink reached about 45°C in the middle at the well cooled area and 53°C at the edge fins where there is not much air flow.

And finally testing the speed using a 7805 regulator and short output wires using a 10kHz, 1A load. The rise and fall time are about 2.1µs.



<disclaimer> This article is an emotional rant and may contain some strong language.</disclaimer>


Studying the available open source solutions for my 1000.1000 project, I found quite a few interesting frameworks for DIY sensors. One of the most complete and fast growing is the My Sensors project. The Framework, like many others, is based on Arduino, with both the traditional and more exotic hardware.

I did quite some embedded software development and other programming throughout my life, as some projects on my site show, but only from a classical approach. I have used multiple Arduino boards for low price and convenience and I have ported a few Arduino libraries to a regular environment, but my experience with the pure Arduino way of software was very limited. I was aware of the limitations, but not quite so…

Playing with examples

Getting the MySensors to work was fast, I setup a gateway, a dimmer node and a button node. Grabbed openHAB controller and made a rule to toggle the LED at the press of the button. Added a motion sensor and another rule in openHAB to turn the light on for some time when there is motion. Sweet. Great work!

Ok this looks really easy and well off, let’s dig into how this works. Oh….s**t! Can’t navigate through the code using the Arduino Ide, well, ok, fine, I knew it was basic.

Let’s just open the source files of the MySensors library used in the example and look at them. S**t! The fu***ng Arduino IDE cannot even open the very .cpp and .h source files used in the libraries without some inconvenient hacks.


OK, there are other IDEs out there, surely Atmel studio has been bragging to me for a while that it supports Arduino. Fire it up, open the project, and voila! Can jump to function definitions….but wait! All the files used in the project are not easily visible and it is terribly difficult to figure it out the whole mysensors library. Better, but not good enough.
Let’s convert the project to a regular Atmel Studio project.
Much better, all most of the source files required are pulled from the Arduino folders into a nice, complete project where one can see all the things happening in the background of the Arduino. And yeah, Arduino does a lot of things behind you back and uses some hardware blocks inside the microcontroller, but that is another story.

But it won’t compile. See, for the sake of simplifying things, Arduino code breaks some rules that normal C/C++ expects. While the Arduino processes the files in the background to make sure they become compatible with gcc, this does not happen here anymore since this project is now a normal C++ project. Untangling things would take a significant effort for such a complex library.

As far as I know, there is no easy way to get both things – the nice complete project with all sources and advanced IDE features and Arduino to compile it, but please correct me if this exists. This is valid for other IDE alternatives, like Eclipse and it is caused by the Arduino way of life.

How does it feel?

Arduino is supposed to be like some aid to swiming. Only that it turns the waters muddy so you cannot see what’s below and you cannot actually swim, you are forced to walk through water. It sorts of works if the water isn’t too deep and your purpose is to get across the river, not learn how to swim.

Don’t get me wrong, it has a very useful place in this world. The community around it had built one of the largest collections of open source embedded code and the far east manufacturers can sure get a board in your hands for cheap. Who cares if it uses a counterfeit or out of spec chip or both, you can get a lot of stuff done.

The alternative is difficult

Actually it isn’t. Let’s look at an example: try reading an analog voltage.
This is how the Arduino sketch looks like, independend to what Arduino hardware you use. Let’s try the newer Arduino Zero.
There is some setup, but nothing to do, it happens in the background, and then you just loop through reading the value. Looking at the ADC it feels like there is more to it, but changing settings will get you digging around the internet a lot.

Now let’s take a similar example using a the SAMD21 ARM that is found on the newer Arduino Zero but in Atmel Studio, which is at the moment one of my favourite microcontrollers. The datasheet shows that indeed, ADC does have few more tricks up its sleeve:
Atmel studio has built in example project to read the ADC using the Atmel Software Framework (ASF). This is the program it produces (removed comments):

Here’s what you immediately learn by looking at the code: there’s a main() function where everything happens, which Arduino normally hides. system_init() takes care of some basic initialisation of the chip. Then you need to initialize the ADC. To get a value you need to tell it to start converting and wait for a result while the ADC is busy, because this takes time. A little bit more complex in appearance, but no different than what actually happens if you use an Arduino, remember the hardware is the same.

But here there is nothing hidden, nothing happens out of your sight or control, you have now discovered more is needed to make a microcontroller work. You can explore the whole code with the ease of a powerful IDE.
And here is where something magic happens, have a look at what is inside the ASF provided function that sets the default way to use the ADC adc_get_config_defaults(&config_adc):
It immediately becomes obvious what are the different settings one can play with. Even for a total beginner, jumping back and forward between this configuration and the ADC diagram above maked it pretty obvious how things can be changed to do a lot more if the user wants to. You don’t need to understand everything at once, a lot of things will be intuitive and some will need the datasheet. This is the way embedded programming normally works, you control the hardware, not use in whatever hidden and obscure way the Arduino wants you to. Atmel provides this nice hardware abstraction layer through ASF, but one can, of course, also use the most efficient way of editing the actual configuration registers following the datasheet.


The complexity is always there, but in Arduino it is hidden. This might be good, but it is also inaccessible and that is why it remains a mystery for a lot of users who never grow beyond it. It’s exactly the wall you hit when you want to dig in and see what really happens under the hood that stops you.

My advice: use Arduino for simple fast things, profit from the community written libraries and buy the cheap hardware, but do learn about the whole world beyond it.

I am not complaining about the loss of performance due to poor code implementation, and in the end not even about the bad IDE. It’s the hide things under the rug to make it look simpler and cleaner approach that upsets me.

So where does this leave me with my home automation project? Tough dilemma, I like my ARM with great IDE and partially written code, but a readymade platform covering 80% of my needs based on cheap hardware and terrible Arduino is also tempting.

Note: there are no links to Arduino sites because they split up some time ago and I don’t find either of them more relevant than the other or worth including both.

10002 Hardware

This article is part of my 1000² Smart Home project. Check out the Architecture and Software and then move on to Hardware. An most importantly, check the Lessons learned and why I did what I did. There are already some first results, connecting all parts of the system.

Some history

A picture says 1000 words!*

*inner voice dependent

Which microcontroller?

When I began this project, I was long given up on the ATMega and ATTtiny micro, with some exceptions, as they are not really justified in a hobby environment. Therefore, I have initially intended to make my nodes using an ATXMEGA32E5, which I believe is an ideal device for sensor nodes, due to the various and low power peripherals. However, it soon turned out that for some devices I would need more flash, but the family stops at 32K and a package change is required for more memory. So I dropped it in favour of the new SAMD21, ARM cortex M0, which comes with more flexible package and flash options. This device burns a little bit more in sleep, but still tolerable. And a 128K flash and 16K RAM version costs on par with the lousy old atmega328 with tons of extra features (way better ADC, DAC, more PWM, more timers, more I/O, more flash, more RAM, faster core, lower uA/MHz, RTC, more SPI, mor UART, more I2C….i’ll stop here).

Below is a brief comparison between the 3 types of devices: the old 8 bit (MEGA), the new 8 bit (XMEGA) and ARM (SAMD21). I have compared the SAM with other ARM MCUs from ST, NXP, Freescale and concluded that the SAM is the best fitted for such low power applications in terms of performance/cost, with the benefit of being familiar already with Atmel’s Software Framework.

Therefore, welcome the “core 1” SAMD21 node and IOT board.

The top and bottom headers contain all the pins of the microcontroller, including power. The left side has an easy breakable micro USB and room for the antenna. On the right there is the “basics” header which contains power plus 7 other carefully chosen pins. For most nodes, the right header will cover all the connection needs. An anti-parallel red-green led can use 2 pins and no series resistor, while being able to display 3 colors. As mentioned in the lessons learned, there is a linear regulator, for the projects that need a regulated 3.3V supply.

And the back featuring the RFM69 radio:

The module is part of a bigger PCB, which contains 3 other modules. On the top, there is a prototype one with an additional USB connector. The middle one is a temperature, humidity and light module, while the one on the right is a 3 channel power driver for LEDs or other loads. Time will tell if this is a good approach.

The best way to see the power of this little beast is to look at one of the earlier test modules i built.  At the same time, I was using : I2C, light sensor, ADC channel, battery monitor, motion sensor, contact, button and driving WS2812 and 3 PWM channels, red-green status LED and, of course, the radio. It’s not that a lower end microcontroller could not do it, but the flexibility and free memory I still have while doing this is of very high value. And, although I am not proud of it, I took the non elegant solution of driving the WS2812 LEDs by bit banging, because I totally can with a 48MHz clock.

Which radio?

The radio used to transmit the data between nodes is one of the crucial parts of the system. As mentioned in the Lessons learned, the NRF23L01 or RFM75 was a good candidate, but eventually failed to meet the needs, so I chose the RFM69. Truth be told, I believe the perfect radio is a combination between the two and some bonuses.

Here’s what I would like to have:

1. Integrated PCB antenna is generally better than an external one when designing a compact sensor node.

2. Decent power, 100mW or more, with the possibility to scale it down to 1mW.

3. High range of bit rates: the RFM69 can do 250:1 (300kbps to 1.2kbps) while the RFM75 is only 8:1. Lowering the bit rate allows for higher range when more power is not an option.

4. Automatic packet handling with automatic ACK and re transmission is gorgeous.

5. Automatic bit rate detection from the preamble: this would allow a gateway or any node to receive any packet without prior knowledge of what bit rate to expect.

6. Cost should be somewhere between the RFM75 and RFM69 (1 to 3 EUR/USD each).

7. Sub GHz band has quite some advantages, but for compactness 2.4GHz works too. Same module with integrated PCB antenna working at 433MHz or 868MHz or 2.4GHz would be gorgeous.

8. Encryption with nounce.

10,940 views since Nov 2016