Show by Label

Thursday, December 19, 2024

LoRa Mail Letterbox Notification



This is the finished prototype. I will replace this picture with the finished PCB.


For quite some time, my wife asked me to "produce something useful" instead of the projects I have been busy spending time and money on.

We live in an apartment building on the 3rd floor (4 for Americans) and our mailbox is next to the entrance together with the other 39 inhabitants. It's a full metal construction with an aluminum lid.

The distance is far exceeding a WiFi connection, so a LoRa connection should solve the distance issue.

Proof of Concept

I experimented with two of the E32 433MHz boards and quickly got that up and running using Arduino Nano boards, with two simple sketches. One acting as the sender and one acting as the receiver with an acknowledgement going back to the sender to turn on an LED. Powering the sender one with a Powerbrick, I ventured a few times up and down the stairs to the mailbox to see if I could get a reliable connection from within the metal enclosure, which I did.

Extending the Proof of Concept

In order to make this more reliable and practical, I wanted to put the sender contraption into deep sleep to conserve power, and waking it up somehow when mail got delivered.

I first tried to use an LDR that would function as a wake-up for the system. Unfortunately, my first attempts failed. I think this is because the mailbox itself it dark, and opening the lid and shoving mail through the opening did not provide enough of a light differential to use it as the trigger. This is unreliable because the postman or woman stands in front of the mailbox, blocking light and that in the winter period is another obstacle.

Besides, the circuit to recognize the opening of the lid by means of an LDR would have to be powered 24x7 and that would drain the battery cell.

It would have been nice nonetheless, because all the parts could be in one enclosure.

Alas, I had to find a different method, preferably one that did not use any power but would be reliable. So, the next thing I wanted to try was to use a magnetic reed switch, typically used for signaling doors opening. I ordered one, but it turned out to be too bulky for this application. The magnet piece would have to be connected to the lid by either glue or double sided tape because I can't drill holes anywhere. This bulky magnet part would be exposed to the outside when the lid opens, and it's too easy to get nocked off with bulky packages.

The next step was to try a smaller motion activated switch by a mercury droplet, which I found after some searching on Aliexpress. I knew about the existence, but looked for a really tiny one.



The glass bulb is 11mm long and has a diameter of only 4mm.

Using a different lid opening sensor

I have been notified by a viewer of this Blog that the mercury sensor I'm using can break the glass and the very toxic Mercury can leak out. He mentioned an alternative solution by using a vibration sensor. 

Vibration sensor

I didn't know about them so I ordered a few and will try them out. I ordered the normal sensitivity one and also the sensitive version.

This is how they look on the inside: (I borrowed the picture below from Adafruit: https://www.adafruit.com/product/2384


I got the vibration sensor with the normal sensitivity and it is not working in this application. It needs quite a violent jolt to make contact, making it unreliable for the detection of the lid opening and closing. Maybe the more sensitive one works better?

I got the sensitive version, and tried that out. It indeed works a lot better, but have a look:


It produces a large number of these very fast pulses when you tilt it or tap it. For this project, that would still work, but it's not any more reliable or different enough to change it for the tilt sensor. It's more appropriate for a door or window sensor, registering a break-in attempt as an example.


Optical light sensor

I also got delivery of another optical sensor, the OPT101. Using a sensor that does not have to be fixed to the lid is a major improvement, because everything can then be built in one box, and there are no wires going to the sensor mounted on the lid.

I built a little prototype with it, and initially, it seemed to work very well, just waving my hand above it would activate it. However, when I put it in the carton shoebox that would mimic the letterbox, I did not get enough light on the sensor to make it work. It's not sensitive enough for this application, even though I increased the gain.



Optical PIR sensor

I also ordered a small IR motion detector, I saw it was used in a mailbox alarm project where the designer sold his result. It uses one of these small sensors.

When I tried it, it worked very well, even within the concocted shoebox replacement, but as I already feared, it only reacts on Infra-Red generated from warm bodies. In other words, it will only work when the postman puts a bare hand for the opening, but it does not react on any light. This will be a very unreliable detector for my particular mailbox. It may be better suited for the US mailboxes that have a much larger opening. I had high hopes for this sensor, but alas...


Tilt switch

The tilt switch I also found while searching for alternatives is so far the best replacement for the mercury switch I'm currently using. As you can see in the picture that I borrowed from Adafuit (https://learn.adafruit.com/tilt-sensor/overview), it uses two balls that roll around and make contact when the device is up-right. Same as the mercury switch.


The ones I ordered arrived and seem to work fine. I will replace the Mercury switch that is currently taped to the letterbox lid with this one soon.


Changing the processor

I had a few issues with putting the Nano to sleep, and waking it up. Also these boards are a tad too large to my liking as well, so I switched to the ESP8266 based WEMOS D1 boards. I use a number of them in my home, measuring many environmental "things" and I always have a number in spare to play with. They have enough available pins to interface to the LoRa board and they can be put into a deep sleep mode with one instruction, while they wake-up when the RST pin is momentarily pulled low.

I'm using a clone of the WEMOS D1 Mini, the GY-D1MINI. The major difference is that it uses a SCP2104 USB to UART bridge, instead of the CH340C, which calls for another USB driver on your PC.

Unfortunately, although there are many variations and models, I have not been able to find a schematic for this particular board.





The proof of concept prototype

To try out the concept, I put together the following circuit diagram, build that on protoboard, mounted it into a small plastic enclosure and mounted the contraption with double sided tape inside the letterbox.


To keep an eye on the Lipo cell voltage, I use the on-board ADC to measure the cell voltage. I used a 120K resistor that works together with the on-board attenuator to keep the voltage within the ADC range. 

To get a more reliable communication, the sender sends a text message that it has detected mail. This message gets verified by the receiver after it than sends an acknowledgement. The sender waits for the acknowledgement, but if not received after a short period, it sends the "I got mail" message again, up to 5 times. After receiving the acknowledgement from the receiver, it would also measure and send the cell voltage to the receiver. On the receiver side, I use an LED to signal a low voltage, set at 3.4V. Reading the cell voltage just after activating the LoRa board, which uses about 100mA while transmitting, ensures that the cell is at the lowest level when I measure it, although the voltage will creep back up a bit when the circuit is put to sleep again.

This worked really well until I did not get any alarms anymore. It turned out that the so called 500mAh Lipo cell drained before mail arrived so I did not get the low battery warning. Bummer! At that time, I set the cell voltage warning at 3.4V, but later I figured out that this was way too low. Due to the voltage drop over the 3V3 regulator, an ME6211 with 260mV dropout, it very well could have resulted in a voltage for the ESP8266 and the LoRa board that was below 3V, at which level they stop working reliably or at all.

First of all, the 500mAh cell capacity was inadequate to begin with, but it is what I had. I had measured the two cells I have several years ago and they showed to have a capacity of only 274mAh and 260mAh.

Because I used the on-board 3V3 regulator  on the WEMOS D1 mini, by the time the cell produced less than 4V, the 3V3 voltage regulator started to drop the voltage, so I did not get much of a useful capacity to start with. I knew that, so I ordered two new LiPo cells with 2000mAh capacity. When they arrived I put one into the letterbox.

Here is a discharging curve for the 2000mAh LiPo cells I'm now using:


This graph was generated by my DC Dynamic Load in the Battery Test mode. That recent design is described elsewhere on my Blog. It shows a couple of things. First of all the discharge curve was made with a constant 200mA (1/10th) of the rated 2000mAh for the cell. The measurement shows that it's not quite up to the specification at 1889mAh, but close enough. It took 9 1/2 hrs to discharge it from fully charged to the 3.0V cutoff setting. The sender circuit should draw about 20uA when in deep sleep, and about 100-150mA when the LoRa module is transmitting for a few seconds. 

When you look at the discharge curve, you see some hash that goes away after 210 minutes. This is only the second time I'm discharging the cell, and from other tests, I'm assuming that the hash can be attributed to the chemical reaction within the cell. This is why I use a 220uF capacitor to smoothen that.

More about the cell voltage later on.

I installed the prototype board into a small enclosure and taped it to the inside of the letterbox with double sided foam tape and used two thin wires that went to the mercury switch that I taped to the lid. I also mounted a small connector to be used for the LiPo cell such that I can replace it without opening the enclosure. The cell is also taped to the side of the letterbox.

This prototype is working really well for a few weeks now. They major issue is that normally, I do not get a lot of mail. There may be days without any. The cell voltage only gets send to the receiver when there is mail, so there is too much of an opportunity that the cell gets depleted before I get mail and I'm unaware of this. I need to find a way to avoid that.


The receiver

The receiver basically has the same ESP8266 and LoRa module, but the circuit is enhanced to give audible and visual information. The receiver is located in the apartment where we can hear it beep, see the LED's and reset the alarm.



This circuit is powered by a 5V USB wall wart connected to the WEMOS D1 mini micro USB input connector. There is a beeper/buzzer that will activate when mail is received and it will beep 5 times. An LED is turned on so you also have a visual indication that mail is received.

You can reset the alarm by a push button. 

Another LED will be turned on when the receiver is notified that the LiPo cell in the receiver module is below the cut-off voltage, I currently have that set at 4V or below.

I'm actually actually using the ADC input to measure the activity of the reset switch, because I can out of digital inputs. The D4 pin is connected to the on-board LED, so I don't want to use that.

At this moment, I'm programming the LoRa module with the standard configuration parameters at boot-up, because I have no other LoRa transmitters nearby. 

The parameters that I currently use for both devices are: 

    Adrs=0, Ser=8N1, 9600bd, Air=2.4Kbps, chan=23 and pwr=20dbm.



Enhancing the sender prototype

I needed a low voltage alarm for the LiPo cell that would wake-up the system and send a distress signal apart from the mail alarms. That took a bit more time to design, because the RST wake-up signal must be a momentary low, not a permanent one. So although I started out with a very simple low voltage indicator, testing showed that I needed a bit more logic to create a more reliable and correct wake-up signal to kiss it out of the deep sleep.

Below is the updated but still evolving schematic.




From left to right...
The LiPo voltage warning is generated by the comparator through the sense circuit R1, R2+R3 for a trigger at 3.2V. The output is going through a capacitor to create a negative going pulse that triggers the CMOS 555 timer. R6 and C4 create a pulse output of about 50mS, that needs to be inverted by an N-FET to drive the RST input momentarily low to wake-up the ESP. (I first used a transistor pair but was not happy about it and it also used quite a bit of power) I also have a voltage supervisor on order and may add that to the layout as an option. The comparator is one that I had left from another project, but you can use anything that fits the SOT 23-5 foot print.

So whenever the LiPo cell voltage is getting below 3.2V, a distress signal will be transmitted to the receiver, which in turn will switch on an LED so I can see that the LiPo needs to be swapped-out.

A cell voltage of 3V2 has enough head room for the voltage regulator to provide 3V1 to the circuits.

This section of the circuit is not yet implemented in the circuit that is now in the letterbox. It is still in prototype form on my desk (see below) because it's too finicky to implement that on protoboard. That will have to wait when I have fully tested the LiPo supply circuit and a PCB designed. More about that later.



The same Trigger input from the 555 is also connected to the activation switch that is fixed to the lid of the mailbox, in a position by which the switch gets closed when the lid is opened. This also creates a momentary negative going level on the RST input, waking it up for an "I got mail" message. This can be important when a larger package is stuffed in the mailbox that keeps the lid open. This 555 circuit will still produce a wakeup call. Without it, the ESP would be held in a permanent reset, and I would not get the "I have mail" message.

The LoRa board is connected to the ESP such that the ESP can initialize the LoRa board, and send or receive messages by using a software serial interface. That means that I can still use the Micro-USB port to upload new firmware and monitor what it is doing by using the hardware serial port.

I added a reverse polarity protection and a fuse for the Lipo connection to prevent a possible to short of the LiPo cell or destroying the components on the board when the wires to the LiPo connector are swapped. I'm using a key'd connector, but not all cells have the same pin-out.

I still measure and send the LiPo voltage every time there is a wake-up call through the on-board ADC. With the new circuit, that will happen when there is indeed mail, or when the cell voltage is too low. If I get the alarm and both LED's are on, I need to swap out the LiPo cell.

Right now, for the prototype that is in the mailbox, I first used the LiPo cell directly to feed the 5V input of the WEMOS. That worked well for quite some time, but to get more mileage out of the cell, I temporarily installed a little boost convertor module that uses the LiPo cell as the input, and I adjusted the output for a 5V1 voltage, and that goes to the 5V input of the WEMOS so there is a reliable 3V3 to power everything. I did find that the Lipo discharged after about 2 weeks already, partially due to the cold weather, but I need to investigate that further.

I added the components for the receiver to this schematic, so I can create one PCB that can be used for both, to save cost.

Using a LiPo cell to supply power

It took me a while to figure out how to do it, and it's not so obvious. Let me explain.

Supplying the +5V input?

The ME6211C33M5G on-board voltage regulator on the WEMOS D1 (and the clones) that creates the 3V3 rail, feeds the ESP8266 module itself and in this design, also the LoRa module. This is a voltage regulator that, according to the datasheet, should have a 120mV drop-out voltage at 100mA and 260mV at 200mA. I measured that the 3V3 output starts to drop at an input voltage of 3V4, which confirms that. When the LoRa is transmitting however, the current will go up, and the drop out voltage will raise with it.

This limit of at best 3V4 by directly feeding the LiPo cell into the 5V input is reducing the usable capacity of the cell to about half, see the discharge graph above. I want to try to wring some more life out of it, thereby extending the time I need to swap it out.
Technically it works, but for this application it is a no for me.

Supplying the 3V3 input?

Can I use the LiPo cell to directly feed the 3V3 voltage inputs to the ESP and the LoRa module?
The ESP-12F module which is on the ESP8266 WEMOS D1 mini, has a voltage rating of 3.0-3.6V. The E32-433T20D has a voltage rating of 3.0-5.5V. It seems the LiPo cell voltage can drop all the way to 3.1V to have a bit of a safety margin. 

Fully charged, the cell has a voltage of around 4V, which is too high for the ESP module. 
So this is also an obvious and definite no-no.

Using the LiPo with a different supply option

Using an "external" very low-drop voltage regulator will be the answer, and I already found one that is variable, because I don't need 3V3, but rather 3V1, which will be extending the cell capacity. What I found is the TPS 73101. LCSC carries the part so I ordered a few for a reasonable shipping & handling price.

Seems simple enough, but wait...
The problem to watch out for is going to be back-feeding from the 3V3 regulator on the WEMOS board when I connect the USB cable for debugging or uploading because there is no series diode or diode across the 3V3 regulator as protection on the WEMOS. The USB 5V has a series diode to prevent back feeding to the connected PC, see below. I need to make sure that the regulator I'm going to use to power everything never exceeds the 3V3 of the WEMOS regulator. That should not be a major issue because my plan is to use a 3V1 supply rail to get more mileage out of the LiPo cell.

Eliminating the USB 5V back feeding into to the circuit

This is only an issue when you connect the circuit to the PC through a USB cable for testing or uploading new firmware. It does no harm, but will mess with the voltages on the receiver board, in essence lifting them up to 3V3. If you want to prevent that from happening, there is a fix. Here is the relevant portion of the schematic that fits most WEMOS variants. There could also be a 100K resistor from the EN pin to GND on some boards.


The 5V comes in through the USB connector and is fed through a Schottky diode (D2) to prevent back-powering the PC when you apply 5V directly to the WEMOS board. (BTW, I have never seen the 500mA fuse used on all the different boards I have).

In any case, the +5V goes to the 3V3 voltage regulator U1 and also to the USB to UART chips.

The three WEMOS variants I have use the CP2104 or the CH340C USB to UART chip. Even though the 5V is going to these chips, they function without it. I tried.

So the most simple solution for the USB power back-feeding into our circuit is to remove the series diode on the WEMOS board, which will prevent the USB supply to feed the 3V3 regulator. This Schottky diode is D2 on the schematic and can be easily removed. I removed it and applied 3V3 to 3V0 to the 3V3 pin on the board to power it and everything, including the USB serial monitor still works on both of these boards.

The location of the diode is pointed to by the arrow for one of my clones.



On the other clone with the CP2104, the diode was located to the right of the 5V pin and is already removed.



With the diode removed, there is no +5V going to the 3V3 regulator on the WEMOS board anymore, so a further refinement could be to also pull the +5V pin on the connector for the WEMOS board to GND, because that will also pull the EN(able) input from the 3V3 regulator down, and disable it. I tried it and it worked, although I did not test the back-feeding by applying a voltage higher than 3V3 and see if the regulator survived.

If you want to go really go fool-proof, you could also remove the ME6211 from the WEMOS board.

Using an external voltage regulator

While searching for a variable voltage regulator with a very low drop-out voltage, I found the TPS73101. The dropout voltage for this regulator is typical 30mV to a max of 100mV at 150mA, and only has 1uA current consumption which is all great. LCSC carries the part so I ordered a few of them which will arrive soon.

The output voltage of the regulator can be set by two resistors. I was planning to use 50K (2 x 100K parallel) and two resistors in series (27K+4K7) for a 31K7 value to set the output voltage to 3.10V, which is sufficient to power the critical components. The parallel resistance is 19K4 and very close to the recommended 19K. Due to the very low drop-out voltage, I'm planning for a 3V2 alarm, so I know it's time to swap out the LiPo cell for a fully charged one.

This also means that I can draw on the LiPo cell for just about the maximum 2000mAh capacity.

The voltage regulators arrived and to try it out in the prototype, I soldered one of them on a DIP carrier board. I then found out that the adjustment to get a precise 3V10 output with fixed resistors is too finicky. You would have to use three in series to get a precise output value so I'm now using a trimmer instead. That, plus some other minor value changes resulted in an updated version of the schematic above.

I took out the sender contraption from the mailbox so I can test a few more things, especially have a more detailed look at the current consumption. When I'm satisfied, I can start to create a PCB. The current plan is to create one PCB that will accommodate both the sender and the receiver to cut cost.

Current consumption analysis

Analysis may be a big word, but I tried 4 different ESP8266 board after I noticed that the current consumption in deep-sleep was much higher than I expected. I tried all four versions that I have with my prototype. It currently, does not have the LoRa module installed. That will be next.

Here is what I found, while powering the board with 3V2 applied to the 3V3 "output".

GY-D1MINI
This board uses the SIL2104 UART and consumed around 26mA when running in setup and 6.4mA in deep sleep. This is the one that I used on the prototype on my desk and the amount of current in deep sleep got me confused. It has the ESP-12F metal can module mounted on the bottom. It also has an LED installed that is connected to the UART, that cannot be turned off in software, at least I could not find how. There is a D2 on this board that can be removed.

With 6.4mA, this board has the highest deep-sleep current consumption.




D1 Mini clone
This board uses the KH340G UART. It is what I had in the letterbox. This board has the ESP8266MOD metal can module mounted on the bottom. It consumed 20mA in setup and 195uA in deep sleep. There is an unmarked D2 on this board that can be removed.

Apart from the WEMOS D1 Mini V4 below, with 195uA, it has the lowest current consumption in deep-sleep, about double the V4 board below, but that has another significant problem.




Unmarked D1 mini clone
It looks like this board uses the KH340G UART, but the markings are removed. It consumed 19mA during setup and 250uA in deep sleep. It has the ESP8266MOD metal can module mounted on the bottom. There is a D2 on this board that can be removed. Unfortunately, I can't find a schematic for this board. I wonder where the two large diodes just above the USB micro adapter are for.




WEMOS D1 mini V4
This board uses the KH340C UART. This board has a connector for an i2c interface and a USB-C adapter. It does not have the ESP8266 metal can on the bottom but uses the ESP8266EX chip. The board also has a 32Mb SPI flash chip and an ME6211C33 voltage regulator. According to the datasheet, it has a 100mV drop-out at 100mA. 

The board consumed 19mA during setup and just below 100uA in deep sleep. This board has no "D2" installed, so the USB 5V always feeds the on-board 3V3 regulator when connected to a PC. 

With 100uA, it has the lowest current consumption in deep-sleep, about half of the best of the rest.

The major draw-back for this board is that it has a different pin-out. It is actually flipped upside down compared to the all the other boards I have, making it a tricky decision because it limits the available boards you can use. Compare the bottom markings with the boards above. It could be used in place of the others, but only when mounted upside down. These boards came without the pins connected so I could simply reverse the connector pins.





I also have an Adafruit HUZZAH but that does not have a USB connector and AI-THINKER modules which are larger, so are not candidates.


Removing D2, do or don't?
While trying all these boards, I found that there is no urgent need to remove the D2 diode, as long as the voltage rail of the letterbox sender is below 3V3, which it should. Just be careful when you are fiddling with this supply voltage and keep it below 3V3. What does happen when you leave D2 in the circuit and have the USB cable connected to your PC is that the WEMOS board will supply current from the 3V3 regulator to the receiver, and lift the voltage to 3V3. In that situation, you can't test the battery cut-out circuit or accurately measure the current consumption.

The overall current consumption of the circuit without the ESP or LoRa is 550uA at a cell voltage above 3.2V, and then goes up to 835uA when triggered. With the ESP at deep-sleep, the total consumption, still without the LoRa is below 1mA.

Just measuring the LoRa board by itself shows that when there is no activity, with the ESP in deep sleep, the LoRa board only draws 1.8 uA. When sending, it consumes at least 110mA in bursts for a very short time.  

The screen shot below was taken through a 10R resistor in series with the VCC of the LoRa board, which is fed directly from the LIPO cell, to not produce voltage sags in the 3V1 rail, which could trigger a premature low batt alarm.



Luckily, I don't need to turn the LoRa board power off in the sleep mode.

Protection fuse

I initially added a 100mA PTC fuse in series with the LiPo cell, with an attempt to avoid serious issues that can be caused by connecting a LiPo cell. What you have to take into account however is the voltage drop over the fuse, the tripping voltage and the time before it trips. I'm not an expert at all, but it looks like a 100mA PTC will trip at 200mA and will take about 2.2 seconds before it trips. (this is the part I have and looked at: a radial RXEF020 from Littlefuse) It has a resistance of 1.8Ohm at room temperature.

In deep-sleep mode, the drop is only 1.3mV, but increases to almost 150mV during the LoRa transmissions. 

That's quite a lot for this application, and I don't like the long tripping time, so I'm changing the fuse type to a fast THT Pico fuse of 250mA. Because I'll rather be safe than sorry.

Reverse Polarity Protection

The other safety measure I took was to add protection for a reverse polarity connection with the LiPo cell. I'm using a connector with a key, but not all LiPo cells come with the proper orientation of the wires. That can easily be fixed by swapping the leads in the connector, but you really don't want to have it wrong, hence the addition of a P-FET. The AO3401 has an RDSON of  60mOhm at 4.5V and 85mOhm at 2.5V, so it will be somewhere in the middle. The voltage drop of that device is not a concern.


So with everything connected and "asleep", the whole contraption consumes about 350uA, so it really depends on the amount of mail I get that will determine the life of the cell.

Rail buffering

With everything connected and working, I looked at the power rails in more detail, because I noticed a sagging when transmitting.
It turned out that I had to use a 1000uF capacitor on the 3V1 rail, and another one on the LiPo rail that supplies the LoRa board, to reduce it considerably.

This is the 3V1 rail without any electrolytes:


One 1000uF added to the 3V1 rail:


Another 1000uF added to the LiPo rail:


This was taken with my Lab Supply with 2ft leads powering the prototype with 3V3.
When I switched to the LiPo that had 4V with very short leads, this was the result:


Obviously, this is with the prototype on proto-board, which is notorious for poor connections, but still...
Something to keep an eye out for. As a result of this observation, I've added a capacitor to the base of the voltage trigger transistor, with an attempt to not let it trigger on a sagging of the rail during transmission.

There may be a potential issue with the power-up of the ESP due to this added capacitance. The chip will go through a voltage ramp-up that may cause instability. I will look at that later in more detail, but right now it does not seem to be an issue.


Next step

With the design pretty much done and functioning pretty well in both hardware and software, I can now start to design a PCB, and I started with a board outline based on the Hammond 1593L enclosure I want to use.

However, while thinking some more about the consequence of adding the large electrolytes (or a super cap) on the power rails, and the potential start-up issues for the ESP (it spends some time in the unstable zone due to the slower voltage ramping up), I considered using a voltage supervisor. While looking into possible candidate solutions, it dawned on me that I could use one as a voltage alarm, and eliminate the two transistor voltage sense circuit. Alas, I did not find any with a trigger voltage of 3.2V, and only a single one with an adjustable input that is more or less commonly available, the NCV308MTADJT1G or the equivalent NCP model. I ordered two NCP versions and will try them soon. This chip draws only 1.8uA, so is a significant enough improvement on the power budget as well. Because I was not happy with the two transistor trigger circuit, I redesigned it to use a comparator. I will try to add the layout for the voltage supervisor for the trigger so it can be used as an option. When I have the PCB, I can better determine if I need the extra electrolytes and also if the ESP will experience power-up issues.

Initially, I was planning to set the 3V2 trigger level with resistors, but after I changed the resistors to much higher values, I did some calculations for the proper values and decided to make it easier, albeit with the expense of another trimmer. That resulted in V2.3a.



The above schematic is what I used to the create a PCB. It has the optional MCP308 voltage supervisor chip that can be used instead of the TS881. Note that I'm now using the WEMOS D1 mini V4 with the flipped pinout because it has the lowest current consumption. Other WEMOS D1 boards can still be used when they are mounted upside down.

Below is a 3D view of the layout in KiCad. The PCB Gerber data is uploaded at PCBWay and I'm awaiting their sponsoring confirmation. 

The board can be used for both the sender and the receiver. Several parts can be omitted or added to suit either version.




Conclusion

We normally don't get a lot of mail, sometimes days without anything, but in the current busy Christmas period we get mail all the time, and the prototype is functioning very well. This is a keeper!



I will add more soon... Stay tuned...

As usual, I will create a GitHub project that will have all the details when I'm satisfied that the hardware works.

Sunday, December 15, 2024

Building a Sensitive Continuity Tester

 


A volunteer colleague in our local Energie cooperation asked me for some help for a project he wanted to do. He found an interesting tool he wanted to build, more for the fun of it than that he had an urgent need for the tool, but that's the way it goes with many of my own projects as well.

His own, very antique, logic level probe/continuity tester died on him, so his original idea was to use the housing of that probe. When I looked at it, I found that it had enough room, but would have been an ugly overkill for the design he found.

That design and description can be found on a website here. The picture below from the original design is from that site.


The original designer, Pieter-Tjerk de Boer, even included the KiCad details, unfortunately, they were from a much older KiCad version I am using, and by the time I could work with it, and made some changes, I decided to start with a new KiCad schematic and redid most of the layout. Not that the original one was poor, but KiCad gave me too many problems with the verifications and library conversions between the two KiCad versions.

The design of the tester is really neat, well done Pieter-Tjerk!  This tester will show (audibly) when there is a good trace connection and is also sensitive enough to pick-up very small Ohm value changes, an indication of a poor trace.

Here is my version of the design, with a few small changes based on the original one.


I changed the way the tester is charged, by eliminating the series LED in the USB 5V path, which is not needed in my opinion. You know when you are charging it. As an indicator to show a fully charged Super Cap it did not work really well for me. The LED in the original design will only turn off when the Super Cap is really fully loaded and there is no voltage differential across the LED anymore. I tried it, and it takes way too long to my liking. The way I understand this, is that the topping-up of the Super Cap goes against the current draw from the circuit. Eventually the LED will diminish and go off, but I had another idea on how to use the probe, without a permanent USB connection. In any case, with the series LED gone, I could also reduce the series resistor to a much smaller value, making the charge time less then a minute for a full charge of very close to 5V, even with more than double the capacity for the Super Cap, which is now 0.22F

With the charging cable gone, what is now more important for this circuit is to have a warning when the supply voltage, from the Super Cap, is getting too low. According to the datasheets for the Opamp, comparator and Schmitt-trigger that was 3.3V, so I added a two transistor circuit that would turn on an LED when the voltage is too low for a proper operation. You are relying solidly on the beeper for a good connection, so the circuit must work reliably. The two resistor values I used for the tripping voltage setting are pretty low for an "ultra-low power" design, but that can be changed by increasing the values for R11 and R12 and make them 150K and 520K, or even higher, as long as there is enough of a Base current for Q1 to function. You can also increase the value of R10 to reduce the current some more.

I do not envision that you will be using the probe for an extended time while searching for a bad connection. In any case, just topping it up within a minute will get you going again.

Another change in the layout was required because I did not have a 33MOhm resistor in my 0805 or 0603 collection. I reverted to using a 13M and a 20M value combination with an 0805 package instead of the 0603 I use for most of the other ones. You can use any combination as long as it is close to 33M. Also R8 is an 0805 package due to the higher charging current when the Super Cap is empty.

Finally, I changed the USB connector for the charging. There is no need for the USB lead to be connected, you can now stick the probe into a USB slot for a minute to fully charge the Super Cap. After that it's much easier to use when you are probing around and don't have the USB cable connected.

By the way, with this design, the Super Cap is always charged and only the connected circuits will drain the charge. The discharging process will go faster as soon as the voltage is below the trigger point when the circuit with the LED will drain it faster. Keep this in mind when you store the probe while it still has a charge. I contemplated using a micro sliding switch to remove the power from the circuit, but then the Super Cap would keep it's charge "forever". I could also have used a draining resistor and a switch to drain the charge of Super Cap itself but didn't like that idea either. It is what it is...

Here is a picture of the 3D viewer in KiCad to have a better look.



As with the original design, you can use a USB connector with THT pins, as well as the SMD version.


I found a test pin that was appropriate by searching for PCB test pins. The one I ended up buying came with a qty of 20 and was called P100-B1. I do not think that this is a standard, so be careful what you order. The link for this part is in the BOM.


When we build our version of the tester, we could verify that these probe pins, that have a spring in them, need to be soldered together to reduce the resistance. With a solid connection, there is a firm buzzing sound. However, with a not so perfect connection, the buzzer emits a distorted sound as a warning.

I also reduced the length of the PCB test pin a bit, but just cutting of about 12.5mm from the back-end.

One of the other boards was used as the second probe. I created a pair of holes in the PCB to act as a strain relief for the connecting wire. I used a small piece of blank wire (from a THT resistor), that I soldered together on the backside, without melting the plastic insulation, of course (;-))





The design information, Gerber files and BOM are on my GitHub site here: 


I may add more later... Stay tuned...

Friday, September 20, 2024

Building a DIY Dynamic DC Load

 VB Dynamic DC Load

Construction and Build Instructions





Here is a list of items and instructions that will help you to build a Dynamic DC load instrument. 

The design process for the instrument is documented on this Blog here:
https://www.paulvdiyblogs.net/2024/04/build-diy-dc-dynamic-load-instrument.html

The two BOM's, Gerbers, Firmware and other required files can be downloaded from the GitHub. Note that I recently added files that Bud created and will allow you to 3D print your own enclosure and that includes the backpanel and feet.|
https://github.com/paulvee/Dynamic-DC-Load

I also added the instrument details as a Shared Project on the PCBWay site so you can order the boards directly from there:
https://www.pcbway.com/project/shareproject/DIY_Dynamic_DC_Load_8643ddca.html
https://www.pcbway.com/project/shareproject/DIY_Dynamic_DC_Load_Face_PLate_12899b9c.html
https://www.pcbway.com/project/shareproject/DiY_Dynamic_DC_Load_Back_PLate_cda4ffcf.html

Bud, the designer of the instruments core, started his own Hackaday project to document the design here: https://hackaday.io/project/195380-dynamic-electronic-load
I took all his stuff from there and copied it in the design process Blog, so it's all in one place.



The Specifications:

  • Input voltage: 1..100VDC.
  • Reverse polarity protection to -100V and a 10A fuse.
  • DUT is disconnected by a relays for invalid inputs like reverse polarity.
  • Maximum current of 10A @ 40V
  • Maximum power 180W @25 degrees ambient temperature (heatsink temp 85C)
  • Off state DUT current 1.9uA at 2V, 57.7uA at 60V.
  • Volt Accuracy: 0.4%
  • Current Accuracy: 0.4%
  • Power input: 12VDC Wall-wart 0.5A with reverse polarity protection to -24V and PTC fuse
  • CC, BT & CV modes with real-time operation in hardware.
  • CP and CR modes have active regulation supported in software (resolution +/-156uA).
  • Pulse/transient mode supported by an external Function Generator. 5V=10A
  • Current monitoring with a DSO. 1V=10A
  • GUI: 128x128 OLED 1.5' color display and a rotary encoder with dual button functions.
  • Two temperature controlled fans.
  • Protection for over voltage, over current, over power and over temperature limits
  • Overall dimensions: 21cm long, 18cm wide and a height of 118cm.
  • Weight: approx. 1110 grams

  • Parts & Components

    I will show a few parts and components in this description, but all the main PCB parts are listed in a BOM with their order numbers, and the additional off-board parts are listed in a separate BOM, both are available on the Github site.


    The Printed Circuit Boards

    The Printed Circuit Boards (PCB's) are available through PCBWay, who are sponsoring my activities by providing the PCB's free of charge. I have been using their service for several years now and the boards are of excellent quality, every time.



    To create a professionally looking instrument, and to aid with the construction, I have also created a front panel and a back panel PCB. Both also available through PCBWay.





    The back of the front panel has 4 solder pads that can be used to glue to the OLED display into position, so the visible portion will be positioned in the middle of the square cut-out.

    NOTE Bud designed an enclosure that can be 3-printed, and that includes a backpanel. See the Github for the .stl files.

     

    Stuffing the PCB

    Adding components to the PCB should be a straightforward job, except maybe for soldering the minute packages for the ADC, the reference, the two analogue switches and the MCP6V51 Opamps.

    I highly recommend you use a socket for the ESP32. To that extend, make sure you order the VROOM 4MB DEVKIT V1 module without the headers installed. The one below has the blocking diode installed, more details below. Note the pin layout and make sure you get one that has the same layout!

     I use the following headers and sockets for the ESP32, I buy them by the strip.






     


    To add the components to the PCB, my recommendation is to start with all the passive components like resistors, capacitors and then the active transistors, MOSFET’s (not the main NFET’s M1, M2), diodes and the voltage regulators U9 and U12. Do not install the relay and the snubber circuit yet. What I then would do is to connect a Lab Power Supply with a setting of 12V and 50mA to the DC input of the board. If it powers-up without getting into current limitation, you will probably not have any shorted rails to ground, and can proceed to test the +12, +9 and +5 supply voltages. If they check-out, you can add the ICL7660 and test the -5V rail. After that, you can add the REF5040 and check the presence of  4.096V. If that also checks-out, you can add the trimmers, connector strips, DAC, ADC, MOSFET switches (U14, U15), all the Opamps and finally, the main relay and snubber circuit. Basically, everything except placing the ESP32 module in its socket, and soldering the main NFET’s (M1, M2) and the LM35.

     

    ESP32 variations

    The recommended ESP32 board is the VROOM 4MB DEVKIT V1. However, I have found that there are slight variations or differences for two components on various sources for this board. One is the capacitor that should ensure a reset after a download of new firmware. On one of my boards, this capacitor was there, but not well soldered to the chassis part of the USB-mini. On another one, there was no diode to block the incoming 5V through the USB, and the VIN supplied to pin 1 of the board. Having no diode but a 0R resistor means that the VIN supply will back-feed 5V into the USB port of your PC. Not recommended!

    To avoid having to mess with the ESP board and 0402 size parts, we have made provisions on the DL PCB to help fix these two issues.

    Verify that the ESP32 module has a 1uF 0402 capacitor most likely connected to the solder pad of the EN button. It may be soldered at a 45-degree angle, see the left blue arrow. If the capacitor is not installed, you need to install C44 on the PCB. (in the schematic C44 has a red cross through the part, to avoid placing this part when not needed)

    Also make sure that there is a diode installed and not a 0 Ohm 0402 resistor (marked 000) as you see here on the board. See the middle blue arrow below for the location. The picture of the ESP32 further up in the Blog does have a diode, which can be easily identified.

    If there is a 0 Ohm resistor on the board, you need to remove or not install R53 and install D10 on the main PCB. See the schematic below. (in the schematic D10 has a red cross through the part, to avoid placing this part when not needed)




     

    The Back Panel

    At this moment in the build process, it will help to mount the fan on the back panel so you can use it to double check the space between that fan and the second heatsink/fan combination that will be mounted on the bottom shell later.

    The back panel fan will be mounted using the flexible silicon mounts that come with the fan.

    To help the installation by pulling on these flexible thingies, it is helpful to first counter sink the 4 holes in the PCB on either side so the silicon will more easily slide into position when you pull them in.




    Note the position of the fan on the back panel, and where the wires need to come out (top left).

    The four wires from the fan come standard with a pretty stiff heat-shrink tube. That's too stiff to my liking, so I cut it off, exposing the four wires.

     

    Modifying the enclosure

    The bottom shell of TEKO AUS33.5 enclosure needs to be modified so we can mount a fan on the bottom to suck fresh air directly into the heatsink fins inside the enclosure. The fan mounted on the back panel will suck the hot air away from the heatsink to the outside of the enclosure.

    A number of holes need to be drilled in the bottom shell to get enough airflow to the heatsink. I used Excel to create a raster for the 6mm holes. The picture shows an earlier position of the fan, I later moved it further down and added another number of extra holes.


    To feed plenty of fresh air from the bottom of the enclosure to the fan, we need to mount 4 feet that are about 1cm in height to lift the instrument from the shelf or desk to create the space.




    The bottom fan needs to be mounted in the middle of the enclosure, and the mounting holes 25mm away from the back edge of the bottom shell, to make room for the fan that is mounted on the back panel. Before you drill the holes, use the back panel with the fan mounted on it to double check the space you need. The minimum space between the two fans would be 2mm.

     

    The bottom fan and heatsink

    The bottom fan will be mounted on the shell by four 30mm long M3 screws. Because of the plastic, and the two hole positions in the ventilation area, I recommend you put M3 or M4 rings on the bottom and on the inside of the plastic shell. Use a normal (flat) M3 nut to tighten the four screws to the enclosure while making sure that the fan will easily fit. After the fan is positioned on the four mounting screws, use an isolated M4 ring (teflon?) on top of the fan before you mount the brackets holding the heatsink.

    The heatsink will be mounted about 6mm above the bottom fan by two strips of a 90 degree angle 15x15mm piece of aluminum. These strips can be found in your local hardware store and probably come in a length of 1mtr. Use a metal hacksaw to cut two pieces with a length of 90mm, which is the same as the size of the fan. Drill two holes of 3mm each 15mm from each end, that will hold the self-tapping screws mounting the bracket to the heatsink.

    I used very short 3mm self-tapping screws to mount the angle pieces to the heatsink. I also drilled the hole through the second flange of the heatsink, to make room for the tip of the screw, so it does not bend the thin flanges.

    Drill two more holes in the other flank of the L-shape brackets that are 81 mm apart, so the screws holding the fan to the bottom of the enclosure will go through these holes. Make sure that these holes are spaced such that when the L-strips are mounted on the heatsink, the holes of the fan will pass through the four 30mm long M3 screws.

    Because the heatsink can get very hot, I used four 3mm insulating rings of the type that are used to mount TO220 type devices isolated to a heat sink. For us they also serve to electrically isolate the screws from the potential of the heatsink, that can be up to 100V DC.


    You’ll need a fifth one to isolate the LM35 from the heatsink later. These rings should fit the holes of the brackets, if not, drill the holes a bit larger to 3.5-4.0mm to create some wriggle room. I then used a Teflon ring on top of the insulators and used self-locking M3 nuts to loosely secure the heatsink, so you don’t need to tighten the nuts too much and put too much pressure on the plastic frame of the fan. You want to minimize the transfer of the mechanical vibration from the fan to the enclosure. It should be a fairly loose fit. 

    The thermal paste you see in the pictures is because I took my instrument apart to make these instructions and the pictures after I finished my build.


    Mounting the Main NFET’s and the LM35

    Before you mount the heatsink on top of the fan, you need to create three M3 tapped holes in the heatsink to mount the two NFET’s and the LM35 temperature sensor. If you don’t have a good quality and sharp M3 tapping set and the right size drill (2.5mm), you can also use 3mm self-tapping screws. In that case it is even more important that you counter-sink these holes well after drilling, so the aluminum material does not come-up and push the devices up from the heatsink when you fasten the screws. If you use the M3 taps, lubricate the drill and the taps well and clean the taps and lubricate them regularly while you are tapping, to make sure that the threads are not damaged. The NFET’s and the LM35 will need to be tightened to the heatsink well, to get the maximum heat transfer, so the threats need to be well made.

    I created M3 threaded holes for the two NFET’s 23mm from the back-end of the heatsink, 33.5mm apart, and each about 23mm from the edge of the heatsink.

    The LM35 goes in the middle of the heatsink and 27mm down from the back. Countersink the holes and make sure everything is flat. Use a fine file or sandpaper with a stiff support if needed.

     









    The other four holes you see are from previous mounting positions and are no longer used.


    The front of the main PCB will be supported by two extenders towards the front of the enclosure. I used two 30mm long M3 extenders screwed together. You can use any length parts, as long as they are 60mm in total. The height can be further adjusted when the PCB is mounted. The position of the holes in the bottom enclosure for these supports is best determined when the PCB with the NFET’s and the LM35 is mounted on the heatsink.

    As you can see from the picture below, the bottom fan is positioned such that the wires come out at the left-hand side. The open side of the fan must be facing the bottom of the enclosure so it sucks the air into the enclosure. 

    Because the four wires for the fans have a shrink-wrap tube, they are too stiff to my liking, so I took the tubing off.


    The NFET’s and the LM35 will be mounted flat on the heatsink. The main PCB needs to be mounted as high as possible away from the heatsink, to minimize heat transfer. With earlier prototypes, I found that there is a surprising amount of heat transferred through the NFET leads to the PCB. Keeping the legs long helps.

    The challenge is to move the body of the NFET's as far away from the PCB as possible, to again reduce the heat transfer by way of the leads, and also the heatsink heating the bottom of the PCB. We also need to create space away from the PCB to mount the two smaller TO220 heat sinks on top of the NFET's without them touching the PCB. The place where you bend the leads of the NFET's upwards is critical to accomplish this. I bend the leads of the NFET's after about 6mm from the case with 90 degrees (not too sharp!) upwards. 

     

    You can position the three devices loosely with a screw using the M3 holes you created earlier, and then position the PCB on top of them, with the leads protruding through the holes in the PCB. At this moment, you can use the two mounting extenders to support the other end of the PCB so it is about horizontal, or use something else to keep the PCB horizontal and stable. I also used two spacers of 8mm to support the PCB near the NFET’s so you can position the PCB horizontally in order to solder the leads, and keep them the right amount away from the PCB. Make sure that the PCB is positioned high enough such that the NFET leads only just protrude 1-2mm through the PCB holes to allow for proper soldering. The LM35 leads are a bit longer, so that’s OK. I suggest that at first you only solder only the middle leads at this moment. Be careful not to drop the other end of the PCB and bend the NFET leads.

    Once you are happy and double checked the position of the PCB and the three devices, you can mark the position of the two front supports in position on the bottom shelf and then remove the three screws holding the three devices and remove the two extra 8mm standoffs.

    You can now finish the mounting of the two front supports by drilling the holes. I suggest that you use 3.5 or 4mm rings on both sides of the plastic for support. After you have secured the bottom portions of the extender to the enclosure, you can roughly adjust their total height by the second extender. 

    Before you finally mount everything again, apply heat paste to the NFET positions on the heatsink and use an insulated silicon pad with an insulator ring for the LM35. Loosely tighten the 3 screws again and use an Ohmmeter to make sure that the LM35 tab is insulated from the heatsink, because the NFET’s are not, and their pads will connect to the DUT voltage of up to more than 100V to the heatsink.

    When everything is in position, you can tighten the screw for the LM35 and again check that the tab is still isolated. Unscrew the two NFET’s screws again and now add the extra TO220 heatsinks on top of them, using plenty of heat transfer paste.


    Make sure that the heatsinks do not touch the PCB. You can now carefully tighten the screws for the NFET’s.

    After that, you can do a final adjustment of the two front supports so that the PCB is horizontally mounted inside the enclosure. When that is done, re-heat the middle pins of the three devices, to let the stress out, and then solder the other pins. Use plenty of solder for the NFET leads, they will get stressed by the developing heat (up to 100 degrees C).

     

    Preparing for a first power-on

    After you have finished the above steps, we can start to power-up the board again and verify some of the vital signs.

    You only need to add the 12V DC power to the board, but I recommend you use a Lab supply initially with a current setting of 100mA. If there is no large current, indicating a short or another issue, you can now switch to the 12V DC wall wart.

    Do not install the ESP32 in its socket at this moment until you have verified the power rails.

     

    Verifying the Power Rails

    You can now verify all the power rail voltages:

    ·         DC Input 12...15V at J4

    ·         +12...15V at pin 1 U9 (LM7809)

    ·         +9V at pin at pin 3 of U9

    ·         +5V at pin 3 of U12 (LM7805)

    ·         -5V at left side of C31 or pin 5 of U5 (ICL7660)

    ·         +4.096V on either side of R60

    When that is OK and within specifications, you can go to the next step, but first disconnect the 12V DC input again.


    Adjusting the OLED display in position on the front panel

    For this step we need to install the ESP32 module on the PCB and load the ESP32_OLED_Test_V1.ino firmware, located on the Github site.

    Do not apply the main 12V at this moment, it is not needed for this step.

    The OLED module connects to J6 on the PCB. The module comes with flying leads that each have their own 1-pin connector. I recommend you change these single connectors to a 7-pin connector so you can’t make mistakes with the order, and it’s a lot tidier and easier to remove and install.

    You can connect your PC to either the mini-USB of the ESP32 module, or start to use the mini-USB to USB-C adapter. When you have made the connection, the red power LED on the ESP32 module should light-up and your PC probably will give a signal that a new device is connected.

    I’m assuming that you already installed the Arduino IDE. If not, you need to do that now. There are plenty of instructions on the internet to do that successfully. You must also install support for the ESP32 and you can use Google to find the instructions. I was using IDE V2.3.2 and now the just available V2.3.3. The Arduino IDE is needed to load the firmware for the ESP32 module. Locate the ESP32_OLED_Test_V1.ino on the GitHub and download it to your PC. Save it in a new directory called “VB Dynamic DC Load” in the Arduino directory on your PC, it is most likely located in your Documents directory.

    After you saved it there, use the Arduino IDE to locate the file and load it into the IDE.

    After loading the firmware, in Tools select Board and search for the DOIT ESP32 DEVKIT V1 in the esp32 branch. That’s the ESP module we use, and the firmware will most likely only work with that module.

    Under Tools, select the connected COM port to establish communication to the ESP32.

    Compile and download the firmware and see if it gives you any errors.

    If there are, you need to figure out what the problem is. There are too many possibilities to help you from here.

    The OLDED display board is just lying on your desk and that's OK. Install the connector from the OLED display to J6 on the main PCB, and position the module so you can see the screen and the white connector on the back is on the right-hand side of the display. When done, you can now connect the main 12V power again, because it is needed to power the OLED. You need to press the EN button on the ESP32 module to force a reboot after you supplied the 12V. When successful, you should first see a splash screen with the version number for a few seconds and then see a white square on the OLED screen because all pixels are lit. Congratulations if you got this far!

    The text of the splash screen will show the proper orientation of the OLED display. You could change the orientation of the display in this test code and repeat that later in the firmware, but if you keep to the instructions, and have the white connector on the right-hand side of the OLED module, you should be good to go.

    You can now proceed to mount the OLED display in position on the Front Panel.

     

    Mounting the OLED display on the Front Panel

    To prepare for the mounting of the OLED display in position on the back of the Front Panel, we need to change the mounting hardware that came with the display.



    During all these operations, keep the screen protector foil on, or apply it again. It will prevent you from scratching or smutching the glass. Use gloves when appropriate.

    Remove the four M2 screws and standoffs. Keep the four screws, but we will not need the standoffs. You need eight extra M2 nuts and four M2 washers to prepare to mount the contraption on the font panel.

    Add an M2 nut to the M2 screws. Stick them through the hole of the board, and add an M2 washer and then another M2 nut. Tighten loosely. The M2 washer is needed to create some extra space between the glass of the OLED and the Front Panel, so don’t skip it. You may otherwise break the OLED display. Do this for all the 4 holes of the OLED board so it looks like the pictures below. The four nuts will be glued to the PCB pads.



    You can now position the OLED board to the back of the Front Panel and check the fit. It should slide on the four nuts, not the glass.

    Apply the 12V main power again and do a reset of the ESP32 (press EN) to verify the orientation of the text from the splash screen and then see if you can position the white rectangle in the center of the square of the front panel. You can now peel the protective cover of the glass, because that may be difficult or even impossible later on. I strongly suggest you use gloves and avoid any finger prints or worse, glue getting on the glass.

    Before you do the next steps, I suggest you practice the next moves once or twice to make sure you can position the OLED properly without tangling the wires or moving the OLED display that you just glued in position. If you are not happy using Superglue, then use normal glue that you can still move a bit, but you then should tape the two together and let it dry for a few hours.

    I use Super Glue paste, not the liquid to avoid dripping the goo all over the place. 

    With the OLED module powered and showing the white square, hold the OLED board with the display side up in one hand, with the white connector on the back to the right-hand side and add a drop or two of (Super)glue on each of the 4 nuts that will connect to the solder pads on the back of the Front Panel.

    With your other hand, pick-up the front panel and position and hold it just above the OLED screen with the silkscreen text from the front panel up and make sure the white LED rectangle square is in the middle of the square hole in the front panel. When satisfied, slowly lower the front panel and press the two together and let the (Super) glue dry. After a few seconds with Superglue, you can carefully turn the Front Panel together with the OLED board face down so the OLED stays in position and you can let it dry a bit more. 

    If you used normal glue, you then need to secure the OLED in position with sticky tape so it will not move while you let it dry for several hours.

    Turn off the power and disconnect the USB connection to the ESP32.

    Wait with the next steps until you are sure the OLED display glue is dry! Give it enough time to dry or you will regret it.

     

    Loading the Dynamic DC Load firmware

    The firmware for the Dynamic Load is located on the GitHub site and needs to be downloaded before you can load it into the Arduino IDE. The firmware is needed to operate the instrument, and at power-up will make sure everything starts in a known and safe state. 

    The firmware is in a zip file with the name of the version number. You need to unzip the zip file and put the 6 files in a new directory that must have the same name as the zip file, and create that directory in the ../Documents/Arduino/VB Dynamic DC Load directory you created earlier. 

    The firmware consists of 6 different files that the IDE will stitch together to create the firmware during the compile, link and then download process.

    Load the file into the IDE and compile & download it to the ESP32 module. You don’t need to turn on the 12V just yet. Just make sure it finishes without errors. The first time can take a several minutes so be patient and just look at the bottom screen of the IDE to see what is going on.

     

    First firmware turn-on

    Do not supply the 12V yet and also do connect the two fans to the PCB at this moment yet. Position the front panel with the OLED connected to the main board such that you can easily see the display. The front panel does not need to be mounted to the enclosure yet, but you could temporarily do that.

    When there are no compile or download errors, the firmware is loaded and started, and with the red power LED on the ESP32 module already on, the blue LED now starts to flash. If that is the case, then congratulations are in place again. Well done!

    With the USB power applied, and when you now supply the 12V main power, the ESP32 is not getting a reset. You need to do a manual reset (press the EN button) again so the firmware is restarted, the OLED now becomes operational and after the splash screen with the version number, you should see the following start screen.

    Great if you are this far! Don't worry about the "negative" or "invalid" warning in red for the voltage. That is because nothing is connected yet and the inputs are floating.  The temperature reading for the heatsink in the lower right corner should be OK though.


    Connecting the fans

    Turn off the 12V and remove the USB connector. If you still use the Lab Supply, raise the current to 350mA. You can now connect the two fans to the PCB and go to the next step. 

     

    Boot sequence

    When you apply the 12V main power, the red power LED on the ESP32 module will switch on, and both fans will start to run at full speed. After about 2 seconds, the splash screen appears and the blue LED on the ESP32 module will start to flash. The flashing is an indication for the execution of the firmware main loop. The splash screen makes place for the initial screen display and the fans will be turned off. That actually completes the boot sequence. The instrument is now ready to make measurements and accept commands.

    If you got this far again, great!

     

    The front panel

    It is now time to finish the front panel installation, and connect the remaining leads and parts to make the unit fully functional.

    In the picture below you can see my wiring on the back of the front panel.


    To connect to the rotary encoder, I used a ready-made and assembled wire-harness that I purchased in different pin sizes. Here I’m using a 5-pin version. On the rotary encoder itself, I bridged the middle of the 3-pin connector which is GND to one of the two switch pins. The VCC pin of the connector is not used. It is there in case you have a rotary encoder with a debounce circuit that needs power. The firmware works well enough with the rotary encoder without hardware decoding support.

    The main power leads for the DUT are heavy duty and I used so called car connectors to make it easy to mount them. Make sure they can handle 10A.

    It’s a little hard to see, but there is a 10nF capacitor directly soldered on the Current Monitor BNC, to take care of a nasty glitch caused by the induction of the cables.

    For the main DUT and sense inputs, I used these 4mm Banana binding posts. They have the correct 19mm distance and you can use wires as well.


    The wiring of the sense switch is quite simple. I connected leads between the main Banana terminals and the sense terminals with solder lugs and used two wires connected to the center pin of the switch to go to J3 on the PCB.

    The power switch is in between the plus lead coming from the DC jack on the back panel and the positive connection of J4 on the main board. The ground lead from the DC jack goes directly to J4.

    I used 2-pin wire harnesses for the Current Monitor and the Transient Input connectors, and used these BNC connectors:


    The main power switch and the USB adapter are not showing in the picture.

    To make sure you don’t pull out the USB-micro to USB-C adapter from the ESP32 socket, I positioned the adapter with everything mounted, and used a tie-wrap flush to the front panel to secure it. To make sure it stays in position, I used some glue to fix the tie-wrap into position.


    With the USC-micro to USB-C adapter connected to the ESP32, you may need to adjust the front supports of the main PCB so the adapter easily fits the hole in the front panel.

    When that is done, you can put the front panel and all the wires to the main PCB in position, and secure the front panel with the two bottom screws to the enclosure. Do not install the top cover just yet.

    With everything thus far installed, you should have a fully working instrument that should look like this:

     



     



     

    You are now ready to move on to the Calibration & Verification section.


    Calibration & Verification

    Remove the top cover of the enclosure. You need access to the trimmers and test points.

    Initial step

    Make sure you have the latest firmware version installed that is available on the GitHub. 

    To start the full procedure again after an earlier procedure, you need to revert some of the calibration factors in the firmware back to the original value. These constants are located in the calibration section in tab ESP32_V4_xx.ino of the firmware in the Arduino IDE starting at around line 54.

    ·         double const shuntVcalib = 1.0; // optional

    ·         double const dutVcalib = 1.0;

    ·         double const cvCalFactor = 1.0;

     Set these values to 1.0 if not already and recompile and load the firmware.


    Calibrate the OLED voltage display

    1. Set a Power Supply to 2.50V, or use a voltage reference, connect it to the main terminals of the Dynamic Load (DL). Use a DMM to verify the actual voltage.

    2. Set the remote sense switch to off.

    3. Make sure the NFET’s are OFF so there is no current flowing.

    4. Note the OLED display for Voltage and adjust RV1 on the PCB so the OLED shows the same voltage or as close as you can get it. (due to the averaging and the resolution, take your time)

    5. Use a Power Supply to raise the voltage to just below 100V or as high as your supply supports (stay below 105V), and verify using a DMM.

    6. The difference between the DMM measurement and what the OLED shows should be less than +/-0.5%. If it is more, you can activate the optional calibration factor in the firmware to apply a correction.

    7. Calculate the difference with the DMM and the OLED voltage and use that as a factor below.

    ·         double const dutVcalib = 1.0;

    The calibration constants are located in the calibration section in tab ESP32_V_4_xx.ino of the firmware starting around line 54.

    8. Recompile the firmware to apply the calibration, and run this calibration section again to verify.

     

    Verify the sense switch operation

    1. Set the Power Supply to 30V and a current of at least 1.5A. Connect sense leads from the DL sense inputs to the Power Supply. Directly connect them at the Power Supply connections.

    2. Switch the sense switch to on and verify that the DUT voltage is the same in both on and off settings.

    3. Turn the DL input ON with a short press of the decoder button, and check that there is no current flowing yet. Adjust the rotary encoder of the DL load such there is at least 1A flowing as a load.

    4. Alternate the sense switch in both positions to show the effect of the external sense input that will compensate the voltage reading for higher currents flowing through the main leads, that will cause a loss and therefore a voltage drop. If you switch to higher currents, the effect will even be larger.

     

    Current calibration for the DAC

    1. Set the Power Supply for a voltage of 10.0V

    2. Connect a DMM to the DAC test point and a GND test point on the main PCB and use the rotary encoder to get a reading closest to 400mV on the DMM - let the system warm up for a few minutes and readjust if needed.

    3. Adjust RV2 on the main PCB to get a current of 1.000A on the power supply or measure the current with a DMM. Note that the current on the OLED display itself will not be accurate yet, it still needs a calibration.

     

    Verify the DAC-ADC and the Power Section accuracy

    1. Measure the voltage at the DUT_I test point on the main PCB -- it should be between 396 and 404mV which is an accuracy of +/- 1%.

    2. Store the error in DUT_Current.

    ·         double const DUTCurrent = 400.00 - your reading in mV; (it is not used however)

     

    Calibrate the OLED display to show the correct current value

    1. Make sure that the shuntVcalib constant in the firmware has a value of 1.0.

    2. If not, set it to 1.0 and re-compile and load the firmware with that factor.

    3. In the CC mode, with the load ON, set the current with the encoder such that the Power Supply shows a current of 3.00A, or use a DMM in current mode to measure the current.

    4. Note the current value on the OLED display and divide the Power Supply or DMM reading by that of the OLED value.

    5. Enter that result (it will be around 2.5) in calibration constant shuntVcalib and re-compile the firmware to activate it.

    6. Verify that the OLED current now is virtually the same as the Power Supply or DMM current at different load values.

     

    Calibrate the CV mode tripping voltage

    1. Make sure that the calibration constant cvCalFactor in the firmware has a value of 1.0.

    2. If not, set it to 1.0 and re-compile and load the firmware with that factor.

    2. Use a Power Supply and apply a voltage of 50.00V, set the maximum supply current to 100mA. (When the CV mode is tripping, a Lab Power Supply will go into the CC mode, and will apply the full current to keep the voltage the same. We want the current to be low, to keep the temperature low during this calibration)

    3. Activate the CV mode, the Set voltage will be automatically set to 10% higher or 55.00V. Turn the DL to ON. There should be no current flowing, if there is, raise the set voltage until there is no current flowing.

    4. Slowly dial down the Set voltage with the rotary encoder and take note of the Set value when the tripping point happens. This is when current starts to flow. You will have to raise the Set voltage about 0.5V higher in order to turn the current flow back off. This is the normal hysteresis activity.

    5. Calculate the deviation factor of the DUT voltage and the tripping point voltage and apply that to the calibration constant cvCalFactor and recompile and load the firmware to make it effective. As an example, with a tripping voltage of 52.50V, the deviation is 52.50/50.00=1.050000 and that is the calibration factor that needs to be stored in the firmware.

    7. After recompilation and loading, verify that the cut-in voltage is now very close. (it is unlikely you will get it exactly the same, but it should be within a few percent)

    8. Try the CV mode now with a Power Supply setting of 2.00V and verify that the tripping point is very close. You will have to dial-back the rotary encoder from 50V down to 2V, which, even with fast dialing, will take some time. You can also cycle through the modes by long-pressing the rotary encoder, until you are back at the CV mode, in which case the Set voltage is automatically set to 2V + 10%.


    CV mode with a regulated (CV/CC) power supply

    Note that with a Lab Power Supply as a DUT, the CV mode is a bit more difficult to use due to the rapid switch of the power supply from CV to CC at the DL tripping point. You need to carefully adjust the encoder to get to an actively controlled load.


    CV mode with an unregulated supply

    To better test the CV mode and get more familiar with it, you can use an (unregulated) power supply that does not have current fold-back or current limiting/regulation. A transformer with a (bridge) rectifier and an electrolyte filter capacitor will much better show the CV mode regulation in operation. This kind of DUT will clearly show the sagging DUT voltage as a result of the load.


    CV mode with a battery

    Basically any battery or cell will provide another DUT to get familiar with the CV operation. Be aware that some of these cell can deliver a lot of current. This is one of the reasons that in the firmware, the current limit in this mode is set to 4A, hopefully preventing injuries or fire-works. Because the battery or cell will to its utmost to keep the voltage stable, you can clearly see the effect of the current changes.


    The Battery Mode PC software

    The Battery Mode application that communicates with the Dynamic Load, sets-up the instrument and does the graphing, is available on the GitHub site. It's a single executable that you can install on your PC wherever you like, and you can run it from there.

    Below is a typical sample:



    A final precaution

    Do not turn the Dynamic Load power off with a DUT connected. The decaying voltage rails may turn the NFETS's on, causing a current to flow in the DUT, even though the NFET's were turned off.

    For the best protection of your precious DUT, always disconnect the DUT from the Dynamic Load before you turn power on or off.


    I may add more later... Stay tuned...