Saturday, May 29, 2021

0000 0000 0110 0011

ZK-4KX (PSU II)

I'm enamoured with the idea of having a purpose built PSU on the lab bench - it seems that this is quite a rite of passage for the home electronics hobbyist. We all have different needs and/or wants for such a device, and also there is a lot to be gained from designing, building and debugging your own PSU.

To that end, on an earlier blog I fleshed out the idea of a switching voltage regulator such as the LM2576 or LM2596 to reduce a 20V input (e.g. from a computer AC/DC supply) to say 8V and then using a linear regulator (less efficient, but nicer output) such as the L7805 for instance to make a stable 5V available for the bench.



Of course, there are also "pre-built" switching voltage regulators, and recently I took delivery of a ZK-4KX unit which I want to test for this PSU project.

Advantages (if it works) include protection, displays, current limiting, etc., but it also just might lend the whole project a bit of legitimacy so that people don't focus so much on the hotglue disaster likely to plague "my side" of the PSU.

In this video I spend most of my time testing and then complaining about a shonky batch of L7805 linear voltage regulators, but in the end I think the overall concept will work.

It's also worth noting that there is an overall fault in my electron train - once which I don't spot even though the train hits me, oscillating like crazy, at around 20V. It took a child's wind up clock to remind me that the obvious things are often the easiest to overlook.



Saturday, May 22, 2021

0000 0000 0110 0010

CD4070 XOR light switch

Scene: A cold Tasmania evening. Having braved a day of arctic wind, frigid fog and horizontal rain you make a beeline for the bedroom and the warm quilt covers. Entering the room you flick the light on, climb into bed and ... dammit just as you thaw out you have to get up to turn off the light!

What we need is some electronic wizardry to turn off the light from near the bed (or turn it on for that matter). In fact, it would be nice to turn the light on or off from either near the door or near the bed.


You could fill a magic box for this project with a micro-controller, Raspberry Pi or similar and code the solution to this frosty dilemma, but also you just happen to have some CD4070 XOR gates in your boxes of bits. 

The wonderful thing about the XOR gate (and there are many), is that just like the XNOR gate we have seen before on the blog, the state of the output changes EVERY time an input changes. If the light is on, flicking either switch will change the state of the lightbulb. If it's on, it goes off. If it's off, it goes on. Perfect.


So putting all of this together on a breadboard yields a circuit capable of meeting the requirements of the scenario. If you need to build this In Real Life™ with an AC component then I urge you to use an electrician, not a bored and cold hobbyist, to wire up the actual circuit!


Not coming out




 

Saturday, May 15, 2021

0000 0000 0110 0001

LM2596 Step Down (Buck) Switching Voltage Regulator (PSU I)

Down a big rabbit hole measuring nano-currents I recently found myself wondering if it is time to DIY or BUY a Power Supply Unit (PSU) for the workshop. I'd like to be able to dial up reliable/variable power of course, but I'm also looking for stable (linear, non-ripply) power for microcontroller projects where dependable voltage and current limiting is expected/implied for most applications. My current options (pun intended) are not so fancy in that regard.


Ideal therefore is some sort of buck/boost IC leading off to linear regulators as per the following back of the envelope drawing.

I'll probably end up using a buck/boost module feeding in from a typically strong AC/DC converter (e.g. a laptop supply perhaps operating around 20V at 3-5A). I am looking specifically at the ZK-4KX buck/boost unit for this "stage one" of the PSU - which I'll test separately in the next couple of weeks.

In the meantime I've dragged out some LM2596 buck converter ICs billed in the datasheet as "a monolithic integrated circuit ideally suited for easy and convenient design of a step−down switching regulator (buck converter). It is capable of driving a 3.0 A load with excellent line and load regulation."

We have looked at the LM2576 before, and seriously for my application there is no appreciable difference, but for the sake of the blog and channel I thought I'd drop in the LM2596 just to show them working.

The LM2596 can be configured to drop down the supply voltage, let's say from 20V to 8V, and then this could feed into an L7805 to give a flatline 5V for any hungry μC that needs a feed.

The breadboard revealed that the LM7805 chips might be a little shonky, so I ended up with my old favourite the HT7850! 

Unfortunately the current draw of these little guys is not really up for PSU work, so I'll need to spend some time looking at all of my LM7805 chips, or maybe an alternative.



Next in the PSU project I will be testing the ZK-4KX in combination with linear regulators and then I'll put the whole shebang together in a 3D box and get out (maybe) of this rabbit hole.



Saturday, May 8, 2021

0000 0000 0110 0000

Shiny sparkly things

Most people who visit our home take away a free fake candle. It's a bit of a tradition, and these devices are now found sitting on window sills all over the world, which is great. It is maybe not so great if you are a visiting child, because candles can be a bit boring unless real fire, genuine heat and immediate danger are involved.

Glittery sparkly things that you can hang around your neck for weeks and glow in the dark are an entirely different matter! To this end, and not at all because I also like glittery sparkly things, I have used Big Clive's design to make a powered necklace based on an LED which includes a LFSR chip to "randomise" the flickering. The main online supplier I can find seems to be called "MOLESMELL", but don't let that put you off!

The LEDs landed in the country for around AUS17 cents each, and they seem quite energy efficient, running off a single CR2032 battery for around 2-3 weeks depending on their colour (i.e. forward voltage).


Early versions were large enough to fit over a person's head, but then I became worried about snagging, choking and all manner of misadventures that could lead to accidents.

Therefore after a few trials with different systems, I have been making them lately using a magnet clasp or similar (e.g. a "normal" Neodymium magnet pair), which has the dual role of completing the circuit, but also allowing the necklace to come apart quickly with not too much force so that any potential mishaps can be avoided.

And for this version I'm experimenting with putting the battery close to the LED at the base of the necklace.

I have been experimenting with different LED/"Crystal" colour combinations, but I find that if the LED colour is matched to the "crystal" colour, or if a "white" LED is used in any "crystal", then the effect is more pleasing - and a higher resistance value can be employed to lower the current and thus extend the lifetime of the battery.






Saturday, May 1, 2021

0000 0000 0101 1111

ATTiny84 low current meter

Sometimes I want a nice cup of tea. At times it seems that the universe is not so keen on the idea - the tea needs replenishment, the milk is finished, there are no cups until the dishwasher is finished it's cycle, the lightbulb in the pantry is out so I can't see where the new tea is located - you get the idea, and we've all had days like that.


I recently also had an idea that it would be nice to accurately measure low currents so that I could experiment with the ATTiny13 and the PFS154 head-to-head by testing current draw while sleeping or collecting solar rays, etc.,.

My usual Cheap As Chips™ digital multimeters would unlikely be accurate at the levels predicted and I cannot afford a µA or nA meter. So I was chuffed to see David Johnson-Davies on the Technoblogy site whip up a simple low current meter using the ATTiny84's ADC inputs. As I was reading the blog I realised that I was out of tea AND cups needed a "regulated 5V power supply" (PSU) for accuracy.

I'm not sure that my cheap PSU or any other alternatives on the bench were going to cut it, but before committing to designing/building a lab PSU, I will whip up David's nano current meter just for proof of concept. The next few blogs and videos might contain a smattering of PSU stuff as well!

In the meantime I figured that an HT73XX LDO voltage regulator (either 5V or 3.3V) would probably provide a stable enough output to at least test David's circuit.

Before any comparisons between microcontrollers occurs, I firstly used the ATTiny13 in various modes to test the low current meter.

With the "bare sketch" and galloping along at 9.6MHz the meter measured "Hi", which is to say that it overshot the limits of it's measuring ability (Current > 10µA).

Even the "bare sketch" ambling at a mere 128kHz was still too high, but things got a bit more interesting when the ATTiny13 was compelled to sleep, firstly with the Analog Comparator, Analog to Digital Converter, Watchdog Timer and Brownout Detector all on, and then all off.

#include <avr/sleep.h>                  // the sleep routines

void powerDown(void) {

  //disable watchdog if enabled
  wdt_reset();                          // turn off Watchdog Timer
  MCUSR = 0;
  WDTCR |= _BV(WDCE) | _BV(WDE);
  WDTCR = 0;
  ADCSRA &= ~(1 << ADEN);               // turn off ADC
  ACSR |= (1 << ACD);                   // turn off Analog comparator.
  cli();                                // Disable BOD
  BODCR = (1 << BODSE) | (1 << BODS);
  BODCR = (1 << BODS);
  sei();                                // enable global interrupts
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);  // sleep deeply little one
  sleep_enable();                       // enable sleep mode
  sleep_cpu();

  sleep_disable();                      // ISR routine returns here so wake up
  ADCSRA |= (1 << ADEN);                // turn on ADC
  ACSR = (0 << ACD);                    // turn on Analog comparator.
  delay(50);                            // settle time after waking up
}

void setup ()
{
  DDRB = 0b00000000;                    // all pins inputs
  PORTB = 0b00111111;                   // and internal pullups
}

void loop () {
  powerDown();                           // call the function that sleeps
}

After measuring the actual voltage output of the HT7350 and HT7333 (4.98V and 3.21V respectively) I coded the measured voltages as well as the "1uF" capacitor (which was measured at 964.2nF) as shown below.



The ATTiny84 was programmed with David's code using an Arduino as ISP.


Then the chip was put into the circuit as per David's diagram (but not anywhere near David's neatness!).

Here are the results: