Thursday, June 14, 2012

Soldering iron driver v1.5 build

So I finally have my soldering iron driver v1.5 from dangerousprototypes (designed by Arhi, laid out by  Arakis) in a condition that is stable and useable.

A few words of advice for people building this

  1. When you populate the board, build the power supply section first and test it to make sure it works. You don't want to find out your buck converter is not working when smoke comes out of your op amp or PIC18F.
  2. The adjustment of the trim pots in the positive temperature coefficient (PTC) amplifier is explained in a readme file in the hardware section. This adjusts the constant current source into the PTC thermistor.
    1. Remove sensor from PTC connector
    2. Attach milliampermeter to PTC connector
    3. Power the device on
    4. Turn CAL1 pot until you get exactly 1.000mA going trough. 
  3. Once you have the current source trimmer set, set the gain as follows.
    1. Remove sensor/milliampermeter and connect a 100 OHM resistor (1% or better) to PTC connector. 
    2. remove jumper from JP1
    3. Power on device 
    4. Turn the RV2 pot until you get on the top pin of JP1 exactly 3.00V
  4. I had problems with the heater control section. It turns out the opto-triac was bad. Not sure if I received a bad one or I fried it somehow. I ended up picking up a non-zero-crossing opto-triac at the local All Electronics. In case you were wondering, a non-zero-crossing works just fine.
  5. Arhi recommended not installing the capacitors for the low-pass Sallen-Key filter. I didn't see that warning until after installing them. They actually worked well with a time constant pretty close to the calculated value so I left them in.

After the board was fully populated, except for the NTC and the thermocouple amplifier sections, I squeezed everything into a plastic box. The enclosure was actually a container for Korean pepper paste (gochujang). I was impressed with Egor who correctly identified the container from a front/side shot.
Here is a picture of the top clearly showing its source.

I hooked up buttons for menu, + and -. These were interrupt driven and the switch bounces caused a lot of problems. Arhi wrote a debounce routine but the button presses were limited to 5 per second and there was no autorepeat which made adjusting the temperature a bit tedious.

I rewrote the debounce code and added autorepeat. This made the interface much easier to use. I posted the changes in the forum

Here is a shot of the inside.
I need to secure the circuit board inside. There is a lot of empty space inside and I am always short on benchtop space. If I am motivated, I might move everything into a smaller enclosure (Korean soybean paste (doenjang) container perhaps). I will have to use a smaller LCD display (8x2 characters) and rewrite the firmware to be more succinct and frugal.

Here is a shot of the completed circuit board. In the second picture, you can see the diode lead art for the bridge rectifier. The capacitor to the right of the diode was a bit big and the diode was squeezed for space. There is another diode standing upright just behind the cap as well.

The transformer was salvaged from a lab freezer controller board. It has multiple primary windings for different input voltages and two separate secondary windings. In its current configuration it puts out 20V AC. Even after its been on for an hour, I can't detect a temperature increase above ambient. The triac gets a bit warm, possibly because the input voltage is lower than the expected 24V so I am going to put a heatsink on it.

Addendum: I have received several requests for precompiled binaries. I have uploaded the modified source along with the compiled binaries (with and without bootloader versions) to github. You can get them at

Tuesday, May 8, 2012

Making Tris buffers by mixing

One of my least favorite lab activities is measuring pH. It dates back titrating buffers using burettes in chemistry lab-- drip dropping one droplet at a time, becoming impatient, and then overshooting. Barnacles!

I try to avoid making Tris buffers for the same reason-- it requires careful drip dropping of HCl. If you overshoot a little, you can bring the pH back using NaOH but then you have added NaCl to your buffer. I found out the hard way making TAE buffer this way-- the NaCl conducts electricity too well.

I need to make Tris pH 7.7 for protein purification and was wondering if there was a way to mix Tris base and Tris HCl to come close to the desired pH. It turns out you can using the Henderson Hasselbalch equation.

pH = pK + log([A-]/[HA])

pK for Tris is 8.1 at 25 deg C

[A-] = 0.285 and [HA] = 0.715 for a 1M solution when pH = 7.7

Using FW for Tris base and HCl that translates to 112.7g of Tris HCl and 34.5g Tris base.

Here is a python script I wrote to solve for the values. Save it as then make it executable using chmod u+x To use it, type 7.7. Here is a sample output:

$ 7.7
For pH 7.7 Tris buffer at 25 deg
112.72 g of Tris-HCl for 1L of 1M soln
34.49 g of Tris-base for 1L of 1M soln

Here is the python script.


import sys

ph = float(sys.argv[1])
pk = 8.1 ## at 25 deg
            ##N.B. per Sigma catalog, pH drops 0.03 to 0.05 per ten fold dilution
            ## also increases ~0.03 per deg C

mwb = 121.136   # FW of tris base
mwa = 157.59    # FW of tris HCl

# use henderson hasselbalch equation to solve for a and b
# pH = pKa +log10(b/a)

a = 1./(1+10**(ph-pk)) #solve for a and b
b=1.-a                  # for a+b =1, i.e. 1M soln
                        # math is your friend

print "For pH %2.1f Tris buffer at 25 deg" % (ph)

print "%.2f g of Tris-HCl for 1L of 1M soln" % (a*mwa)
print "%.2f g of Tris-base for 1L of 1M soln" % (b*mwb)

OK, this is high school chemistry, but that was a long time ago. Hope you find this useful.

Monday, April 9, 2012


I would like to win one of the elusive free PCB coupons from Dangerous Prototypes. Finish one, get another! How can you beat that deal? Haven't won yet, but it is only a matter of time.

I have to admit, I was one of the people who requested the opportunity to buy PCBs from the PCB drawer. When I saw Ian's breakdown of first year sales of the Bus Pirate, I felt twinges of guilt because I had not yet purchased. I plunked down my $10 and received two DIY Bus Pirates PCBs. I sent in a Mouser order for the parts (plus extra SMD resistors because they are easy to lose).

All told, the PCBs, components, plus shipping/handling came out to about $50 for the two Bus Pirates. Considering Seeed Studio will sell you one for $27, assembled, programmed, and shipped, this was starting to look like a losing proposition. Did I mention the twinges of guilt driving the purchase?

I soldered up the boards in an evening. This was my first time assembling SMD parts but after watching the HOWTO videos on Dangerous Prototypes, it wasn't so bad. Patience, flux, and desoldering braid.

When I plugged in a USB cable, the PWR LED came on and the computer recognized the FT232 chips. So far so good. Now I needed to program the PIC24 chips but I don't have a PIC programmer. I didn't want buy a PicKit because that would really make for a losing proposition. I saw that Jozef had devised a way to program the devices using a AVR microcontroller. He was kind enough to share source, precompiled binaries, and firmware. Great! But I don't have a AVR programmer. Talk about bootstrapping problems!

I do have a MSP430 Launchpad and I figured I could have the MSP430 emulate the AVR. I modified the firmware code to run on a MSP430G2553. I picked this part because it has a built in UART. You can probably modify the code to run on MSP430s with software UART but I am not going there.

Here is a picture of the programmer hooked up. PGC is on P2.0, PGD on P2.1 (through a 1K resistor), and MCLR on P2.2. The Launchpad runs at 3.6V but this is within the electrical specs for the PIC24 so I figured why not. Fortunately, it works just fine.

I programmed the v4.4 bootloader using ApProg using the Launchpad running the modified firmware. The firmware came next using the ds30 loader GUI. This is much faster than trying to program the combined bootloader/firmware using ApProg. The ApProg binary is available here.

And it works! I have two functional Bus Pirates. No more twinges of guilt. So the final cost for the two Bus Pirates (PCBs, parts, Launchpad) came out to almost exactly what I could have ordered from Seeed Studio. But mine have DIY silkscreened on the boards!

Here is the source code for the MSP430. It has been condensed into a single file. You can create a new project in code composer studio v5, copy and paste into main.c and compile. Some day, perhaps I will take the time to learn how to host files on github. Posted on github.