The lamp that WAS meant to be! (WS2812B LED Box)

A little while ago, I was experimenting with a WS2812B LED and toying with the idea of making a basic lamp. Things didn’t work out and the project was scrapped but I still had the internals of it ready on a breadboard so I gave it another go, while taking in some inspiration from the comments on that post which mentioned a product that’s more or less a small table-top spotlight.

20150822_151542

From my previous experiments, I already had a WS2812B LED soldered to some wires. For this project, I used only 22AWG stranded wire. For isolation and to hold things in place, I used hot glue.

20150822_151553

With the LED ready, I started by putting one of my Attiny85 breakout boards onto the perfboard.

20150822_200005

I then completed the soldering of the LED and potentiometers to the perfboard. The potentiometers are all connected to each other by Vcc and Ground. It seems like the connections in between one another weren’t very good as the LED would go wild at times, changing color or blinking for no reason. After some wiggling with the wires, I found which connections were weak and reflowed them.

20150822_202840
… But even reflowing the connections didn’t work. The only thing that did fix the problems was putting force on the connections in a certain way. Once I got it working, I quickly hot glued everything. I know that’s horrible, but, being such a no frills project, I’m not very concerned. After the circuit was completed, I trimmed down the perfboard since the rest of it wasn’t needed.

20150822_204337

The potentiometer and LEDs were all 5mm^2 so it wasn’t difficult cutting out appropriate sized holes for them. I first put in the LED and taped it to hold it in place before adding hot glue.

20150822_204355

After the LED was in place, I fed the power supply wires (female jumper wires) through a hole I cut near the bottom corner of the box. The potentiometers come with a washer and nut so I didn’t need any hot glue to keep those in place. This is my first time using these kind of potentiometers in a project and, even without fancy knobs, I think they look great. They certainly look better than tiny trimpots, which is what I would have used otherwise.

20150822_204657

And that’s it! The placement of the potentiometers was planned specifically to double as a way to lay the box down on an angle.

I hope you liked this simple project of mine. I recently ordered a set of these LEDs for an idea for the next Light Show.

PS. My main website, www.mwhprojects.com, was recently updated!

Chinese Power Adapter Teardown

IMG_0198I got this power bank yesterday from China. Obviously it’s not a Samsung product but the power bank does seem to work fine. I wanted to make sure that it wasn’t connecting to data so I sliced the cable open. It only connects the power wires, thankfully. I bought a cheap USB voltage and current measurement tool on eBay but it won’t be here for a long while, especially with their national holiday. I’d like to measure the current coming out of the outputs.IMG_0187Anyways, it came with this really sketchy power adapter. The USB slot is like a half USB slot where your plug doesn’t fit in all the way or latch in properly. You can also feel the assembly was loose inside of it by just shaking it. I was definitely not planning on using the plug so I decided to open it up and see what was inside.IMG_0188Three sides of the front plate were already loose. I just had to slide a knife down the fourth side and a quick tug on the plug popped the assembly out.IMG_0189There’s a transistor between the transformer and a capacitor but there’s barely enough space for it so they put it on an angle. For whatever reason, the other transistor nearby is also at an angle and they’re both pushing over another capacitor. I thought it looked funny.
IMG_0190Dave from the EEVBlog explains in a video what’s crap about it, more than I ever could, but it was interesting to look at one myself.
IMG_0199Here’s a closer look at one of the boards.

So yeah… I’m not expert enough to rip on the board, but anyone can point out it’s a piece of junk just by holding the thing.

Tutorial: LM317 Variable Voltage Regulator

I noticed a couple people landed on the blog because they were searching for information on the LM317 voltage regulator. I figured I should do a tutorial on it and hopefully they’ll come back to see it.

Here are some of the key features listed on the datasheet: Max output current is 1.5A; Adjustable output voltage between 1.2V and 37V; Current limiting and thermal shutdown protection.

When you’re connecting the circuit, take careful note of the pins on the regulator. From left to right: Pin 1 is Adjust, Pin 2 is Vout, and Pin 3 is Vin. This is important to remember as the circuit diagram has a different order when you read the diagram from left to right.

The circuit in the datasheet calls for capacitors but I didn’t include them for this basic demonstration. They’re used to smoothen out voltage spikes and improve the transient response. The datasheet calls for 0.1uF and 1uF at Vin and Vout, respectively. If you’re using electrolytic capacitors, make sure that the polarity is correct. The negative side is marked with a white stripe. That side of the capacitor should be grounded while the other side goes to Vin or Vout. I’ve read that ceramic capacitors have a better effect on the transient response so feel free to use them if you have them. They’re not polarized so you don’t have to worry about which way they’re connected.

I connected the circuit shown in the datasheet, minus the capacitors, and supplied it with my unregulated 9v DC power supply which actually supplies around 12v with no load.

IMG_0850The minimum output voltage checks out at 1.2v.IMG_0849This was the maximum voltage I could get out of the regulator’s output. As I said in the power supply tutorial, it’s never a good idea to ask more from your power supply than it’s rated for. When you’re using the LM317 regulator, chose a power supply that supplies a higher voltage than what you’ll actually need.IMG_0852Here’s the regulator circuit adjusted to drive a yellow LED. All you need to do is turn the potentiometer and read the output on a multimeter until you get your desired voltage.

If you don’t want to use a potentiometer, you can calculate your R2 once you have chosen an R1 and you know your desired output voltage, Vout. I thought it would be neater to take a picture of my notes rather than try to type out those equations…

IMG_0856So if we were to replace the potentiometer with 1.5kΩ, we should get 9v…

IMG_0854That’s so satisfying.

I hope this helps out those looking for information on the LM317 regulator.

Tutorial: Full-Wave Rectifiers

IMG_0747In my first tutorial about power supplies, I mentioned I picked up this adapter by accident. This adapter has an AC output which is pretty useless to me, unless I build a rectifier for it. That’s what this second tutorial is going to be about.

I was taught about rectifiers by this guy who just threw up a whiteboard of equations every lecture. The labs didn’t help because they were boring (ie. Get the circuit working, get a signature, go home, wonder what I’m doing with my life). While I sort of understood what was going on, I definitely needed some time to register it all, even if that time is like two years later. Looking up information online to refresh my memory was difficult because it was the same formulas being thrown back at me.

In this tutorial, I’m going to show you how a full-wave rectifier works. It changes an AC signal into a DC voltage. My goal with this tutorial is to explain how it works with little to no formulas, enough so that you could practically use everything here if you happened to be stuck with an AC output adapter like me.

ewb_posWhenever you’re analyzing a schematic, the best thing to do is group components into blocks and figure out what they do, and then see how they work together. This is what the first piece of the rectifier looks like. When the sinusoidal input is above the x axis (positive values), the current takes the path of the red line starting from the top of the source (the circle). For now, think of the two dots as the places where you’d put your oscilloscope probes to see what’s happening.

ewb_negWhen the source voltage is below the x axis, you can think of the source as flipped upside down so that current is now coming out of the bottom of the source and following the blue lines. Notice how the flow of the current is going through your top oscilloscope probe and exiting the bottom again as it did in the previous diagram.

ewb1This is what the waveform now looks like with the AC source going through that diode configuration. The negative values of the sine wave is flipped over the x axis so all of the values of the signal are positive.ewb2When you add in a capacitor, the capacitor charges once the input signal is applied and then stays at a certain voltage (the voltage level will be discussed later). Since there is no load, it doesn’t discharge so the voltage remains a nice DC output. Obviously, this is useless to us, but it shows the reason for the capacitor.ewb3Once a load is added (the resistor in the diagram), you start to see ripples in the voltage. The peak-to-peak value of the ripple is known as the ripple voltage. This ripple happens because the capacitor discharges as the input signal heads toward zero. The capacitor charges again as the signal heads back toward its peak.

The reason I did the simulation is because I don’t have an oscilloscope. I still did it on a breadboard with my multimeter in hand, where I did a couple simple calculations. Let’s go through it.

IMG_0792The source measurement is giving us 14Vac…IMG_0793… at 60Hz.

The 14Vac that we’re seeing is an RMS, or root mean square, value. Any value taken by a multimeter is an RMS value. All you need to know is that if you are given an RMS value, the peak is actually the RMS value multiplied by √2. To go the other way if you are given the peak value, the RMS value is the peak voltage divided by √2. If you’re unsure what to do with √2, just remember that the RMS value is always less than the peak.

IMG_0794 So, with our 14 volts read by the multimeter, the peak is actually 19.8v. If we account for the two diodes that are conducting for each half of the cycle, that’s a 1.4v drop (each diode is a 0.7v drop). That leaves us with an 18.4v output. How satisfying. Remember that we have to use the peak value because the capacitor charges up the peak, not the RMS level (which is 70.7% of the peak).IMG_0795And obviously, with a DC output, the signal is 0Hz.

IMG_079618.4 volts is still pretty high for the applications I have for my supplies. The LM7805 voltage regulator can handle input voltages between 7-35 volts to produce a 5 volt output. You can use other voltage regulators to have other DC levels for your projects.IMG_0798For an example of a practical use, here’s the rectifier and 5v regulator driving one of my new blue LEDs.

So that’s it! Hopefully you understood everything in this tutorial. While I probably wouldn’t use this in a project (for space issues, primarily), it’s good to understand this concept as it is basically what’s going on in some DC output adapters.

Tutorial: Power Supplies

Introduction

When I first started playing with an Arduino, I relied on USB power. Once I got into those roaming robots, I started using a battery holder I bought with the rest of the parts. In my recent projects, I’ve used power adapters that plug into the wall. With my experiences using different ways of powering my projects, I thought I’d write a tutorial that may help someone chose a supply for their projects.

Power supplies can come in different forms that give you choice based on what’s best for your project. Making a roaming robot? Go with a 4-cell AA battery holder. How about a scarf with LEDs? The lithium ion polymer (“lipo”) battery is great for wearables because it’s light and small. Sticking up strip lights above your kitchen counter? You’ll need a power outlet adapter to drive all of those LEDs. Of course, you can stray away from what a certain power supply is typically used for, as long as it can handle whatever your project is asking for.

Battery Packs

IMG_0748

Every maker probably has a handful of battery holders lying around at any time because they’re so easy to come by. Most of the holders I have were stripped off of old toys and electronics.

The voltage that is supplied by the pack is easily calculated by adding the voltage put out by each cell. On most batteries, a mAh, or milliamp-hour, rating will be given. This is telling you how many milliamps you can draw from the battery for an hour. For example, if you have a 3000mAh battery, you can draw 3000mA for an hour, 1500mA for two hours, etc. The higher the mAh rating, the larger the capacity of the battery and the longer your project will be powered.

Power Adapters

You also probably have a power adapter lying around from an obsolete device. Inside of the “black box” is a transformer to step down the voltage, and then a rectifier circuit to make the output DC (if the output is DC). I’ll probably try writing tutorials for transformers and rectifiers once I brush up on the material. For now, all you need to know is that the adapter is converting your outlet power into power suitable for your project or device.

IMG_0752Look for the specifications printed on the adapter. The input is always the same but you need to make sure it’s an input that works for your location. In North America, we’re looking for adapters that want 120v 60Hz power, while people in other places around the world may want to look for adapters that want 230V 50Hz power. If you’re reading this, you should know what comes out of the plug next to you.

As for the output, that will vary between project and device. It is always important to know the power your project requires. For most projects, you’ll be looking for a DC supply. It’ll need to have a voltage rating appropriate for the components in your project. It is always possible to change the voltage for parts of your project using voltage dividers or regulators (to be discussed shortly) so go with the highest voltage that is required by any of your components. It is important to consider the current draw of your project as you can cause your adapter to overheat and fail if your project begins to draw more current than the adapter is rated for.IMG_0747This was a good reminder to check the specifications carefully. I accidently picked up an adapter with an AC output…IMG_0751Some adapters allow you to change the voltage and polarity of the output.

IMG_0754It is a good idea to check your power supply with a multimeter. With the variable power supply in the previous picture, the label on the switch is not very accurate so I used my multimeter to adjust the switch to the proper position. I didn’t want to open up the project to take a picture but I still wanted a picture of my lovely multimeter so this was the best I could do. (Please see the Voltage Regulation section for an extra word on measuring your supply.)

IMG_0749Power supplies will usually come with some sort of connector at the end of it. Just remember that no matter the shape of these connectors, it always leads to a couple of wires. I don’t bother looking at the connectors anymore because I end up chopping them off and stripping the wires. If you want to keep the connector, you can pick up a female connector to add to your project so that you can easily plug and unplug your power.IMG_0750This supply for my PLC shows the symbol for DC power, the dotted line under a solid line. The symbol for AC power is a sine wave. It also has circuitry so that it can work internationally as seen by the input rating.

Voltage Regulation

IMG_0767

Sometimes, parts of your project may use a different voltage to one that your supply is giving you. The LM7805 is a 5v constant regulator that I use to power my Atmega 328 projects (unless I have a 5v supply). For other voltages, you can use other constant regulators or a variable one like the LM317.

If you are using an Arduino board, such as the Uno or Mega, there is an onboard regulator for you already. As long as you supply it with at least 7v DC, it will be happy. If you’re using a power adapter and it doesn’t have the correct barrel jack connector, you can strip the wires and power the Arduino through the Vin pin. Don’t forget to connect the ground too. One thing to note is that each pin on the Arduino can handle 40mA max, so you’ll need to consider the current draw of each component. That’s why people tell you to use an external power supply for servo motors because they’re one of those components that will draw a lot of current.

Switches can be added in various places around your project. Good places to put them are on your main power supply and the supply to major components that you’d ever want to cut power from. If you’re ever dealing with lots of power, be sure to check the rating of the switches.

About measuring your supply: Adapters can be regulated and unregulated. Regulated adapters have voltage regulator circuits built in them while unregulated adapters don’t.  When you measure the voltage of an unregulated adapter, the voltage may be higher. The voltage will drop as the load on it gets larger. I’ve never experienced any huge variations in measuring my supplies but it may happen and it could affect your project.

Conclusion

When choosing a power supply, you look for one that is an appropriate shape for your project and one that meets the power requirements of your project. It’s a good idea to have a multimeter around when building and testing your project to make sure you’re getting the correct voltage and current in the places you expect. As you always should while building something, be cautious with what you’re doing to ensure the safety of you and your project.