Ar2uino Dummy Load โ€“ 7

The idea behind the Ar2uino Dummy Load is that it should be possible to use both as a Dummy Load but also as Battery Capacity Tester! To be able to do this I am planning to have two “modes” – naturally: Dummy Load and Battery Tester! This will be my first implementation of something with a ESP8266 module and controlled via Wi-Fi! So I will learn a lot! As the Swedish children’s book figure Pippi Longstocking says: “I’ve never done this before, so I can probably do it very well!” She is more sure of herself than I am – but I will certainly give it a try! ๐Ÿ™‚

I decided to go with the “bare” ESP-12F* module so I get the challenge ๐Ÿ‘ to get that working also! I sent for a number of those as I think they certainly have a potential for use in a lot of different applications! By far one of the most “bang for the buck” ones among the Arduino-type of low cost 32-bit microcontrollers! Wi-Fi, 80/160MHz, 80kB RAM and 4MB flash memory! Very impressive! Specification varies a lot so be sure to check out what you are buying! Using an ESP8266-based controller meant that I had to get 3.3V power for it and some way of setting all the different pins correctly for programming and executing a programme! See my separate previous post about: Getting ESP-12 to work with Arduino IDE! I should point out that doing this interface circuitry myself is just for learning – prize wise there is not much to save compared to a Mini D1 for example – and that one has all the supporting circuitry already! Of some value is also that I get to place the components according to my own requirements! But generally – if an ESP8266 is wanted I think that the many different alternatives with included support circuity is to be preferred!
* Ridiculously cheap – $1.80 (incl. international shipping) on eBay! January 2022

ESP-12F Analog output quality and range

The size of the load of the Ar2uino Dummy Load (Step 1) is at the moment controlled by a voltage set by a trimmer potentiometer. That will be controlled by a voltage set by the ESP-12F in Step 2. Now, the ESP does not have an analogue output through a DAC (Digital to Analog Converter) but I could use a separate DAC like in the Ar2uino Digital PSU project – but as my test showed that a pulse width modulated (PWM) signal with a filter will also give a perfectly OK analogue signal – I will try that! So we will use a PWM signal to generate this analogue voltage by filtering it with a resistor and a capacitor. But naturally we will test it first to see that it is acceptable! There is a very handy on-line calculator to find suitable values for the resistor and capacitor here! I have chosen to have 10kโ„ฆ resistor and 10uF capacitor that should give 8mV peak-peak ripple at mid-voltage and a rise time of <230mS*. It just so happens that those are the very values that I have fitted in the Ar2uino Dummy Load (in Step 1). ๐Ÿ˜‰
* Using a dedicated DAC like the MCP4725 would do this much quicker – in just around 6 uS but for my use I do not see the dummy load used for very quick pulsed loads so the PWM solution should be sufficient! Or am I incorrect in assuming this? If short pulses is a requirement – it is just a cheap ($1) swap!)

Some of the communication alternatives that are handled in hardware and do not affect the normal execution in ATmega328 – are instead handled in software on the ESP8266 and that has the potential to disturb the “normal” execution! That is so with PWM. We will use PWM to supply a voltage to control what load we want to have. But we will only use one (1) PWM channel so hopefully that will be stable enough! The Wi-Fi routines must be allowed to execute very often and take around 20% of the MIPS! Also there is some talk of it being a power hungry chip …

Pulse Width Modulation (PWM) Signal samples. 50% width ON at the top and 25% width ON at the bottom and should after filtering give 50% and 25% of the peak output voltage.

The PWM firmware in the ESP8266 is (according to the datasheet) very flexible – you can both set the repetition frequency (100-1000Hz) and the resolution (max 14 bit) or number of steps (max 8000) ! As the PWM is handled in software this will consume some of the power (MIPS) from the CPU – but our remaining requirements are low so this should hopefully be ok! Let the testing begin!

To simplify testing this I used a ready-made D1 Mini with a USB interface – but with the same ESP12-F module and I used the same setup as in the Ar2uino Dummy Load – a 10kฮฉ resistor and a 10uF capacitor connected to the 4 pin. Marked with D2 on the Mini D1! The reason for testing this a bit extra is that as the ESP-12F only has ONE (1) ADC pin ๐Ÿ˜ฆ so it can only measure one voltage! For a dummy load it is vital to know the current current! ๐Ÿ˜‰ For a battery tester it is vital to know the voltage over the battery! How will we get around this dilemma?

Well, as voltage over the load is something we want to measure and the current is something we want to set – we might have a solution there! If the current set is stable enough it would not need to be measured! If we could trust that the dummy load current is “exactly” as set – that would solve it! We would not need to measure that! I have already seen in my previous tests that the dummy load is very stable when set from the trimmer potentiometer! BUT now the remaining question is if the voltage generated by the PWM from the ESP-12F output is stable enough? Nothing in this world is absolutely exact – it always has a tolerance! Everything with less than 1% deviation I think is acceptable – and even more if small in absolute terms! Would it be possible to calibrate the PWM output voltage? Remains to be decided who (or rather what) will be the judge? Well, it would have to be my multimeter!

First out is to check the output voltage range of the ESP8266 when used for PWM! Using a small programme I set the write frequency to 1000Hz and the write range to 1000 steps and then alternate between range value 0 and 1000. For 0 I get 1.5mV. Not quite zero but close enough. Using the value 1000 I get 3.314V and quite close to 3.3V as expected! Checking other combinations and extending over the set values still produce the same results! The voltage regulator on the Mini D1 I measured to 3.322V so that is according to specs. What seems to be confirmed is that the PWM output voltage max is 3.314V – and it seems very stable! Over the course of a few days I have remeasured it a number of times and it, thankfully always gives the same result!

Next is to find out how linear the ESP8266 PWM output is! A first test with just 10 values spread out over the total range shows very good linearity! Just -2mV to +5mV deviation from the mathematical calculated values! It looks just as a straight line to my eye but I’l show it anyhow – as it also shows the small deviations in the 10% steps over the full range! (See above) Notice that the right hand scale is for the mV differences. Looking at the orange curve of differences I think – even with these coarse measurements – I see a general behaviour! It starts with slightly too high values (+5mV) close to 0 and then it creeps down to slightly too low values (-2mV) as we are reaching full voltage output. These are small deviations but they can be improved a bit – either with a general formula or by calibrating discrete settings like with the Ar2uino Digital PSU. A more detailed measurement is needed to confirm this. See below!

Settling time is the next to be verified. I wrote a small programme to pulse one pin and immediately thereafter start the PWM on another! Going from 0 to 40% of the full scale value (3.314V as seen above). I chose 40% just because it filled the oscilloscope display best. ๐Ÿ™‚ Channel 2 (blue) is the 20mS trigger pulse that indicates the start of the PWM. On channel 1 (yellow) you can se the rising of the voltage up to its set level. I could have used channel 1 (yellow) to trigger the capture but I wanted to see if there was any delay in starting the PWM and as can be easily seen there is an immediate start of the PWM. Just what I hoped for! ๐Ÿ™‚

The oscilloscope shows the rise time to be 197mS – that is from 10-90% of set level. I would say that it takes 300-400mS from 0 to reach very close (99%) of the set level. The curve is very flat when it gets close to the set level and takes quite a bit of time to reach the full 100% – that is why I give such a imprecise rise time! That is also the reason why measurements of rise time usually is measured from 10-90% of the full voltage swing. The settling time is anyhow <0.5s – which is good enough for my purpose!

As I mentioned earlier an alternative to using PWM could be to use a 12 bit DAC like MCP4725 and get the ability to control the dummy load also for short pulses! With that DAC it takes just 6uS to settle on a new voltage! On the other hand the PWM gives a nice smooth transition to a new load… It is not a big deal to change the design and the additional cost is low ($1). I will try to write the software so that the PWM solution easily can be swapped for a DAC solution! ๐Ÿ˜‰

PWM set to 90%. Ripple around 5mV.

Now would be the time to look at the steady signal and see how much ripple and noise it has. Turning up the sensitivity to just 5mV per screen division and timing to just 200uS per screen division this is what we see. It varies depending on the set level with around 5mV ripple at 0.3V % and 2.8V and around 10mV ripple at the middle 1.6V output level. It tallies well with the theoretical values from the calculator. I show the 2.8V measurement at 1kHz frequency. Here the output is on at 90% of the time and the slanting sawtooth with the rising voltage is the result. Naturally it will be close to all flat when we reach 100% on-time. It has a triangular shape at 50% – half on and half off. At the mid position the PWM signal has the most ripple. The ripple is affected with both the writing frequency – the higher the less ripple (here 1000Hz) but also the resistor and the capacitor sizes. It is a balance against the settling time – the bigger R+C – the less ripple but also a longer settling time!

Next up is using a good ADC and do a more fine grained sweep over the range! I will be using my ADS1115 16bit ADC to measure the output voltage. It has 32767 steps that we can use! That makes each step just over 0.1mV using the 4V setting on the built-in gain amplifiers. This makes it close to 33 times more precise than our PWM – so we should be able to trust our measurements – any variation in the singles digit will not affect our settings much at all! In short we will trust it to be correct!

Using 1000 steps in the PWM naturally gives the ability to set the current to 1/1000th of the full scale of 5A so that means we will be able to set the current load in steps of around 5mA from 5-5000mA. That would mean that each step can not be calibrated individually to get closer to the exact 5mV step! (See more about this here!) If we decrease the step size to <5mV we could calibrate the 5mV output steps and compensate for some faults…

More about this next time…! ๐Ÿ™‚

See you soon!
/Sfenn

Ar2uino Digital PSU โ€“ 12

NOTE: A new article no 11 has been published in place of this and this has been given a new no – 12!
In a previous instalment we analysed the performance of the MCP4725 12 bit digital to analogue converters that we used for this design of the Ar2uino Digital PSU. We saw that (naturally) they deviate a little from the ideal values. As we amplify the DAC output 8 times that means we will amplify any deviations also! With no corrections done the DPSU varies with around 25-130mV over or under the correct values. That sounds a lot in my ears but this might be acceptable to some of you. I wanted to get a “little” better result – so in this posting we will measure the output voltages and calibrate them to a max deviation of around 5mV!

We have one (1!) adjustment with a trimmer for the overall voltage and one for the overall current limiting. As my design goal is 15V, first I adjusted the trimmers for a good full scale setting at 15V. So a DAC-value of 1 500 will output 15 000mV (=15V) using 10mV per step – just as planned! Had the DAC been a perfect one that would have been all we had to do – but we live in the real world and here are always deviations to be expected! So also in this case! ๐Ÿ™‚

The 12 bits of the MCP4725 translates to 4095 steps. There is no way to change the output for every one of those 4095 of the 10mV steps from the DAC using just ONE trimmer! Neither can we use more than one trimmer! So what can we do? I see two solutions:

1 What we can do is to lower the selectable resolution a bit and instead pick an output step that is closest to our wanted voltage setting! Say that we want to be able to set the output voltage for each 0.1V step! That gives us 10 different 10mV steps to pick from for each 0.1V setting! We just have to find out which setting gives the closest output! That would give us the ability to calibrate the output voltage within a 5mV deviation from the desired voltage. Ex The 10.5V setting would be somewhere between 10.495V and 10.505V. That is more than enough precision for me! ๐Ÿ‘๐Ÿ˜

That would mean that we would have to pick 150 measurements that gives the best values out of 1500 measurements and then store them in the EEPROM or put in a data statement of the ATmega328! Might be a bit boring to do manually – but it is feasible anyhow! An easier and more fun ๐Ÿ™‚ way would be to use a separate Arduino to control the sweep of the voltage in 10mV steps and measure the output voltage for each of the 1500 steps. BUT the ATmega328 only has a 10bit ADC (1023 steps) so something better will have to be used! An ADS1115 is a 16bit ADC giving a whooping ยฑ32767 steps(!) over the selected voltage range. We are just using the positive range so that translates to 0.46mV resolution over the 15V range. This ADC has 22 times better resolution than our MCP4725 DAC (as we are using it) so it should give us accurate enough measurements! Compared to the ATmega328 ADC the difference is even bigger as each step on the built-in ADC corresponds to 32 steps with the ADS1115.

2Another alternative way of correcting or rather calculating the output from the DAC is to isolate the EXACT voltage values of each binary step: 1, 2, 4, 8, 16… Ideally they should be EXACTLY double the previous step! Ex: 2 should be EXACTLY twice the size of 1, 16 should be EXACTLY 8 times bigger than 2 and at the same time 16 times bigger than 1. If this is possible we should be able to calculate which DAC setting to pick to get the desires output voltage. The advantage of this solution is that we would only have to store 12 values – 1 for each bit. BUT we would also have to do a bit more processing…

Said and done! Two pieces of software – one for the DPSU and one for the measuring Arduino! We will measure every setting of the DAC from 0 to 15 000 mV (15V) in 10mV steps – that is 1500 steps to measure! Then we will analyse the results and see if we can find the best (and easiest) solution to the “problem”. Is it solution no 1 and is the no 2 outlined above any real contender?

Features

Chosen values for my build and my software:

Input voltage: 19V
Output voltage:
Max 15V in 0.1V steps
Current handling: Max 2.4A in 10mA steps

I am using an old portable PC switch mode power supply, like the one in the picture. It is very handy, small and safe – no need to handle mains voltages! Practical long thin cable as well!

On the other hand, anything (well almost) that can deliver a DC voltage >7.7V can be used – depending on what max output voltage you want. Use a transformer, rectifiers and capacitors if you want to reduce the switching noise. Design and calculations for this is not handled here though. Just search for it! ๐Ÿ™‚

Design Decisions

The following are my designed min/max settings. It is the software design and component selection that translates to the real life values! If you, like me, do not need high voltages or high currents you can chose to increase the measuring resolution if you want. It is just a matter of picking another resistor or two and changing a value or two in the software to make these changes. I have already spoken about the decisions I made for my version of this DPSU. Some things you could even make switchable – make a 20V and a 40V version and make it switchable if you want. Thereby increasing resolution a bit! Higher voltage or higher resolution! Or be satisfied with the 40V/4A design and the resulting resolutions even if you will never use them to their maximum levels! Staying at max 30V/4A you can just follow my design. Recommended! Should you on the other hand want to go to the full 40V you will need to use a voltage regulator to lower the supply voltage to the op-amps and the other voltage regulators! A LM317 is a good pick as it can handle 40V difference between input and output!  Ex: Input 42V and output 15V!

  • Voltage output step size: 100mV (0.1V) (DAC step is 10mV)
  • Min volt setting: Low << 1V maybe 0.1V? (Depends on tolerances – will be measured!)
  • Max volt setting: 40 950mV (4095 steps) (Depends on chosen input voltage!)
  • Current output limit step size: 10mA (DAC step is 1mA)
  • Min current limit setting: Low << 100mA maybe 20mA? (Depends on tolerances – will be measured!)
  • Max current setting 4095mA (4095 steps) (Depends on chosen input current!)
  • Measuring resolution for voltage and current : 1023 steps
  • Measuring voltage steps: 20mV(max 20V)  or 40mV(max 40V)
  • Measuring current steps: 2mA(max2A) or 4mA(max 4A)

Calibration Process

Two separate parts of software are needed for the automatic calibration:

  • One for the DPSU that increases the output voltage 1 DAC step (10mV) at a time – lets call it “DACsweep“.
  • One at the controlling/measuring Arduino that would use an ADC to measure the output from the DPSU and would signal when to increase to the next DAC step – lets call it “ADCmeasure“. Ideal would be if it could also select the DAC setting nearest to our wanted voltage! Could it also write the data statement to cut and paste into the Ar2uino DPSU software – it would be super! ๐Ÿ‘

So … that’s what I set out to do! ๐Ÿ˜‰ After some thinking I devised a very simple signalling mechanism for the two Arduinos. A signal/data wire would be connected from an output on the ADCmeasure Arduino to an input on the DACsweep Arduino (DPSU). A short high pulse (<50mS) would signal to increase to the next DAC value. A longer high pulse (50-600mS) would reset the DAC to start from zero (0). The DPSU will need some time to settle the newly set voltage so I have added a short delay for each measurement. I also added a few extra calibration/presentation settings.

The principle of work is this:

  • Measure each voltage and memorize the previous voltage
  • Increase the voltage in 10mV steps until it just passes the desired 0.1V voltage step
  • Compare the output with the output from the previous measurement step
  • Pick the one that is closest to the 0.1V step!
  • Print the desired info to serial monitor

With the above we will have the no 1 solution already solved! BUT we will analyse the measurements to see if solution no 2 also is feasible!

Print Format

There are two different lines of data printed by the software. This is the format of the printed information when there are three (3) values printed on the line:

  • DAC – the DAC value
  • Volt – the desired voltage to set
  • ADC Volt – The output voltage measured by the ADC

Below is a partial sample listing of the printout starting at close to 5V:

DAC     Volt    ADC Volt
..
..
502	5	4.9823							
503	5	4.9913							
504	5	4	4.9913	5.0022		0.0087	     >	0.0022	
504	5.1	5.0022							
505	5.1	5.0112							
506	5.1	5.0202							
507	5.1	5.0282							
508	5.1	5.0362							
509	5.1	5.0442							
510	5.1	5.0551							
511	5.1	5.066							
512	5.1	5.0759							
513	5.1	5.0839							
514	5.1	5.0929							
515	5.1	5	5.0929	5.1038		0.0071	     >	0.0038	
515	5.2	5.1038							
516	5.2	5.1157							
517	5.2	5.1266							
518	5.2	5.1365							
519	5.2	5.1465							
520	5.2	5.1545							
521	5.2	5.1634							
522	5.2	5.1734							
523	5.2	5.1824							
524	5.2	5.1913							
525	5.2	5.1993							
526	5.2	5	5.1993	5.2112		0.0007	<	0.0112	
526	5.3	5.2112							
527	5.3	5.2202	
..
..						

Each time the output voltage passes an even 0.1V step the software prints out an extra line with some extra information. This is the format of the printed information when there are seven (7) values printed on the line:

  • DAC – the DAC value
  • Volt – the desired voltage to set (In 0.1V steps)
  • Dev – The difference from the desired voltage in DAC steps!
  • Prev V – The previous step voltage measured by the ADC
  • Curr V – The current step voltage measured by the ADC
  • Prev Diff – The difference in volts for the previous measurement to the desired voltage
  • Curr Diff – The difference in volts for the current measurement to the desired voltage
  • The little arrow (< or >) points to the closest value!
DAC     Volt    Dev     Prev V  Curr V          Prev Diff       Curr Diff
504	5	4	4.9913	5.0022		0.0087	     >	0.0022	
515	5.1	5	5.0929	5.1038		0.0071	     >	0.0038	
526	5.2	5	5.1993	5.2112		0.0007	<	0.0112	

Using the DAC 504 value above as an example: We see that the 5.0 V was passed first time with a DAC value of 504. Ideally it should have been 500! That gives a deviation of 4. We also see that the measured voltages for the previous step (503) was 4.9913V and the current step (504) was 5.0022V. The differences to the desired voltage of 5.0V was 0.0087 and 0.0022 – below and over the 5.0V level we wanted. In this case the 0.0022V was the smallest so we use that and when we later want to set the Ar2uino Digital PSU for 5.0V we will actually set the DAC to 504 to get 5.0022V – a deviation of just 2.2mV! Superb! ๐Ÿ‘๐Ÿ˜Š

Looking at the DAC 526 value above we will se a similar situation – but here instead the previous measurement 525 is the closest with a deviation of just 0.7mV! Even SUPERBER! ๐Ÿ‘๐Ÿ˜๐Ÿ˜Ž (Yeah – I know…!)

In theory we should always be able to pick a value that is ยฑ5mV from the desired value as we have 10mV steps. In real life the step we pick might deviate a little from the ideal 10mV – it might actually be maybe 11 or 12mV so we might end up with a deviation of 5.5mV or 6mV instead for that particular step. This is more than good enough for me!

Looking again at the DAC 525 value that should ideally really have given an output of 5.25V but instead it gave 5.1993V – that is 50.7mV to low! But we will remember this deviation and will use DAC 525 instead of DAC 520 when we want 5.2V because that will give us just 0.7mV deviation!!

The software also can output a data statement to cut and paste into the Ar2uino Digital PSU code:

byte corrDAC = { 98, 99, 98, 98, 100, 98, 98, 103, 98, 98, 98, 98, ... }

This is 100-based so 98 means -2, 99 means -1, 100 means zero(0) and 103 means +3. This is to save space and use a byte to hold the -100 to +155 interval. Depending on the deviations of your particular sample of DAC this can be adopted to hold more negative values or more positive values just by moving the zero midpoint – (100 in my case). If you are strapped for memory space and you have a good sample of DAC (like I have) you might even pack a maximum deviation of 15 steps into half a byte …

If you are keen on having even better precision you could lower the DPSU output to max 20V – thereby halving the DAC step size to 5mV and the maximum deviation to just ยฑ2.5mV … But all this is depending on how good measurement instruments you have got for the initial calibration … and also how good the ADC really is! As I have no means of checking how exact and linear the ADC is I will just have to trust the datasheet and assume that 16 bit resolution is so much more than needed so it is easily good enough!

2So what about method no 2 from above? Is there anything to gain from calculating the exact voltage values for each binary value; 1, 2, 4, 8, 16 … – is it even possible? To find this out I picked out measurements of these from the ones I already did and isolated the voltages for each binary step: 1, 2, 4 and 8 just to have a quick look and see if it is feasible at all. I then did two calculations – one where I selected the highest values and one where I selected only the lowest values. The difference was 1.4mV between these two measurements. I just checked 4 bits and we have 12 bits to handle. The result “sort of” indicates that it could be possible to use this alternative approach to get the nearest value – but I feel that the more direct approach of method 1 is easier to understand and easier to implement and also easier to automate so I have decided to go with method 1!

The Actual Results

As can be seen if we use the uncorrected DAC values we will have rather big deviations 25-130mV from the set (desired) values. We could do a general correction with around -80mV and we would end up with around ยฑ50mV max deviation. As can be very clearly seen above we do not have a linear deviation but instead a periodical sawtooth pattern that is rather cumbersome to correct with a general correction formula. We still could not correct the output of each DAC output value but would be left with having to select the DAC setting that is closest to what we want – just like with method no 1!

Ar2uino Digital PSU – Output voltage deviations at 0.1V intervals – after corrections 0.1-15V

After using method no 1 we do get excellent results – at the cost of having an array with correction data that has to be used. A very small cost for the substantial improvement gained – I think! ๐Ÿ™‚ As the components age it might be necessary to redo the calibration from time to time but as this is more or less automatic I feel that is acceptable.

Another solution is to dynamically correct the set output. This could be done by adding another DAC with a small total output span roughly the size of the first DAC steps to correct the first one and also adding a high resolution ADC to measure the output and supply the correction!

Distribution of deviation – each dot represents the deviation in one voltage setting of the DPSU

If we sort the values from low to high we see that it is a very even distribution of deviations from the set voltages with the lower deviations a just little more frequent! Notice here that I have picked the closest value all the time – no matter if it is below or over the set voltage! I think that is the most important! If you desire that the voltage you get NEVER should be above voltage set – then you can always pick the values below! As corrections are so small, in my case just from -2 to -13 DAC steps, you can easily fit both the correction and a few bits of info about the value into the byte array used. Just 4 bits used for the correction leaves a whooping 4 bits for other info! ๐Ÿ™‚ That way you could actually switch between voltage always under, always over or nearest value!

Having used the above no 1 method for calibration and correction the Ar2uino Digital PSU now have an average deviation from the set voltage of just 2.525mV! A maximum deviation of 5.8mV. Minimum is zero (0). These are the values from my sample – yours might not be the exactly the same but should not differ much! Really good i think! ๐Ÿ™‚ ๐Ÿ‘โœจ

The above means that I now can set the output voltage in 0.1V steps from 0.1V – 15.0V – that gives 150 steps. It would be easy to use the same solution for having a little smaller 0.05V steps instead – but I like the easy series of 0.1, 0.2, 0.3, … 14.8, 14.9, 15.0V and I see very little use for smaller steps. I can still have a setting that even lets me use all of the 1500 DAC 10mV steps directly – if I use a multimeter to know the output voltage. ๐Ÿ™‚

I just wanted to get this post out there! I will add links to the two small pieces of software needed, a description of use and also a connection diagram!

That means that we are now finished with the calibration and corrections of the voltage setting – next up is the similar measurement, calibration and correction but for current limiting!

See you soon!
/Sfenn

Ar2uino Digital PSU โ€“ 11

This article finally deals with the schematic and the design! The analogue part of the schematic is above and I will start to go through that one. The digital part will be dealt with further down! As I write this as I build I would recommend you to read the text in red below! But I feel that I have come close enough to the final version that I dare to show the schematics now! You are very welcome to follow me on the last bit of the journey towards the goal! ๐Ÿ™‚

WARNING NOTE! As long as THIS text is here I would strongly advise AGAINST anyone to build this YET – as there is bound to be unknown changes coming! So wait a little until I am fully ready! The version on the schematic should be at least v4.5!
I will remove this warning-text when the design is final and fully tested!

This is the block diagram of the Arduino Digital PSU as it looked in the very beginning. I have stuck with the general design but there have been – and until I am 100% ready – still will be small changes and updates to the schematic!
The design can be divided into two parts – a digital part and an analogue part! The Processor, display and control represents the digital part that deals mainly with the presentation of information, controlling the functions and the setting of values. The voltage set and current set DACs are the link between the digital and analogue parts. The regulation is analogue both of the output voltage and the current limit! The digital part – with the Arduino and the graphics display gives us possibilities we would not otherwise have! So to summarize: We have digital settings but analogue regulation! The best of two worlds – I think! ๐Ÿ™‚

The Analogue Part

Looking at the analogue part – it can also be divided into two parts – voltage regulation and current limiting. The diagrams below are not based on the latest version of schematics – but there are no changes that affect the working principles!

Starting with voltage regulation: Prerequisite is that the V-DAC will supply a voltage that goes from 0-5V when the output should go from 0-40V. Using a very standard feedback loop with a voltage divider we can set the amplification needed. We need 5V to be 40V – that gives that there must be a 8x amplification. In the diagram above you can see how the feedback loop works. As an example lets say that the V-DAC is supplying 1V to the non-inverting input of the CA3140 op-amp. The op-amp will increase the voltage output until it is balanced with the same level on the inverting input! As we have fed back the voltage through an 1:8 voltage divider the op-amp will need to amplify the voltage up to 8V before the voltage divider lets through 1V to the inverting input. There the op-amp stabilizes!

You can follow the signal via the thick blue lines: … voltage from V-DAC … amplified through CA3140 … as base voltage of BDX53C darlington power transistor … voltage fed back through 180k resistor … to the inverting input of CA3140 … where it balances out the 1V on the non-inverting input! Voila! Voltage regulation!

One comment is the fact that the forward voltage drop of the transistor is handled “magically” by the feedback loop – but it will still have to be supplied by the input voltage to the transistor so we loose a little voltage level here!

Looking at the current limit there are two Prerequisites: a voltage set from the V-DAC activates the transistor that lets the voltage increase and that in its (immediate) turn will increase the current. Also a voltage from the A-DAC sets the level on the inverting input of the op-amp LM358. As long as the level on the inverting input is largest the LM358 output will be negative! This in its turn will make sure that the 2N7000 transistor is switched off! The current through R1 – the current sense resistor – creates a voltage over it. This voltage is amplified by the LT6105 Current sense amplifier just a little over 12 times so that a current of 4A generating a voltage of 0.4V will generate 5V output.

If the voltage on the non-inverting input of the LM358 is bigger that the voltage on the inverting input – the LM358 will immediately swing high and activate the 2N7000 transistor that will pull the voltage fed into the non-inverting input of the CA3140 towards ground – thereby lowering the output voltage supplied by the BDX53C transistor until the current going through the load will give a current sense voltage that will be the same as the set voltage!

You can follow the signal via the thick blue lines: โ€ฆ voltage from A-DAC โ€ฆ inverting input of LM358 … voltage across R1 amplified through LT6105 โ€ฆ non-inverting input of LM358 … when bigger then inverting output goes high … 2N7000 shorts parts or full voltage to ground … lowering CA3140 output voltage and BDX53C darlington power transistor lowers voltage … current lowered! Voila! Current limitation!

The Digital Part

The digital part is not very complex. It consists of just a few blocks. An Arduino Nano, two MPC4725 12 bit DACs and a 2.4″ TFT Colour Display. A rotary encoder is used to control it all.

I did not want to modify the Arduino Nano that was a 5V device so I let that be supplied with 5V and then fed the DACs also with the same 5V. The display needed 3.3V so I had to add a few voltage converters (5–> 3.3V Not seen above!). I used a standard 7805 5V voltage regulator and a AMS1117 3.3V regulator for the display. This was added so that I could power the digital part of the PSU just from USB 5V. Still the use of 5V in this case gave the PSU the ability to supply both 3.3V and 5V continuously as handy extra voltages – unrelated to the variable output voltage! Not seen in the schematic is the separate LM317T with voltage divider to give 3.3V output!

Would I ever build this again I would be definitely use another processor or modify the Arduino Nano to be powered by 3.3V as it would simplify the design even further – no voltage conversions!

The design is simple: The Arduino is controlled by the rotary encoder and presents information on the display. It uses the DACs to set voltage output and current limit. An I2C bus is used for the control of the DACs. Makes it very compact – just two wires! The display is controlled via a SPI inteface.

This digital part has given me a lot of ideas of “extra” functions like Li-Ion battery charger, tone/pulse generator … etc!

Next up is the calibration of the Ar2uino Digital PSU!

See you soon!
/Sven

Getting ESP-12 to work with Arduino IDE

The ESP-12* is an amazing smoking hot little module with a powerful CPU, memory and Wi-Fi built in! But it can not be programmed and will not even execute without a little support! This is a detailed post about what is needed and how to get it to work! As the title says my goal here is to get it to work with the Arduino IDE! So this journey will start with the bare ESP-12* module suspended in sleep like Snow White and hopefully end with a live and kickin’ one! ๐Ÿ™‚
* In this post I will use an ESP-12F as an example! But it is general enough to apply to several other “ESPs”!

This post is a post in the Ar2uino Dummy Load series just after Step1 and before Step 2 but I felt it was so general that I decided to post it as a separate article. Posting it like this will hopefully make it easier to find if you are looking for stuff about ESP12 and Arduino IDE!

Be aware of …

1First of all we need to remember that the ESP-12F is a 3.3V device and according to the datasheet has an absolute maximum operating voltage range of 3.0-3.6V – but let us stay close to 3.3V just to be nice! There is some writing in the ESP8266 datasheet suggesting that it is 5V tolerant on the I/O-pins – but there seems to be a certain uncertainty about whether this actually is the case! The problem with something like this is that most devices will gladly work some time with “over voltage” and then will fail – sometimes several month later and that makes testing very hard for us amateurs to establish if it really is 5V tolerant! So, for ME the ESP-12F will be considered a 3.3V device and NOT 5V tolerant! Better to be safe than sorry! ๐Ÿ‘

The second thing and quickly obvious to anyone trying to solder an ESP-12F in place, is that the pins are spaced at 2 mm (or 0.07874016″ in that funny inches system ๐Ÿ˜‰ ). It complicates the use of ordinary experimenters boards and you have to take care when you make your own PCBs! But I will not make a programming jig for the ESP-12F so I will not need a holder with 2 mm spacing as I will just use wires to solder it in place! That way the different spacings will not matter! ๐Ÿ™‚ It might not look as “professional” but I will have to try and look beyond that…! ๐Ÿ˜ฃ

3The third “complication” or at least difference is (believe it or not!) the pin numbering! Well, it is like this: in the Arduino IDE you can access the different pins by numbers 0-22 or by predefined constants like D2 or A5. They are always printed next to the pins on the Arduino boards in a nice orderly manner so there will be no mix-ups. Very handy! The ESP-12F is not so straight forward: The pin addresses are out of order and there are gaps in the sequence. Also, the port names are printed on the reverse side! Moreover quite a number of pins are reserved for use of the module! Thankfully it is usually not difficult “translating” from port names to numbers to use with Arduino! Be sure to get a proper printout of the available pins on the ESP-12F you are using.

My ESP-12F is the one in the picture. It might take some time to get used to not have the numbers printed next to the pin! Even more complicated it becomes when you use the D1 Mini with those printed pin numbers … (Not within the scope of this post – I am glad to say!) ๐Ÿ˜

I have colour coded the pin addresses as follows: (Please note that the numbers referenced here are the pin addresses that you use while programming! Do not confuse them with the physical pin numbers of the module!)

  • White pins can be used without restrictions. 2, 4, 5, 12, 13, 14, 16. Seven usable pins in total!
  • Orange pins can be partly used – but not during boot up – making them more difficult to use! 0, 1, 3, 15
  • Red pins are reserved for specific use already, like Reset, Enable, Transmit, Receive and SPI.
  • Blue is the one and only analogue input pin. Can not be used for normal I/O. 6 (AKA A0)

All the pins in the green are area reserved for the Serial Peripheral Interface (SPI) – and are already used with the “internal” SPI 4MB Flash Memory built into the ESP-12F module – but you can naturally also use them for SPI communication with your SPI devices! It includes two not so common SPI pins 9 HD (Hold) and 10 WP (Write Protect) used with the “included” memory together with the CS0 (Chip Select) – used to select the “internal” memory.

A special case is the on-board blue LED. It is connected to pin 2 – BUT to the positive rail. That makes the LED light up when you do a digitalWrite(2, LOW). If you connect another LED between pin 2 and ground it will work in the normal way LOW=off and HIGH=on. This blue LED is also doubling as a serial communication indicator so it flashes a little during communication.

4A fourth complication is the fact that the ESP-12F uses interrupts for a few different things – especially the Wi-Fi routines. Those need to be given time to execute every so often otherwise a watchdog reset will be tripped with the message “rst cause:4,” spoiling the execution of your programme. A delay(0) or a yield(0) call every now and then inside your loop will fix that. If you have a busy Wi-Fi environment the Wi-Fi buffers will fill up quicker and you need to delay/yield more often – but we are looking at around max 15 mS without a delay/yield for it to NOT generate a reset! This IS a complication for sure and has to be handled in the code! ๐Ÿ˜ฆ Not such a good feature of the ESP8266-family but I guess we have to “pay” for the Wi-Fi in some way! What a winner it would be to be able to really switch OFF the Wi-Fi completely and regain memory and processing power!

This need to execute interrupts every now and then affects most programming tasks but is usually not impossible to overcome! But it certainly complicates for example the ability of the ESP to bitbang nice stable pulses. Looking at ESP-generated pulse sequences on an oscilloscope shows that they “wiggle” a little over time with some pulses getting a little longer every now and then. This could break protocols for RGB LEDs like WS2812B which are very particular about a steady pulse stream! An ATmega328 (with no interrupts activated) is definitely better at doing this delivering a rock steady pulse stream!

5A fifth complication is that the ESP12 (and all ESP8266 based modules) need TWO things to happen to make it possible to program (flash) it! First of all the programming pin (GPIO0) has to be pulled low and then the reset has to be made! That would involve doing these things manually before a new program can be uploaded! More about how to make it as easy as programming a standard Arduino – below!

USB and Serial

We have to start somewhere and I start with what I have got already: A USB to serial adapter that I use for my Arduino Pro Mini programming! Is it safe to use with the 3.3V ESP-12F? It uses the Silicon Labs CP2102 UART chip. I got out my NEWLY SILENCED* Rigol 1054z oscilloscope and checked the output levels on all the pins. All signals from the CP2102 were kept at 3.3V or 0V so that will be “safe” for the ESP – so no level conversion is necessary! Also really handy is that the 3.3V level that it outputs is 5V compatible so no voltage switch will be needed to use it with 5V devices either! ๐Ÿ‘
* By the way, it is such a joy with a much quieter oscilloscope! Recommended: swapping in a more silent fan! ๐Ÿ™‚

A very important feature of this particular USB-Serial adapter is that it has all signals from the CP2102 broken out along the edges. We already have the “DTR” that is used to reset the Arduino before upload of a new programme. To bring the ESP-12F into programming mode we have to set the GPIO0-pin low during reset. To do that easily and automatically the ESP-12F we also need to use another signal! We will use “RTS” signal to make that possible!

If you look at the above picture of the back of the USB-Serial adapter you will see that it has a “3V3” output at pin 6 (the bottom pin) and I plan to modify that so it outputs the RTS signal there instead! That is alright for me as I do not use the 3V3 output and it supplies only max 100mA – and that is not enough for the ESP-12F anyhow. Or I might keep the 3V3 and add a 7th pin for the RTS signal … ๐Ÿค”

Flipping the USB to Serial Adapter over and looking at the front. In the picture taken in very bright sideways lighting you can see the track slanting downwards with about 45 degrees marked in blue as A“. In reality it is quite tricky to actually see this track with the bare eye! I needed to use a 10x loupe to spot it! According to my measurements that is the track that leads to the 3V3 pin at the very bottom – and NOT to the GND pin as one would think! The 3v3 pin that I will to use to bring out the RTS signal. I will cut the track and solder a thin wire from the RTS-pad (marked as “B“) to the cut track. (Click the picture to see it enlarged!) You can then easily see the dashed blue line where I will cut the track and scrape away a bit of the solder mask so I can solder the thin RTS-wire to the lower part of the exposed track.

This is how it turned out! I picked a wire with a little colour to brighten things up a bit! ๐Ÿ˜‰ The modification took less than 10 minutes! I cut the track at “A“, scraped the solder mask off at “B” and soldered a wire from the exposed copper at “B” to the RTS-Pad. (Click the picture to see it enlarged!) So now I have the voltage output at the 3V3 pin replaced with the RTS-signal! It might be even easier to just cut the track on the front side and then solder the wire on the back – but I felt that the wire was more “protected” on the front side!

This modified USB to Serial Adapter will now be able to program more USB-less microcontroller boards! It will still do its ordinary “job” to program standard Arduino boards microcontroller boards – like the Arduino Pro Mini*AND from now on also automatically program ESP8266, ESPxxx and ESP-32 modules of different varieties! Read about that further down below!

* The Arduino Pro Mini (โ‚ฌ2/$2) is actually my preferred Arduino for embedding – small, low cost and easy to modify! Powerful enough for many situations! Perfect for IoT-applications when you use batteries or solar power! But if power is no problem and you need Wi-Fi then the ESP-variants are very good value and some variants are practically the same price as Arduino Pro Minis. That makes you wonder if we ever will get the power and the masses of memory like the ESP8266/ESP32 has but without the disadvantages the Wi-Fi support brings? Couldn’t they even be cheaper – I mean if you remove something …!? Why has nothing happened there for so many years? Demand is probably the answer! Well at least we have the Seeeduino XIAO and a few Teensy alternatives – that certainly have the power but not really the price

ESP-12F Connections

Reading the data sheet and also looking at other sources a “two-transistor” solution seems to be used everywhere for automating the reset/programming signals – but according to my testing it does not seem to be necessary so I will pick a simpler alternative. Summarizing it all in the schematic below this is what I came up with … after testing! If this shows any problems in the long run I will make a small additional “in-between” or converter board that contains all extra components that is only needed when I want to program the ESP! All that is needed to run a program should be on the board next to the ESP-12! By modifying the USB-Serial Adapter the way I did makes it work both with the ESP-12F and the Arduino Pro Mini with no change necessary! ๐Ÿ‘

Please let me know if you follow this guide and notice problems with the automatic flashing!

All that is needed on the board together with the ESP-12F module is resistors R1 & R2 plus capacitors C1 & C2! In my case I want to be able to power it directly from any 5V USB power source, power bank or computer so I will also add the voltage regulator for 3.3V and its two capacitors, C3 & C4. According to the data sheet you should have a 22uF Tantalum capacitor on the output but I have increased the size of C3 to 100uF to better handle the short peaks of high power demand that the ESP-12F makes. * Tests will show if 100uF is enough or maybe a little over the top. (If – I will naturally change the information here!)

In some places on the web it is stated that the ESP will need its own power supply in the order of 1A(!) and that the USB from a computer will not be able to power it – but according to my testing that is NOT so! In fact it works very well on the power from a computer USB connection! According to the data sheet it requires a maximum of 170mA but I guess that it might go higher in short peaks so having a bit of a margin is not so bad! A minimum of 5V @ 0.5A will be available from all (read: majority) of all USB sockets. I have had no problem whatsoever powering a D1 Mini from any USB – weather is is a USB charger or a computer USB socket! I do not know from where this “rumour” originates from but (apart from a badly regulated underpowered supply) I can only see one possible reason for having that experience: not large enough reservoir/decoupling capacitor close to the ESP or thin wires used on a prototyping board could also give similar results! A really bad USB cable can drop maybe 0.2-0.4V under a big load but that is from 5V so in most cases it should not affect the voltage after the 3.3V voltage regulator! But a AMS117 has a typical 1.1V drop … so the headroom isn’t really that much … so maybe after all this might give brownout problems …?

One remaining question: Can the ESP-12F be powered from the 3.3V output of your serial board? The answer is probably NOT – but that it depends on what voltage regulator it has – if any! You have to look! I will just mention: AMS1117 is OK (1A). HT7133 is NOT ok (30mA)! Most serial boards instead rely on the built-in voltage regulator of the USB-serial chip and that is usually NOT powerful enough. The three most common ones: CP2102 will supply max 100mA so that is “in the vicinity” but still too low! The FT232R can supply 50mA so that is a clear NO! The CH340 has no info in the datasheet but seems to supply around max 25mA and that is absolutely not enough! To summarize: You will need a separate power supply with stabilized 3.3V and at least 500mA! OR add a voltage regulator as I have done in the schematic above and supply anything from 5V to 12V @ 500mA!

“Solder by Numbers” ๐Ÿ˜‰

Well, lets get started soldering it up! The following connections are in a list – the same connections and numberings as in the schematic above! The physical pin numbers are starting with 1 in the lower righthand corner with the antenna facing upwards counting the numbers (as in the schematic) in a counter-clockwise direction! Number within brackets () are numbers on the USB-Serial adapter. Solder them all up on a perf-board. Free placement mostly – but C2 must be VERY CLOSE to the ESP! Also use proper wires all the way for GND and VCC!

Start by soldering wires to the minimum 8 pins listed below. Naturally also solder wires to all the extra pins you plan to use – maybe all of them!? In my case I will only be using pin 10 (ADC) and pin 14 (GPIO12, PWM) so I will solder wires to those as well. I bring out two extra pins for future use: pin 6 (FAN) and pin 12 (LED). As I said earlier the reason for using wires is to adapt the ESP-12 pin distance of 2 mm to the board 2.5 mm hole raster on the perf-board – an adaptor board is another alternative.

  • 1 GND
  • 1 0.1uF capacitor C2 to pin 16
  • 2 GND
  • 4 10k R2 to VCC 3.3V
  • 4 DTR on USB-Serial (1)
  • 7 TXD on USB-Serial (3)
  • 8 RXD on USB-Serial (2)
  • 9 10k R1 to VCC 3.3V
  • 9 0.1uF capacitor C1 to ground
  • 9 RTS on USB-Serial (6)
  • 11 VCC
  • 16 VCC
  • My extras:
  • 6 FAN
  • 10 ADC
  • 12 LED
  • 14 PWM

As can be seen I have removed a part of the prototyping perf-board to have it as clear as possible around the the area where the antenna will be situated! You might have an altogether different requirement! You might instead let the antenna extend over the board edge for example! You will not need that much space around the ESP-module. If you already have 3.3V for powering of the ESP then you only need to have space for 2 resistors and 2 capacitors 0.1uF. If you do not have 3.3V available then you will also need a little more space for a voltage regulator (ex AMS 1117) and 2 capacitors. If you use Tantalum capacitors they will be very compact!

Before soldering the ESP-12F in place I insulated the experimenters perf-board – anything nonconductive will really do – I used an empty 5 pin Dupont female connector shell. It was just the perfect width and also raised the ESP a little from the perf-board. I glued the Dupont shell to the perf-board in the middle but I will NOT glue the ESP to the Dupont shell!

The wires will help to keep the ESP-12F in place so solder them a little tight – at least that is what I will do! Another alternative is to hot-glue the board in place with a thick blob of hot glue. That will both hold it in place and insulate it electrically – but it will be a total mess if I ever need to remove it – so I will not go that way! ๐Ÿ™‚ If you are willing to waste a row or two of “holes” on the perf-board then you can also use Kapton tape for the insulation and that will work as well! No need for glue here either!

I solder all the wires in place on the ESP-12F board before soldering any on the perf-board! That makes it look like a great spider but it makes it easier to get all the wires into the holes without bending too much! It is actually easier to thread the wires into the holes if you cut them each at a little different lengths. As I am not using all the “pins” I have skipped soldering wires to the unused ones – and that meant that I got a little extra freedom in picking the holes! Also note that I have soldered just one(1) wire to both pin 1 and pin 2 – as they are both going to be connected to GND. When you have managed to put ALL the wires in the planned holes – press the module gently down! I chose to use ordinary one-stranded wire to give the mounting a bit of extra stability. Always use a these thicker wires for the GND and VCC as the ESP-12F is very sensitive to brownouts. The first few wires are the most important ones for the placement so be extra careful when soldering those! I start with the ones closest to the corners!

After soldering the ESP-12F in place it is just a matter of fitting the rest of the components (2 resistors, 2 capacitors) on the board. In my case I also wanted an AMS117 3.3V voltage regulator and 2 capacitors on the board as well. That is to be able to power it (the Ar2uino Dummy Load) from a USB 5V source or really a variety of other power sources up to (depending on load) 12-15V.

Placement is noncritical but this is how I placed my components. IDs refer to the schematic above. The SMD-type components (IC1, C3, C4) have just been soldered to the through-plated holes on the top side and the wires are soldered on the bottom side. NOTE: The C2 capacitor placement IS important and is soldered at the bottom, directly between the VCC and GND connections of the ESP-12F module – so it is not seen in the picture. (Click the picture to see it enlarged!)

As I build my projects at the same time as I write I seldom have the “luxury” of a readymade PCB but instead solder my components on a protoboard/perfboard and use wires to connect it all. It certainly does not look as tidy and elegant as a custom made PCB but usually works alright and is so much quicker than waiting for PCB to be made.

Adding ESP8266 support to Arduino IDE

Well there is actually one step left before you can program the ESP-12F and that is to install support for the ESP8266 series of boards into the Arduino IDE environment.

Go into File – Preferences and add the following “http://arduino.esp8266.com/stable/package_esp8266com_index.json” (only the blue text without the “-chars) and click “OK”. Either you can add it to the end of the line with a comma (,) before – or you can click the icon after the line to show the above dialog form where you can add the new line!

Next go into Tools – Board – Boards Manager…

Search for “ESP8266” and click “Install“. After a little while (it is quite extensive package) the “INSTALLED” text is shown as above.

Next go once again into Tools – Board but this time scroll down till you see “Node MCU 1.0 (ESP-12E Module)” – and click it!

Testing of the total ESP-12 solution ๐Ÿ™‚

Now it is time to see if we can get the “blink”-program uploaded automatically! The modification of the USB-Serial adapter and the components on the board – will they work together as intended …? Finally: Open the “Blink” sketch and upload it to the ESP-12F module! The standard Arduino sketch nowadays uses a defined constant to the built-in LED so it should work right away! ๐Ÿ™‚ NOTE: In case you think it does not respond correctly to your changes of the blink times be aware that the blue LED is connected from the VCC so it lights up when the pin goes LOW!

I am VERY HAPPY ๐Ÿ™‚ to say that it worked very well! I even increased the upload speed to 921600 bps and that really shortened the upload times! ๐Ÿ™‚ That really helps with development iterations when you test and test … because the upload size with ESP-modules always are quite big as it includes the whole WiFi-stack – every time!

After this relapse into (really!) the Ar2uino Dummy Load project I will be returning to the Ar2uino Digital PSU project again.

See you soon!
/Sfenn

Ar2uino Dummy Load โ€“ 6

I had not planned to continue with the Ar2uino Dummy Load any more for the moment until Step 2 – but the day before yesterday when I replaced the normally(?) noisy fan of my Rigol 1054z oscilloscope with a more silent one (Gelid Silent 5) I suddenly had a fan of the right size left over! Not such a bad fan either but to noisy to listen to over extended periods with the oscilloscope! But that did not matter in this case – any fan would do for the dummy load! Just one critical thing wrong with it – it was a 12V version! The 5V fan that I sent for was $10 with shipping and even if I have gotten that money back now – I still have no fan! Then I realized that I could use this “left over” fan just by adding a DC-DC Voltage Booster to bring those 5V up to the stipulated 12V – for less than $1/โ‚ฌ1/10SEK! No need to send for another 5V fan and pay $10 again! ๐Ÿ™‚

That is really a good idea that I will have to remember in the future! Power something by 5V (or even 3.3V) and need a fan? Then use a 12V fan and a DC-DC Voltage Booster and get variable fan speed thrown in! So now all my 12V fans can be used at much lower voltages! That is really cool! Eh!? ๐Ÿ˜‰
(Albeit at the expense of higher current requirement.)

At least for the moment what I have is a manual speed control that I can use to lower the fan noise a bit when the load – and the cooling capacity needed – is not so high! ๐Ÿ‘ I have had plans to make the fan temperature controlled in Step 2 or controlled by the ESP8266 depending on the load – but this might turn out good enough … I will see!

It is a scary moment when you have cut the wires at exactly the right length and then have to remove the insulation! You know that if you fail and cut through the wire – it will NOT fit very well and you will have to extend the cut off wire in some not so very elegant way! The critical de-insulation – went well after all! ๐Ÿ™‚ Just to calm my nerves I added a back-EMF diode! That is to protect the booster from the high voltage generated by the fan motor working as a generator when the fan spins down. I just soldered a 1N4007 across the output terminals! (See the red arrow!) No particular reason for picking the 1N4007 – just because that was what I had at hand. Well it has to handle the desired max forward voltage naturally! The 1N4007 does that hands down! ๐Ÿ˜‰ It was an SMD type with solder pads made from bent flat “wires” so I “unbent” the solder pads somewhat to be able to solder them a little easier.

Then is the question of if the fan is most efficient when “blowing” or “sucking” air? I will need to test this just to find out how it is – at least in this case! Not that I think the difference will be big enough to matter that much! It is just fun finding out! ๐Ÿ™‚ Judging from the manufacturers sticker (assuming they want to be seen) it should probably be “sucking” the air out of the heatsink – but to my … ehrm … extra sensory perception – tells me it would be better with “blowing” air into the heatsink! ๐Ÿ˜‰ A small test will give the answer … and the answer is …

Heatsink temperatures with the fan blowing air into or sucking air out of the heatsink. 5 min settling time on each.

To quote a nice song: “The answer my friend, is blowing IN the wind…” Well, as expected the difference is not very big degree wise but it is definitely clear and big enough to motivate choosing it! Blowing into the heatsink is the most effective! See diagram above! As the fan was blocking the view of the heatsink innards I could not use an infrared thermometer so I decided to use the temperature add-on to the multimeter to find the temperature. This time I measured it at the transistor side of the heatsink, at the transistor metal tab. Measured with the fan set to be powered with 12V – that is “full blast”. Room temperature was 21ยฐC and it was open space all around the heatsink.

The loads I measured was 20V and 300mA and 500mA – translating to 6W and 10W. The temperatures (above) that those loads gave translates to temperature increases of 0.5ยฐC/W when blowing and 0.75ยฐC/W when sucking air. That is around 50% worse when sucking air – not such a small difference after all! The temperature measurement was only possible in whole degrees Celsius so it is a bit coarse – and the measurement points were not very far apart – but the difference is clear! I removed the fan and let the temperature climb a bit and then replaced the fan again – and every time the temperature settled on the above levels! To go by these values a 50W load should raise the temperature around 25ยฐC from room temperature and that puts it in the vicinity of 45ยฐC – if the fan blows into the heatsink!
(I broke off the measurement of 500mA without fan as the temperature broke 48ยฐC and was still climbing!)

I used heat glue to stick the DC-DC booster to the side of the fan – out of the way. The thinking was right – but NOT the glue! I was only left with a small “glue-coin” that did not stick to either surface! So I switched to superglue and that seems to have done the trick with a small distance put in between to cater for the soldering bumps! One thing that initially had me flabbergasted (just for a little while, mind you!) was that the booster would just “pass through” any voltage that I fed to it and no matter how much I turned the little trimmer screw (clockwise) nothing happened – not even when I turned it counter-clockwise did anything happen! ๐Ÿ˜ฆ Then I realized a small lead bridge over two pins at the small IC on the booster so I tried to fix that with a solder wick – but no improvement! I decided to try my other sample of the same DC-DC booster – but the same result! Both broken? Murphy hit me twice? Unlikely … so then I decided to turn it all the way counter-clockwise! Lo and behold – after about 5 to 10 turns the output voltage started to go up! I set it for 12V and connected the fan – and it was as noisy as before! But now I can adjust it! Lovely! ๐Ÿ‘๐Ÿ˜

Those small DC-DC Voltage Boosters are certainly both handy and cheap. But they are switching which means they are generating high frequency electrical noise. Will this disturb the dummy load maybe? We are dealing with some very minute voltages there! A look at the old oscilloscope would not be amiss!

See you sooner!
/Sfenn

 

Ar2uino Dummy Load โ€“ 5

DummyLoadReadyStep1TestIll

At last it is time for testing the Ar2uino Dummy Load! ๐Ÿ™‚ย  The Corona pandemic has been very “mildly” handled here in Sweden with few restrictions on what we can do (but instead putting most of the responsibility on ourselves to behave with care) so I should not blame that for my slow progress but it has affected the ability to meet with friends – and talk about nice things like Dummy Loads. ๐Ÿ˜‰

I would also like to again point out that the Ar2uino Dummy Loadย also can be seen as just an improved version of the Ar2uino Battery Tester (3) – but it has a wider scope than that and I have therefore changed its name! The battery tester functionality will appear in Step 2 of this project – when we add the ESP8266 microcontroller!

Things to test will be:

  • Ability to keep a constant load as voltage varies
  • The resolution โ€“ can I set it to the exact mA
  • What is the lowest current load setting I can make
  • What temperature will the heatsink be at a few different loads
  • What internal resistance will it have with 5V power, the Op-amp and transistor used – that shows how low I can go with a low voltage and a high current at the same time.
  • The stability of the load (Oscilloscope analysis)

Constant Load Test

First out to be tested is naturally the ability to keep a set load while the voltage varies. The theory behind this is as follows Ex: Start out with 100mA load at 5V. According to the standard formula Voltage= Resistance * Current this gives that the load should “pose” as 50ฮฉ resistor (5/0.1). If we change the voltage to 10V it should keep the current constant at 100mA so it would need to “pose” as a 100ฮฉ resistor (10/0.1). The same applies for 15V when it should “pose” as a 150ฮฉ resistor. This is handled automatically by the feedback loop formed by the current sense resistor and the Op-amp. We just have to set the desired current load with the 100kฮฉ potentiometer. That is all! With any voltage applied the Dummy Load will change its resistance so the a 100mA current flows through it in the above example! What it really is about – is to keep the voltage over the sense resistor constant! A very appropriate task for an Op-amp with a feedback loop!

I have still not yet received my 5V 50mm fan from China (will I ever โ€ฆ?) โ€“ shipping times are really the worst with shopping from that far! I decided to go down to my local electronics store and buy the same fan there โ€“ for 10 times the price โ€ฆ well they did not have it in store but would get it in a few days – they are very helpsome and friendly! And it was really 10 times … ๐Ÿ˜ฆ AND I had managed to get a fan that did not fit my heatsink! ๐Ÿ˜ฆ

Lacking the fan makes testing of the higher loads at higher voltages not really feasible โ€“ but I will try short time loading to avoid heat build up!

Testing: 10mA, 50mA, 100mA, 500mA, 1000mA, 2000mA โ€“ from 0.1V to 20V.

ConstantLoadDiagram2As the diagram shows the dummy load is very stable from 0.1V to 20V for all loads! Stupidly I measured the current with a current meter (they have a built-in sense resistor) – further adding to the internal resistance. This shows as the up-ramps between 0.1V-2V on the 500-2000mA curves indicating around 1ฮฉ total internal resistance. (I might re-measure this later using a voltmeter over the dummy load’s own 0.1ฮฉ sense resistor to see if I get steeper ramps – that is lower internal resistance! I managed to blow the fuse on my power supply during testing – and naturally I had no spare – so this will have to wait a little …)
The rest is just straight lines! ๐Ÿ™‚ That is excellent! It shows that it manages to give the same stable load no matter what the voltage is! The difference is less than the last digit on the multimeter! I could not read anything below a 1 mA difference due to the multimeter ranges! This is really nice – stability is what I want in an electronic dummy load! ๐Ÿ™‚

Resolution Test

PotentiometerEffHaving a 100kฮฉ trimmer 25-turn potentiometer should give us a very good ability to set the load according to our wishes! Each turn translates to just 4% of the total resistance and should give us an ample number of settings. In theory we should be able to set the potentiometer to an unlimited number of resistance values – BUT testing it out with an Ohm-meter I found that with a reasonable amount of fiddling the smallest fraction I could set it for in reality with any form of repeatability was in the region of 50ฮฉ. That would turn out to be 2000 settings for the whole current span. In my case that is 5700mA (5.7A) which would be 2-3mA in each step. To my way of thinking this is much more resolution than I need!ย  With a bit of fiddling any load could probably be set! I am mostly interested in a stable load!

ESP12-FsIn the upcoming Step 2 of the Ar2uino Dummy Load when an ESP8266 will be used to set the current load – it will be handed via PWM instead of the trimmer potentiometer. According to the data sheet the ESP8266 features a 14 bit PWM resolution at 1 kHz refresh rate. That will give us over 8000 digital steps with (in theory!) less than 1 mA in each step!

ย 

Lowest Current Load Test

30mAWith the 100kฮฉ potentiometer I can relatively easy set it for around 30mA again and again. But it is like a “jump” in resistance at the lowest setting! When I fiddled a lot (several minutes!) I managed to set it for 10mA – I could not believe my luck – but it is not something I would like to do regularly! So I would say that 30mA is the lowest current that can be set with the trimmer potentiometer!

ย 

Heatsink Temperature Test

DummyLoadHeatSinkSAs the most heat will be generated at higher currents and higher voltages – that is what I will focus my testing on.ย  As the MOSFET transistor in use IRL540 will handle >20A current and a power dissipation >150Wย  (IF it has an enormous heatsink!) it will stay in the no risk zone with the “small” maximum load of 20V at 2A = 40W – which is almost the limit of what my old PSU can deliver. To get some idea how the dummy load heats up I will start with just 100mA at 20V. That will translate to just 2W of power that has to be turned into heat. At 500mA the power turned into heat is 10W.

Due to the problems with the stability of my old PSU (See below!) I have so far just tested 5V at 500mA and the heatsink did just about turn luke-warm! This gives just around 2.5W (5V*0.5A )to cool away…!

HeatsinkTemperature

Using a infrared thermometer the above heating was measured at a room temperature of around 22ยฐC at different current loads (50, 100, 200, 500 and 800mA marked by the small blue points above). The temperature was measured at the centre of the heatsink – just about where the power MOSFET transistor was bolted on the other side of the heatsink. A very stable 12V lead acid battery was used and the dummy load was very stable – just showing a straight line on the oscilloscope! Thank you EW for the help!ย  ๐Ÿ™‚ I stopped the measurements when the temperature had risen to 50ยฐC as it was really too hot to touch comfortably. At that point the current was 800mA (0.8A) and the heatsink had to take care offย  around 10W of heat! This gives us close to 3ยฐC/W in temperature raise for this heatsink. If we double the power we would theoretically be looking at a temperature of 80ยฐC – far to hot to handle without a fan!

Higher loads will be measured in Step 2. The good thing with using a battery for this test is that I could see that the dummy load was really stable – no interference from a PSU! See more about stability below!ย 

Load Stability Test

PSU Direct Voltage 5V SwitchingSuppliesOn

This certainly was much more tricky than I expected! First of all there were so many sources of disturbing electrical noise! I set up the oscilloscope and switched on my old PSU and set it for 5V output – unloaded. Then I was really surprised to see the SAWTOOTH wave curve above – and to that a lot of “fuzz”!

Some easy testing showed that apparently it is my old LM723 basedย  linear PSU that produces the sawtooth shaped curve at 50Hz! NOT the dummy load! Our mains frequency here in Sweden is 50Hz – that must be involved in some way… That in itself is a question! The sawtooth is just 20mV but all the same – should it look like that? Google did NOT help – I could not find a single relevant trustworthy oscilloscope picture of a normal LM723 voltage curve! But mine has for all I know been like this for MANY years – and the sawtooth is not very big – and I have used it with no problems – until I got the oscilloscope and could see …!

Ignoring the sawtooth there is still all the fuzziness around – in my case it comes from a few different switch mode PSUs! I had 3 of them around me: one for my portable computer, one as mobile phone charger, one for a small desktop LED-lamp and finally the big culprit – one powerful magnifying lamp with a circular array of LEDs and a built-in switch mode PSU!ย 
(Click any of the oscilloscope pics and it will open in a new tab!)

PSU Direct Voltage 5V

Switching off all the sources of electrical noise I was left with the curve as seen above. A 50 Hz saw-shaped curve with a small high frequency wave superimposed on it. The ripple (saw-shaped) is around 17mV. This level is perfectly acceptable for this type of PSU according to knowledgeable friends of mine. Zooming into the curve as far as I can to see the high frequency part showed the following:

HiFreqJitter

This is as far as my oscilloscope will go! The high-frequency wave is 500uV with peaks extending as much as the double (1mV).ย  It has a period of around 4-5nS but wobbles a bit with a longer gap every now and then. This is precisely similar to what the scope shows when there is no probe at all attached to it or even with the input shorted with a special plug! So this high frequency wave must be from within the oscilloscope. These levels are perfectly acceptable and can not be avoided as I see it! With this I think I have eliminated most of the error sources – and understand the rest.

Only Cables

I decided to definitely eliminate the dummy load as the one to create the sawtooth by using a Li-Ion battery and load that with 50mA & 100mA! First out above is just the probe and cables in the setup – no dummy load connected! As can be seen above this gives a stable curve with the “standard” superimposed high-frequency wave. But the cable do provide some sort of noise pick up!

Li-Ion_4.2V_50mA

Dummy load 50mA at 5V above! Looks very similar to the “cables” above! My deduction is that it is stable!

Li-Ion_4.2V_100mA_a

Dummy load 100mA at 5V above! Also looks very similar to the “cables” and 50mA load above! So again I think that indicates that it is stable!

That concludes the Ar2uino Dummy Load tests – which I think shows it is stable enough for use as a – yeah – dummy load when testing other things.

ย 

Conclusion

DummyLoadReadyStep1sThis is definitely a worthwhile and simple device to buildย  ๐Ÿ‘ – every “little electrician” should have this in the toolkit. ๐Ÿ™‚ Few and cheap components – maybe even in your scrap box? Easy to build, no complex diagram to follow! Layout non-critical! Even this Step 1 version with the little trimmer is very usable! Admittedly it is a little fiddly to adjust the load with the small trimmer – but you can naturally use ordinary full-size potentiometers if you want – you could even have two in series with one acting as coarse adjustment and the other as fine – but they will only be used as trimmers in Step 2 of this project!

Well now that it is usable I will be able to go back to the Ar2uino Digital PSU project where this Ar2uino Dummy Loadย  is very much needed! ๐Ÿ™‚

I will return to this project after that the Ar2uino DPSU is finished and go on with the Step 2 and add the ESP8266 with the needed software.

UPDATE: As I will be using the Ar2uino Dummy Load some time before I go on with Step 2 and add the ESP8266 – I have seen the need of a “Power-on LED” so that I can verify that I have a working supply to the electronics (really just the LM358). I have added a small blue LED and a 470ฮฉ series resistor over the supply lines from the small micro-USB connector for that purpose!

See you sooner!
/Sfenn

Ar2uino Dummy Load โ€“ 4

As can be seen above I have really gone for compact with the Ar2uino Dummy Load (aka Ar2uino Battery Tester 3)ย built according to step 1. Controlled just with the potentiometer. Very easy! Just set the current with the potentiometer and measure the current going through or measure the voltage across the sense-resistor. Remember that 1mA current will give only 0.1mV across! So 1A will give 0.1V.

Above you can see the side with the micro USB connection for 5V power to the Dummy Load. Also you see the 25-turn potentiometer for setting the current load. To the far right as a blurry green square on the other side you can see the screw terminals for connecting the load! There is room the the right of the USB connector for another power connection in case you want to power it in another way. At the moment (step1) it draws very little power – just about a mA! In step 2 when we add the ESP8266 it will draw substantially more power 2-300mA and even more in short bursts. We will make sure to include a proper reservoir capacitor to handle the peaks. I am waiting for the 5V 50mm fan that will be mounted on top of the heatsink – the “U” shaped form at the top takes 3mm screws so mounting should be easy! Even if I will test it I will not be able to go to very high loads swithout the fan! NOTE: The above USB is just for power – not for programming or communication!

Here is the other side slightly from above. On the very left you can easily see the screw terminals for the load. This is where you connect whatever you want to test. Power Supplies, Power Banks, Batteries … etc. In the shade under the heat sink you can see the 0.1ฮฉ sense-resistor. It is soldered hovering a few millimetres above the PCB and also a few millimetres below the heat sink. Practical tests will show if this is a feasible solution heat wise. The connection wires have been bent to allow easy access in case you want to monitor the current by measuring the voltage over the sense-resistor. You also can see the two heavy wires (red and black) that carry the current up to the Power MOSFET that is bolted to the heatsink. Not seen is the LM358 op-amp hiding in the middle under the heatsink.

Here it is “unfolded” so all of it can be seen. Not much really – but it is a very simple circuit! Placement of the components is not very sensitive – but try and keep wires as short as possible and go for heavy gauge wires where I have so indicated in the schematic! I went for compact and that has forced me to use longer wires than would have been necessary with a more “sensible” layout. Another throw in just to looks is the red and black wires that I let extend out a bit – looked cool I think! ๐Ÿ˜‰ A little blurry you can see the IRL504 Logic Level Power MOSFET bolted to the heatsink with an isolating silicon pad. Gold ๐Ÿ˜‰ spacers keep the hot heatsink away from the rest of the components. Heavy gauge wires lead the current up/down to the board. Closest is the white 0.1ฮฉ 5W sense-resistor. Behind that is the 1uF capacitor and the LM358 op-amp and its standard 0.1uF decoupling capacitor. Along the further edge is the micro USB power connector, a 470kฮฉ resistorย and the 25-turn 100kฮฉ potentiometer.ย  A 10uF Tantal SMD capacitor finishes of the components just in front of the potentiometer. Left is only the screw terminal for the load! That is all there is to it! ๐Ÿ˜‰

I have left space on the board for the ESP8266 ESP-12F module and the 3.3V voltage regulator to be added in step 2. As you can see I have also made a cut-out for the ESP-12F antenna so that will have free transmission in most directions.

As mentioned earlier the layout of components is not very critical but make sure to save space so that the ESP8266 module can have free transmission in most directions. The closer to the heatsink the antenna is placed the more the heatsink will block or weaken the WiFi-signal. Because of my small and cool heatsink I opted for cool and compact – but see that just as a not so optimal layout and maybe also not such an optimal heatsink! There is also no need whatsoever to go with the very compact and folded design layout that I did! But cool it is … ๐Ÿ˜‰

Well, next up is the testing of the Ar2duino Dummy Load. Read about it in post no: 5!

See you soon!
/Sfenn

Ar2uino Dummy Load โ€“ 3

This is how the Ar2uino Dummy Load Step 1 electronics design looks at present! It is a very simple design and not complicated at all! This is a standard design of using an op-amp! I have included the logic level MOSFET IRL504 so that it will work well at 5V. As I said you can use practically any MOSFET as long as you can drive it and do not exceed the max specifications. NOTE: If you use a standard non-logic level MOSFET you might need a voltage step up module or power it with around 9V instead.

We are using the MOSFET transistor to ‘burn off’ a selected amount of current so a heatsink is necessary! How big and if you will need a fan depends on how many Watts you want to load it with! In the schematic above you can see how to change components for different load maximums. I have gone for the lowest using a 470kohm R4 giving a max (theoretical) current of 5.7A. As the table (of a few standard resistors) shows that will generate around 3.2W and the 5W resistor I have chosen as R1 can handle that! It will definitely get really hot at max load. If you decide to go higher in current be sure to swap the R1 for a higher wattage one! I feel that it is best to limit the current by a selected resistor this way – then you can not by mistake turn the current load too high! Be sure to have a good Watt margin on your sense resistor (R1). NOTE: The table above is calculated for the Step 2 version of the Ar2uino Dummy Load when R6 is fed a stabilized 3.3V. Either you live dangerously (like me) and make sure you do not overload the sense-resistor by going too high – OR you use 820kฮฉ as the R4 resistor – that will limit the current to 5.7A and 3.2W. You should definitely do thisย if you do not intend to continue with the ESP8266 in step 2!

Picking the sense resistor is a almost always a compromise. You want the voltage across it to be of a reasonable level for it to not be riddled with electrical noise from the surroundings and at the same time small enough that the heat generated in it will not be too big. If we look at my design as an example: I picked 0.1ฮฉ soย 1mA will generate 0.1mV across it. That is very small but is still handled well with the op-amp. 5.7A will generate 0.57V and that turns into 3.2W and that in its turn turns into HEAT! I could have picked 0.01ฮฉ and that would have made all the difference in heat generated – BUT that resistance is so low that almost everything will affect it – the soldering, the wires, the contacts, etc. On top of that the voltage generated for 1mA is just 0.00001V (10uV) and here the noise starts to be (too much?) more noticeable! It is doable but puts (in my opinion too much) demand on the construction!
Another thing that is affected is the internal resistance of the dummy load. The sense resistor of 0.1ฮฉ together with the resistance of the MOSFET adds up to around 0.2ฮฉ of total internal resistance. This is the lowest resistance that the dummy load can offer – or if you want the highest load it can offer! At lower voltages the load is restricted by the internal resistance!
Ex: At 1V the theoretical maximum load is 5A, at 0.5V it is 2.5A and at 0.1V it is 0.5A. I will test this to get real life values!

Just a few words about how wonderful op-amps are! ๐Ÿ™‚ We want to have a certain amount of current going through our dummy load. We measure that by having a sense resistor (R1). Applying the standard equation volt=resistance*current we can calculate the voltage that a current will give over the resistor. In our case the resistor is 0.1ohm. We want max 5A so this is just 0.1*5 which gives us max 0.5V.
In this circuit we just tell the op-amp what voltage we want to have over R1 by setting that voltage on the non-inverting (+) input of the op-amp. It will then (“on its own”) adjust the output until the inverting (-) input is equal to the non-inverting (+) input. The wonderful part of it is: We do not need to know the exact level necessary as the op-amp will adjust that “automatically”! We do not need to know the exact voltage when the MOSFET will start to conduct or exact how much voltage to apply to the MOSFET gate to get it to conduct the right amount to let through the exact amount of current to get the voltage over the sense resistor to match the voltage we set! I do not even want to think of the work to do this precision work without an op-amp! It makes it sooo simple!ย (The IC is here placed on an apple!)
The op-amp will adjust this “automagically” for us! In short: op-amps are amazing! ๐Ÿ˜‰
(We do need to design the circuit so all these things are “within reach” for the op-amp though!)

It is easy to change it from potentiometer controlled to an ESP8266 controlled later on – in step two. Until I return to this I will keep it connected to 5V and will have to use the potentiometer and a multimeter to set the load current! NOTE: That the table above is calculated for 3.3V! The potentiometer is not even wasted at all in step two – we will use it to calibrate the output from the ESP8266! We will just re-solder the R6 to 3.3V when we add the ESP8266!

Next step is to actually build the Ar2uino Dummy Load as in step 1 – with the potentiometer and no ESP8266. Read about it in post no:4!

See you soon!
/Sfenn

Ar2uino Dummy Load – 2

Building the Ar2uino Digital PSU has shown me that a variable electronic dummy load comes in very handy when designing prototypes for different projects. Every makers lab should have one! I have built two battery testers so far and as they really are just a form of specialized dummy loads I have decided that the new battery tester Arduino Battery Tester v3 should be more versatile so that it can both test batteries and also be used as a general dummy load – that makes it the all new Ar2uino Dummy Load! That is the reasonย why I have changed the title of this blog series! ๐Ÿ™‚

Design

I am thinking of designing it along the lines of a load of max 25V and max 5A – but not both limits at the same time! That would handle the majority of situations I could think of. A fan would have to be included as there would probably be some heat that has to be ventilated away – and I do not want a massive chair-size heatsink! If I can avoid it! ๐Ÿ˜‰

In case your requirements are totally different to the above it is easy to change the solution to handle these limits! First of all the Power MOSFET that I plan to use (I have a few IRFZ44N laying around!) will easily handle a continuous load of over 35A and up to 55V – as long as the total power dissipation is kept below 94W – AND the required cooling is available! So you could have for example 15A load at 5V or 1A load at 55V! BUT you would have to have a very good cooling to go so high! And then if that is still not enough you could also just swap “my” transistor for a beefier one … ! Use an IRL504 if you need higher voltage! It goes all the way up to 100V! As we are using this transistor as a sort of “variable resistor” almost any Power MOSFET will do! Or you cold have a few parallell transistors instead! The above is up to you but myself I will keep away from the extremes! ๐Ÿ˜‰

How many Watts the Dummy Load will really be able to handle will depend a great deal on the level of cooling I will be willing to supply – and that I have not decided yet! I do not see that I will ever need a 94W load … but we will see how difficult it is to achieve this! I will probably use a small heatsink – and a fan to compensate for this! I am thinking “compact” for this device! I have an old CPU heatsink 50x50x35 mm (2″x2″x1.4″) that I plan to use.

As previously described the general idea is to employ an ESP8266 as the main microcontroller. It has one big advantage with the built-in wi-fi but also a big disadvantage with only ONE analog to digital converter ADC. ๐Ÿ˜ฆ The version 2 of the Ar2uino Battery Tester did very well with just one ADC due to the fixed load resistance – but to build a variable electronic load one should really use two ADC:s – one for measuring the voltage across the load and the other to measure what the actual load current is.

That can easily be fixed by using an Arduino for the measuring job and the ESP8266 mainly for presentationย and wi-fi. A tempting idea! Another alternative is to add an extra ADC – for example the 4-channel ADS1115. Either solution is roughly the same price ADC or Arduino Pro Mini – just below 2โ‚ฌ/$2. An advantage in using an extra separate ADC is that it is higher resolution – 16 bit vs 10 bit! An advantage of using an extra Arduino is it can offload work from the ESP8266. I do not feel I would need the extra resolution in this case!

The offloading with an extra Arduino is not such a bad idea considering that the ESP8266 has more things handled in software compared to the ATmega328 where it is handled in hardware. PWM is handled in software. So there will be more of a challenge to develop the code for the Dummy Load in such a way that it does not disturb the “firmware”.

It just irritates me that I would have to add an extra module to the ESP8266 … but it can be avoided IF the set current value is accepted as a correct value … which is a quite a bit of an assumption to make! I will naturally have test it to see if it is acceptable!

I have already tested the PWM stability of the Arduino (ATmega328) and found it to be very good – so I will not add any digital to analog converter (DAC) either but will instead use the ESP8266 PWM with a small RC filter for 1024 steps. This helps to keep the circuit simple. The ESP8266 will hopefully be as stable as the ATmega328! Testing will give the answer!

Those 1000 steps would translate to 5 mA steps in my max 5A design. And I might add one lower-load setting with 1 mA steps up to max 1000 mA for measuring smaller loads/batteries. Load can also be varied by pulsing the load.

I plan to power it from an ordinary 5V USB cable. That will make it very easy to power it from a mains USB adapter/charger or a USB Power Bank – depending on your needs. Or you can even power it from a USB port of your computer. When using it with a Power Bank I plan to have the ability to switch on/off the wi-fi updates to save battery power!

Using a low cost easily available Power MOSFET with a threshold gate-to-sink voltage VGS(TH) of 2-4V might require a higher voltage than 5V to drive it properly so I will add a voltage doubler or a step-up module if necessary – as we only need mostly voltage and very little current. A step-up module might bring it all the way up to 12V making an easier selection for fan! Wish I had gone for the logic-level IRLZ44N (VGS(TH) of only 1-2V) when I got the MOSFETs … then I would not have to handle this! Well, there is an electronics component shop in town … ๐Ÿ˜‰

UPDATE: I actually paid the electronics shop a visit and got a few IRL540’s – so I will be using those! It simplifies the solution a little. ๐Ÿ™‚

Components list:
  • ESP8266 ESP12-E/F
  • Power MOSFET IRF540N/IRL540/IRFZ44N/IRLZ44N
  • Heatsink with 5/12V fan
  • LM358 Op-Amp
  • 0.1 ohm 5W resistor
  • Misc capacitors, resistors and diodes
  • Optional step-up module
  • USB to Serial adapter – for programming!

Software

The software can be considered consisting of two parts: the presentation/settings part and the electrical part.
The presentation part will first of all create the webpage where it will handle the setting up of the Dummy Load – how many mA load should load the source with or any pulses to be used or any other settings. Here you will also decide if you want to use it as an automatic battery tester or a general dummy load.ย The electrical part will control the loading as by the setting. It will also measure voltage across the load and calculate the load in mAh/Wh. With these values the presentation part will create diagrams and tables of the measurements.

I assume that the software will be the real challenge in this project – as always! ๐Ÿ˜‰

To be able to use the dummy load as quickly as possible for the testing of the Ar2uino Digital PSUย I am going to make it in two steps:

1:st step is to make a simple version that is controlled with just a potentiometer. That will be good enough for the testing I need initially with the DPSU. Read about it here!

2:nd step I will return to this Ar2uino Dummy Load project as soon as I have finished the DPSU and continue to add the ESP8266 and support for Wi-Fi!

See you soon!
/Sfenn

Ar2uino Digital PSU โ€“ 10

This is a the DPSU measured with a 0.5% precision multimeter and the built-in 10 bit ADC in Arduino (ATmega328P). Every 0.5V was measured. When doing any kind of measurements one has to have a reference! I have decided (with some evidence to support this) to trust my multimeter the most. Therefore both curves above needed to be corrected to coincide with the multimeter readings!

First of all there is an offset error with the DAC. The multimeter readings shows that the output from the DAC is generally about 45mV too high. The multimeter curve above has been lowered 45mV all over the voltage range to illustrate this. One would have to accept that the MCP4725 DAC:s that we use have this type of deviation! Pretty decent I think with around +-30mV over the entire voltage range – except for +50mV at 11.00V – is quite alright. I will probably want to do something more advanced about it in software later on – but for now this simple correction will have to do!

Secondly I automatically measured (at the very same time as above) the output from the DAC with the Arduino 10 bit ADC. That measurement had a slight gain error that I corrected with a standard linear formula. It brought down the deviations to much the same as the multimeter readings – but with generally bigger swings between too high and too low values. Still it is easy to see that both the multimeter and the Arduino ADC have measured the same DAC voltages. So if we squint a little the curves above shows roughly the MCP4725 DAC deviations. Also here I will do something in the software late on.

It would not be very difficult to make adjustments in the software to get deviations down to below just a few mV for all the above measurements. Also it would be “easy” to adjust all settings to within +-10mV for each 0.1V setting – that is 400 voltage settings. But considering that the DAC has over 4000 possible voltage settings, every 10mV from 0V-40V puts up some challenges! To correct all those is not feasible with the small EEPROM memory of the Arduino – even if we use compression of data – we would have to add extra I2C serial bus memory for around $1. That in itself is no big deal but we also have the question of HOW we should accomplish this! Manually measuring 400 values is ok – if tedious! But 4000 …? It would have to be an automatic or semi-automatic calibration!

The difference between the DAC with 12 bits and the Arduino ADC with just 10 bits means that we will be able to set it much more precise (4 times) than we can measure! It is possible to even out this difference and improve the built-in 10 bit ADC of the Arduino by using oversampling. We do this by oversampling (measure) 16 times and sum the results, right shift 2 bits or divide the result with 4. We will then be left with 2 extra bits! ๐Ÿ™‚ So 10 bits turns to 12 bits! A small amount of noise is necessary for this “trick” to work. Just out of curiosity I will test it out. As we are only using the ADC for display purposes the extra time it takes to measure 16 times does not really matter. We will not update the display more than around 2 times/second anyway! My explanation is just the basics – search for “oversampling” to know more!

Another, very tempting, and possibly better idea would be to add a much better ADC like the 16 bit ADS1115 and use that to improve the results! By also adding an extra EEPROM memory where to store the voltage corrections it would be possible for a simple automated calibration of EVERY single selectableย  step from 0-40V. Note that I do not say every “10mV step” as these steps will be correct but probably not exactly 10mV each. They will be as correct as the new ADC will be! But as we only have a 12 bit DAC we have 4 extra “throw away” bits (that is 16 steps!) for accuracy! ๐Ÿ™‚

Even if the above is possible it might be setting the goal too high with the components chosen! In case we want this kind of 10mV precision we should probably have got a more expensive and more precise DAC in the first place – and not have had to do so much “software-magic”! Setting the goal for 0.1V or 100mV steps is a better goal considering the components, I think. There is nothing that prohibits the drop in of both better DACs and an external and better ADCs for a higher spec DPSU – the solution will still be the same! If they are I2C controlled devices the swap is very simple! It depends mostly on your requirements and wishes! ๐Ÿ™‚

See you soon!
/Sfenn