Tuesday, April 21, 2015

AD9833 Signal Generator

In an earlier series of posts, I described building a prototype signal generator using a DAC driven by an Arduino. The Arduino sent sample values to it, allowing arbitrary wave forms to be generated. It was limited to a fairly low frequency by the rate at which the samples could be sent.

An alternative is to use a component that generates signals directly. Analog Devices have several such. They are known as DDS devices, for direct digital synthesis. The idea is that the DDS generates a digital value internally which it then converts to an analog output. The disadvantage of such devices is that they can't generate arbitrary waveforms. For example, the AD9833 generates sine, triangle and square waves, and the AD9850 generates only sine and square waves. They are not really intended for arbitrary signal generation, and instead are aimed more at things such as modulating and demodulating signals.

I put together a signal generator using an Arduino, a prebuilt AD9833 module and some components to provide a user interface: a LCD display, and a rotary encoder. You can pick up AD9833 modules quite cheaply on ebay. AD9850 modules are more widely available and a bit cheaper. Here is the wiring diagram for how I connected it up:
The rotary encoder incorporates a switch, which I have shown separately, and the trimmer is for adjusting the contrast on the LCD.

[Sep 2021: the code for this is no longer available. The following description might not make sense as a result.] Roughly, the idea is to show three fields in the display: the frequency (1Hz to 1MHz), the waveform and whether automatic or manual mode is in use. Automatic mode means changes take effect immediately. Pressing the switch (actually the shaft of the rotary encoder) has various effects. A long press moves between the three fields, indicated by an arrow next to the active field. While in the frequency field, turning the encoder increases or decreases the frequency, and a short press of the button select which digit you are altering. For example, if the current frequency is 10000Hz and the current digit, indicated by a cursor, is the middle one, the frequency changes in steps of 100Hz. On the waveform field, the encoder steps between sine, square and triangle. On the automatic/manual field, the encoder steps between these options, and a short press on the button while in manual mode applies the current settings.

Originally I had thought of making this a full project, packaging it up and adding more options to the software. For now, I am leaving it like this, as I have some ideas for a different signal generator project that I would like to explore.

Sunday, April 19, 2015

Finishing off the PSU

In a couple of previous posts, I wrote about building a PSU based on an instructable. I finished this off by packaging it in a plastic box. The original used an aluminium one, so the whole box can act as a heatsink. The converter board came with a heatsink with some self-adhesive tape. I replaced this with a thermal adhesive pad made by Startech, and then cut a hole on the side of the box for it to protrude from. I'm not sure how hot the heatsink will get and whether this poses any risk to the plastic box; time will tell.

Here's a few pictures. Note that I set this up so that anything that is in the lid of the box connects to things in the base through something that can be unplugged or removed mechanically in some other way. This makes putting it together a lot easier.

 

Friday, April 17, 2015

Desoldering parts from a buck converter module

A few weeks ago, I wrote about building a power supply based on a LM2596 buck converter module. The design came from a posting on instructables. Destructables might be a better name, as you have to remove two present pots from the board and it's very easy to damage it in doing so. After my first messy attempt I decided to try to do it better. I've desoldered things with a solder sucker and with solder wick, and by just heating and wiggling the part, but all of these have the risk of damaging small tracks or pulling out the through hole plating. A bit of searching pointed me at using ChipQuik. See this video for a good description of it, and also part of this one. It's expensive to buy, but it turned out I had some lying around from a SMD soldering skills kit I got at Jameco. You slather some flux paste on the joints, then melt something which looks like solder over the joints. It's actually not solder, but an alloy which merges with the solder and gives you a mixture that has a lower melting point. You can can then keep all the pins molten which you gently pull on the part. To clean up, I used solder wick, taking a tip from the second video. Melt some solder onto the tip of the soldering iron, place the solder wick over the area to clean up, and then press the soldering iron onto the solder wick. The solder on the tip of the iron helps the wick heat up quickly and transfers heat the the areas of the board you are working on. Together these resulting in a board with clean holes and no damage to the tracks. Nice.

Sunday, April 12, 2015

Dremel tools

I bought a couple of additional tools for my Dremel (actually a Wen). One is the Dremel 561 Multipurpose Cutting Bit. I was hoping this would help when I need to cut a hole in a project box. It's a bit too aggressive for that, and you can't cut accurately to a line, at least on ABS, so I'm not sure I'll be making much use of it. The other is the Dremel 631 Brad Point Bits set. This is really nice - four very sharp drills, with brads (pointy bits) which helps center them when you are starting to drill.

Tuesday, April 07, 2015

Boxing up the Capacitance Meter/Transistor Tester

A short while ago, I wrote about a kit for a tester for capacitors, transistors and other components. I got the kit from banggood and they also sell a plastic case for it. You have to do a bit of adaptation to make the case fit. As they put it: "You need to trepanning for the switch, because this shell is Molding products, you need to DIY yourself". As the saying goes, Trepanning Takes your Breath Away.

There are several things that need doing. There is a switch for operating the tester, but no hole in the case for it, so you need to measure up and drill one. The kit includes a plastic top to put on the switch, but it still didn't make it easy to use, so I replaced the switch with a simple normally open push button mounted on the case. You can drill a hole in the side to get at the 2.1mm power socket. Some of the pictures on the banggood web sites show bringing the 9V battery clip outside the case by making a small notch for the wires, and I did the same, to avoid opening the case every time I needed change the battery. Finally, I used binding posts for the test points. The holes on the case aren't quite far enough apart for the ones I used, so I filed them out slightly. I also rotated the screw terminal block that the wires from these go into so that the opening face inward on the circuit board. This makes the wires from the terminal block to the binding post less crowded.

One other thing I needed to do was to remove a couple of lugs from the bottom half of the case. Without doing this, the case is not deep enough. This might explain one of the comments about the fit on the banggood site.

Here's some pictures:



Sunday, April 05, 2015

ATX power supply

There are many people out there on the web who have taken old ATX computer power supplies and adapted them for use a bench power supplies. Instructables has a page with many such designs, differing mostly in the style of case, and the connectors they use. You can also buy a hugely overpriced kit from Sparkfun. I had an old power supply from a disassembled PC and decided to do the same. I decided that I would use 4mm binding posts so I can plug banana plugs into them, and to include an on-off switch and a couple of LEDs, one for when the power is connected the ATX (standby) and one for when it is actually on. For the project box, I chose a CES box, size 3.97" x 2.12" x 1.72". That's 100mm x 54mm x 44mm in measurements used by grownups.

To get the layout of where I needed to drill holes and cut a hole for the on-off switch, I drew up a diagram in Open Office Draw, then printed it out with lines marking the centers of the holes. One of the holes, for the switch, was rectangular, so I marked the boundaries of where I'd need to cut. It looked like this:

I then took the lid of the CES box and placed it face down on the printed reversed diagram, taped it in place, and used a rules and something pointy to lightly score the positions I needed to drill and cut. Note that my power supply does not have a -5V output, as some older ATX supplies do, and having two posts for ground was just for convenience.

My ATX supply had many wires and connectors coming out of it:

The printed page in the background is an older version, before I realized that there was no -5V. The important connector is the rectangular 24 pin connector at the top right. I hesitated between putting a 24 pin female connector in the box as in this design, or snipping the 24 pin male connector off and bringing the wires in directly. Using a connector has the advantage that if the power supply dies or if I wanted it for something else, I could disconnect it easily, but I wasn't sure that I could cut a clean hole the right size and make it mechanically stable. The design I just mentioned attaches the connector to the box with epoxy, but as these connectors are quite stiff to attach and remove, I'm not sure how well that would survive. Another option might have been to attach the female connector to a piece of stripboard and then attach that the the case with a couple of screws. That plan was thwarted by the size and pitch of the pins on a Molex Mini Jr connector. It's 0.165", so it won't go on standard 0.1" stripboard. One more option is to keep the connector, but make the connection inside the case, with just a hole in the side of the case to bring the wires in. This is promising, but with the size of case I had chosen it was hard to make it work. So in the end I decided to connect a 24 pin female connector outside the box and just bring through the wires I needed. I brought in one wire for each voltage and signal, and two for ground.

With this, we're ready to get out the drill and the dremel. I'm not good at doing the physical construction part of projects, due to a lack of both skill, and good tools. Or perhaps experience rather than skill. I can usually get something that's OK, though it might not look pretty, and in this case I ended up with the LEDs a bit skewiff. I see an analogy with what my coding was like back when I started: I could hack my way to something that would work, but in an unclear way and lacking finesse. 35-plus years of programming and working in a professional environment changed that, and maybe if I spend more time on projects like this one, I'll improve.

With all the parts in place on the front panel, it's a matter of connecting everything up:


I attached the ATX connector to the outside of the case with hot glue, and also daubed a bit around inside to anchor the LEDs and the bundle of wires. To prove it works:


I still have to make some labels for the binding posts, and then it'll be done.

Things that worked and didn't about this. Worked: it's compact, gives useful voltages. Drilling and cutting the case was imperfect but not too bad. Less good: the weight of the bundle of wires from the ATX makes it hard to keep this stable. Some of the instructables projects are physically attached to the ATX case, and this is probably a better idea. Other less good things: I'm not sure how well the glue holding the connector will last. And finally, I scratched the case in a couple of places while putting the whole thing together, which is just annoying. Overall, I'd rate this as 2/5: it works, but is a little disappointing.

Sunday, March 29, 2015

A small power supply

As I mentioned in the previous post, I have been building a small bench power supply. It is loosely inspired by the instructable here. That design has a LM2596S module to convert from unregulated DC to regulated DC with voltage and maximum current controls, and a voltmeter/ammeter module for displaying the output levels. It also uses an Arduino to indicate whether the voltage or the current is limited. What I built omits this last part. I don't really see it as needed, as the module has a built in LED that conveys most of the same information. It's labelled CC/CV and is off when the voltage is limiting and on when the current is limiting; more on what this means in a moment. All I did was to unsolder the one that is built into the board and solder on an external LED, so I can bring it out to the front panel when I put it in a case. I did the same for the OK LED on the module. I also used a different meter. And finally, I omitted the on-off switch and the output on/off switch from the instructable design. So the final design looks like this:

(Image generated by MooseCAD).

The specific LM2596S module I used is this one, and the meter is this one. I bought both on ebay from a seller called nyplatform. Note that one difference with the original design is that the thin black wire (power for the display) does have to be connected or the display does not come on.

My input was a wall wart with a variable output that I had lying around. It has a 2.1mm connector. I have several other wall warts with fixed output, and an old Thinkpad power adapter with the same connector. Any of them will do. The weakest spot in the components I used was the 2.1mm socket from MCM Electronics, which doesn't make a very good connection and has to be jiggled sometimes to make it work. I'll replace this at some point.

Adapting the power module

The power module is designed to be used in a battery charger. If you follow the link, you'll see it has three adjustment potentiometers attached to the board, one for the voltage, one for the current limit, and one which sets the threshold at which charging is considered to be complete. We are only interested in the first two, and we want to replace them by free standing potentiometers. Unlike the instructables design, I used regular 270 degree linear ones, not 10 turn wirewound ones. The 10 turn ones are expensive and I don't think I need that level of control. You have to unsolder the adjustment pots from the board so you can solder on wires going to the free standing ones instead. Unsoldering the adjustment pots from the module turned out to be quite hard to do, and I ended up damaging one of the PCB tracks for the wiper of the current adjust. Fortunately, there is a small pad on the module PCB which it connects to, and I was able to solder a wire to it. For one of the pots, I soldered on a header, but after doing this I decided it didn't offer an real advantages electrically or mechanically, and so I soldered the wires directly to the board for the other one. I also removed the power and CC/CV LEDs and soldered on external ones instead. Note that if you remove the CC/CV LED, you must attach either an external LED or a resistor instead or you lose the ability to set a current limit. You can see why by examining the circuit diagram, which shows it is part of the feedback into the LM2596. The result looks like this:

I'll package it up into a box when I get one of a suitable size.

Controls

There are two controls, one for setting the voltage and one the current. The original instructables article is not very clear on how these controls work. Perhaps this will help. The module will provide output at the voltage you set, provided the load on it stays below the current limit that you set. If the load tries to draw more current than this, then the voltage will drop to keep the current at the threshold. When this is happening, the CC/CV light will come on.

For example, I connected a 10 ohm, 10 W resistor to the output and set the voltage to 5V with the current setting turned up to maximum. The meter shows a voltage of 5.02V and a current of 0.49A. Now I turned the current limit down. Eventually it reached the point where the current limit was below 0.49A. At this oint the CC/CV light comes on and the voltage drops. For example, with one setting I got 0.25 A and 2.61 V. Probably it's not exactly 2.5V due to the tolerance of the resistor. Note that I had not changed the voltage setting: it was just the current limit which was forcing the module to output a lower voltage.

The function of the other ("OK") LED is a little less clear: it is on when the current limit has not been reached and is off when it has been reached, but there is also a gap when neither is on.

I imagine in most cases when I am going to use this power supply, I'll just have the current setting on maximum, as I'm typically more interested in setting a voltage limit.

One last thing is to see how the output looks on a scope. Here it is:

Removing the DC and zooming in shows about 3mV oscillations for about 5V output:

When current limited the shape is slightly different: