What is Freeside?

Freeside is a Georgia nonprofit corporation, organized to develop a community of coders, makers, artists, and researchers in order to promote collaboration and community outreach. Learn more »

Constant Current Dummy Load

I just got my first oscilloscope. Complex analog circuits are now possible.

As I mentioned in my last post, I working on a power distribution unit (PDU) for motorcycles, cars, and other DC applications. The project is very close to the testing phase and that means I will need to run this device at precise power levels and at precise temperatures. The testing protocol also includes vibration studies, but today we are just going to talk about precision current testing.

This can be done many different ways. You can just put a resistor to ground and use Ohm's Law to tell you how much current you are burning. If you want to change the current in use though, you will have to change the resistor. That is not very handy if you want to test your power supply at multiple currents as you will need a lot of different resistors. Since my system is running at about 14V and I am talking about 15A of current, I'll need some pretty beefy resistors and those are expensive.

Instead, I've decided to purpose build a constant current dummy load. This uses a single logical load resistor (I will have parallel resistors but they will behave as one) and adjusts the voltage across it to define the current that gets burned. I searched Amazon and found a pair of 100W chassis mount 0.1Ω resistors for $7. My requirement for this testing tool is to be able to burn up to 15A which is the maximum current load I have defined for the device. Using Ohm's Law that means I'll need to to be able to adjust the output voltage between near 0V and 1.5V. If you put 1.5V across a 0.1Ω resistor you get 15A, so that is the plan. I have not done all the calculations necessary to nail down the exact output for a given input, but doesn't really matter because the input is linear from 0V to 1.5V and you will measure the output across the load and do your Ohm's Law calcs based on the precisely measured (4 wire) resistance for that specific load resistor. 200W is just a tad bit low (about 10W by the numbers) but I'll mount these on a heat sink with a fan around if necessary.

There are a couple of options I could select to get 1.5V on the output. I could use a voltage regulator to get a "precise" voltage, but that isn't really a good option. Regulator's are not that precise. Instead I'll use a voltage reference. The one I had in the drawer was a 2.048V reference and I can count on it to output exactly that figure. It is a high impedance output though so I'll need to do something else with that. I could setup an op amp and voltage follower and have a low impedance voltage source. With that, the standard thing to do would be to put a voltage divider in the circuit with a potentiometer to adjust that output to another op amp and put an output transistor in that amps feedback loop. I've decided to NOT do this though. I don't have any nice pots (10 turn or 1 turn), so I've decided to doing something with some digital components as well. I've decided to use a DAC (an MCP4921) to produce the voltage, based on the aforementioned reference. To control the DAC I need a micro-controller. I had a tube of ATTiny85 MCUs and that is just perfect for my needs. The ATTiny85 is an 8 pin MCU with 5 IO, Vcc, GND, and reset pins. The DAC requires 3 pins as it uses an SPI interface. That leaves me 2 pins to the human/machine interface. I have a drawer full of rotary encoders (like a digital pot). It outputs a quadrature code which essentially tells you what direction the knob is being turned. The MCU keeps track of the current state and adds or subtracts based on the encoder input and then sends a command to the DAC to change its output. 

My DAC is referenced to 2.048V and it is 12bit so it will output a linear voltage between near 0V and 2.048V at 4096 equal steps. Since I want only 1.5V I'll put a static voltage divider in the circuit and send that to the op amps which are controlling the output transistor.

I've seen a couple projects like this on the internet and they all used a system to control the output transistor that I don't like. They use a MOSFET which I like, but they simply bias the transistor in it's Ohmic region so that it is being used as a variable resistor. That causes the MOSFET to produce a lot more heat than if it were being run fully "enhanced" or "saturated" (we are talking about N channel enhancement MOSFETs). If you fully enhance it, power flows through it at lower resistance and your MOSFET will run cooler. It also means your analog circuit will need to be able to do fast, and preferably rail to rail, switching to keep the current constant. If fast rail to rail switching is what you need, then a comparator is a good thing to use.

I am using three op amps in the output transistor loop. The DAC feeds a voltage follower op amp and its output feeds the positive input of another. It's output feeds the positive of a third whose output drives the gate of the MOSFET. The MOSFET output runs into the negative terminal of the latter two op amps. This gives me a rail to rail PWM signal to the gate of MOSFET such that for each .1V I put into the first op amp, 1A goes through the load resistor. A nice system and my MOSFET runs as cool as possible.

This is the first analog circuit I've designed and built. It was made possible by the introduction of an oscilloscope to my lab. I like it! You can see my love of digital electronics has not died by my introduction of the MCU and DAC to a circuit that could have been done just as well with a nice 10 turn pot. No matter, the encoders are a dime a dozen and small while 10 turn pots are pricey and large.

Another challenge faced in this project is the fact that I am running an SPI device on an ATTiny85. This is worth mentioning because the ATTiny doesn't have a hardware SPI interface so it needs to be done in software. I didn't see any examples of this on the interwebz, so I'll post it up here in case it's is of use to anyone. I should also mention that the DAC I am using is a MCP4921 in case someone searches for a way to use this chip with a ATTiny they won't have to reinvent this wheel. The important things to notice are the use of the word (16 bit number) and the shiftout, highbyte, and lowbyte functions I am employing. These are built into the Arduino tool chain so as long as you can handle your latch pin by yourself you are in business.

int del=0; 
word outputValue = 0;
byte data = 0;
int val = 0;

int csPin = 0;
int sckPin = 1;
int siPin = 2;
int ENC_A = 3;
int ENC_B = 4;
void setup()
  pinMode(csPin, OUTPUT);
  pinMode(sckPin, OUTPUT);
  pinMode(siPin, OUTPUT);
  pinMode(ENC_A, INPUT);
  pinMode(ENC_B, INPUT);
  digitalWrite(ENC_A,HIGH); //these pins do not have pull up resistors on an attiny...
  digitalWrite(ENC_B,HIGH); //you must pull them up on the board.
void loop()
  int enc = read_encoderJOM();
  if(enc != 0) {
    val = val + (enc*10);
    val = min(val,4095);
    val = max(val,0);

void setDAC(int value) {
    outputValue = value;
    digitalWrite(csPin, LOW);
    data = highByte(outputValue);
    data = 0b00001111 & data;
    data = 0b00110000 | data;
    shiftOut(siPin, sckPin, MSBFIRST, data);
    data = lowByte(outputValue);
    shiftOut(siPin, sckPin, MSBFIRST, data); 
    digitalWrite(csPin, HIGH);

int oldENC_A = 0;
int oldENC_B = 0;
int8_t read_encoderJOM() {
  int a0Pin = digitalRead(ENC_A);
  int a1Pin = digitalRead(ENC_B);
  int returnVal = 0;
  if(a0Pin != oldENC_A || a1Pin != oldENC_B) {
    if(oldENC_A == a1Pin && oldENC_B != a0Pin) {
      returnVal = -1;
    } else if (oldENC_B == a0Pin && oldENC_A != a1Pin) {
      returnVal = 1;
    oldENC_A = a0Pin;
    oldENC_B = a1Pin; 
    return returnVal;
  } else {
    return 0;

Entire circuit except for the output transistor and the load resistor. Those are visible in the video above.

Yellow is output from DAC. Green is the final output to the MOSFET gate. The DAC is outputting 1.47V (the scope is off by a factor of 10) and the meter tells me the load resistor is burning 17A. The op amps are running at 12.5V and peak the peak the PWM is 12.4V. There is lots of room in that duty cycle as well you can see.

"Making lemonade with lemons" or "Reworking your bad PCBs"

I've been working on a large project for a few months now. It's a DC power distribution unit, and as you can imagine it has need for relays. I've got the thing setup to accept cards to can perform many uses both input and output. One of the many cards I've designed for this system (dual low-side switching relay, 5V, 12V, audio sensor etc..) is a dual high-speed 12V solid state relay card.

Rendering of PDU and fresh pile of PCBs from Circuitmart
This is a photo of the relay on a breadboard.
 single channel of dual high-speed 12V solid state relay on breadboard
This is the card from both sides. The "empty" space is used for thick and wide traces to carry current. These will be built with 6oz copper and can source 23A @ 330W in theory. I've only pushed them to 100W so far but they showed no meaningful rise in temperature so I think I am on the right track. By the numbers, they are right where they should be.
Because these cards are small and parts count it large (4 diodes, 6 transistors, a driver IC, 7 resistors, 1 tant cap) I sourced  ICs with the configs I needed inside of them pre-configured. You would be amazed what you can find at Digikey if you look hard enough. Anyway, I'd never used these ICs before so I was required to design the footprints for them and lay them all out and what not. Long story short (too late), I read the datasheet wrong for one of them and got some pins confused. I didn't notice this until I had it all built up and my beautiful square wave looked like this.

Not so square... :(
I began going through everything and I found the problem, but what to do? Well, run new wires of course!
I didn't have to do any drilling because I happened to have vias available so I just needed to cut some traces and thread some wire. I used an old length of stranded telephone wire. After stripping the outer shield, I removed one of the four insulated wires inside and stripped it down to its constituent 8 strands. I used two strands (twisted) for the short trace and one strand of the longer one. In order to raise the single strand's current capacity a bit, I wet the entire length of the strand with solder. This also stiffens it so it wont bend so easy. 

My square waves have returned to me!

Bench power supply project

I found myself needing a 480W power supply to test a high current project I was working on. A 500W bench/lab power supply will set you back $100s so I figured a PC power supply was the cheapest bet. For $80 you can get a Wonhunglow brand. I checked ebay and found Dell 500W server power supplies CHEAP. Like $2 cheap.

I acquired a couple and figured out how to turn the thing on by shorting 3 pins together. Then I designed a simple little 4 rail power supply PCB and had it built by OSH Park. This power supply outputs 12V and 5V and 4V. I didn't have any use for the 4V so I skipped those pins but did add a 500mA 3.3V LDO to my board so I have 3.3V, 5V, 12V, and GND rails available. I left a large section of the solder mask missing so I could solder on some more current carrying capacity and called it done. I used a DPDT switch to short out the 3 pins required to turn on the 12V rail and added a little LED to indicate that the 3.3V regulator was running and put a small current limiting resistor on the LED so that the regulator is stabilized (I didn't check the datasheet too closely but it is common for an LDO to behave strangely until it has a minimum load). One minor complicating factor was the unusual connector on this hot swappable power supply. It had a part number on it though and I was able to get Molex to send me a couple mating adapters.

I will redesign this with a fully adjustable constant voltage and constant current output in the the future. That will be a bit of a project because 500W is a lot of power to bleed off and I want it to be accurate so I plan to use 12bit DACs and ADCs. I've been looking around for them and they are expensive enough that I think I will just use a ARM Cortex 3 microcontroller with on board 12 bit converters. More on that on some future post.

Here it is.
The business end.
Plugged into the Power Supply
Side view of the Power Supply with PCB attached
The back side featuring the LDO and Molex connector.

Successful Launch of Classes on Meetup

A little over 2 weeks ago, we at Freeside Atlanta launched a series of classes on Meetup on everything from Linux to 3D Printing. They've been a huge success so far! Our 3D Printing class, shown above, was taught by 3D Printing Expert Anthony Aragues. We had 11 students sign up for the first class, where they covered the recent iterations of hardware and software and how to use them.

In fact, every single class that we launched filled to capacity. Intro to Linux, Intro to Electronics, Intro to Arduino, CNC, and 3D printing. Thank you to all of the Teachers and Students that made this little experiment such a success! Because of how well this first round went we'll be launching more classes and workshops soon, so stay tuned!

Sharp Memory LCD - Arduino Library

This post extends the previous post.

Source Code Released!

I've got a little reflow oven simulation running on the LCD. I think its going to be great for the reflow oven project.

The source for the sketch in the video is attached below. The library now does vectors in addition to text and bitmaps. I am now extending the Adafruit GFX library so I can use those vector drawing routines in addition to my PGM space bitmaps. I still need to clean up the unnecessary banging I am doing on one pin. I'll post up the code on the interwebz for all to use once that is cleared up. I need a darn oscilloscope to inspect that pin!

If you need an early copy of the library and you don't know how to contact me, PM me from the youtube video.

#include "SharpMemoryLcd.h"


void setup() {                

void loop() {
  lcd.setTextColor(0, 1);
  lcd.print("Sharp Memory");
  lcd.print("LCD Library"); 
  lcd.print("Adafruit GFX");  
  lcd.drawLine(0, 0, 95, 95, 0);
  lcd.fillRect(4, 4, 7, 7, 0);
  lcd.fillCircle(7, 7, 2, 1);
  lcd.print("Draw Vectors");
  for(int x=0;x<32;x=x+4) {
    lcd.drawRect(47-x/2, 47-x/2, x, x, 0);
    lcd.drawCircle(75, 75, 20-x, 0);
  lcd.print("Invert Them");  
  lcd.print("Reflow Oven");
  lcd.drawRect(0, 0, 96, 96, 0);
  lcd.drawRect(1, 1, 94, 94, 0);
  lcd.drawRect(2, 2, 92, 92, 0);
  for(int x=3;x<93;x++) {
  lcd.print("Remove PCBs");
int testTemp(int x) {
    return x+1;
    return 30+((x-30)/2);
    return 45+((x-60)*2); 
    return 75;
    return 75-((x-85)*3);    

Sharp Memory LCD - Musings

Update: Arduino Library Released

If any of you guys were at Freeside this weekend, you would have seen me staring into the oscilloscope trying to make heads or tails of its output and comparing that to a couple of datasheets. One of those datasheets was for the Atmega328P microcontroller that is on the Arduino UNO, the other was the Sharp Memory LCD. These are cool because the are ultra low power 6uW and have extremely high contrast.

The Sharp datasheet isn't what I would call straightforward, at least for the uninitiated (whom I count myself among). The power up sequence was pretty clear but once it came to pushing pixels it got a little vague. Really it was just a bunch of waves on the sheet.

One of the waves is a constant 5-60Hz pulse. That is the sort of thing that would be very irritating to create if you are bit banging on the main loop of your program, so I needed to get the AVR to pump that out in an automatic way. Researching the interwebz and reading the Atmega datasheet at length and comparing that to the output on the o-scope, I came up with this:

pinMode(11, OUTPUT);
TCCR2A = _BV(COM2A0) | _BV(COM2B1) | _BV(WGM20);
TCCR2B = _BV(WGM22) | _BV(CS22) | _BV(CS21) | _BV(CS20);
OCR2A = 65; // 60HZ roughly
Which is logically equivalent this (to but not as annoying because it happens in the absence of the loop):
int bang = 0;
void loop() {
  pinMode(9, OUTPUT);
  if(bang == 0) {
    bang = 1;
  } else {
    bang = 0;

The prior code puts out a "phase correct" square wave on pin 11 at 60Hz. It also screws with pin 3 (not good) which I need to address next time I am at a scope. With that, it was just a matter of reading the data sheet for the screen and deciphering the thing into C code. I also found a non-arduino project on youtube using one of these screens and asked the poster to send me his source which was very helpful in understanding the datasheet. Once that was done, I converted that C code into C++ code and made a "SharpMemoryLCD" Arduino library. Currently it can print out basic strings and read byte[]s from PROGMEM and paste them to the screen. I will also add some other features like painting vectors to the screen and loading bitmaps from a disk before I'll call it "done". The current functionality is enough to get the reflow oven project I am working on finished though. That reflow oven project will be the basis of a future Freeside project/class where attendees will get a custom PCB and firmware to use to convert their toaster oven into a high quality reflow oven. You will be required to bring a 1500W toaster oven, and I think the rest of the stuff I'll include in the class fee (custom electronics, solid state relays, and thermocouples).

This is the code that produces the images in the video above. The library is not link up yet. I'll make a google code project for this once I have it a little more mature. Feel free to post up a comment if you want a pre-release copy. I'll hook you up.
#include "SharpMemoryLcd.h"


void setup() {                


void loop() {
  lcd.LcdPrintString("  CRAFTYCODER'S",4);
  lcd.LcdPrintString("  WIFE COMES HOME",7);

ISP Programming Jig w/ pogo pegs

During one of the last projects I was working on, I found that the first programming jig I made had a serious draw back. It could only put the #1 pin of the programmer in two of the four corners. That meant that I could only program my board from one side. That was fine until I assembled the project in it's case. At that point, reprogramming was a difficult task that required disassembly, something I never considered when I designed the item and as it turned out it was almost impossible to do without destroying it. Annoying!

Three weeks ago I decided I wanted to flash some new firmware on my motorcycle remote so I could use it to put a GPS on my Kindle Fire. That meant I needed take it apart and risk destroying it. Not an exciting prospect. Then I thought, why don't I just build another programming jig like the last one only upside down. That seemed like a winner, because it was fast, but I didn't have any more 2x3 ISP headers. Bah! Since I needed to wait on a shipment from Digikey I went ahead drew up a custom circuit board and added a few bells and whistles and sent it to fabricator. 

The bells and whistles I spoke of are a pair of ISP headers which are mirror images of each other and a pair of LEDs that point to the #1 pin. When you plug into one the of the two headers, one of the two LEDs lights up pointing to the #1 pin. This function makes it easy to identify how to orient the PCB to the jig.

Below are images of the schematic and the board layout. The assembly is very easy. You just take two of the PCBs solder a pair of headers to the bottom board and pogo pegs to both and use some stand offs for strength. Check out the video for a better look at the final assembly.

You can modify the Eagle files posted below or send the pre-configured Gerber files directly to http://oshpark.com/ or your preferred fabricator to get some PCBs of your own.
Link to Eagle and Gerber Files


I drew up the board upside down for no particular reason.
Blue is the outside and red is the inside.

Simple Chemistry

Inspired by THIS

This is some dangerous stuff.
It will mess you up. 

Zn + 2 HCl        > ZnCl2 + H2


This giant masonry blade has been sitting around Freeside forever:

Rust and dust are indicators of abandonment.
Please make use of the rusty and dusty.
Note the diamond tipped edge

Let's make a giant scythe for my Halloween costume!! 
(Never too early to plan)

Thingiverse: Anatomic Human Foot

Freesider's are evermore professional printistas of sorts.  As our sprints are ramping up, there seems to be a growing interest in "organic modeling".  Things often found in nature fall into this category for CAD artists.

Here is a recent Thingiverse upload, which was made from some very simple modeling techniques in Newtek's Lighwave 3D application.  A little goes a very long way, indeed.

per Thingiverse.com:
There are 26 proper bones in the human foot; 28 if you consider the sesamoids of the 1st metatarsal phalangeal joint complex. That's over 25% of your body's total musculo-skeletal anatomy, hitting the ground every time you go for a walk or run! Quite impressive, really.

Read More:

This anatomic foot model was designed in Newtek's Lightwave 3D, as part of the podcast @ YouTube.com/DrGlassDPM

Anatomic study models can be quite expensive, search.anatomywarehouse.com/search?keywords=foot&x=0&y=0 so I wanted to share my printable version with the Thingiverse crowd and give a big shout out to Freeside Atlanta's Hackerspace!


I've included the individual bones with a straightforward naming convention. These parts will be replaced, as I continue to add more detail and such; for now, enjoy!

Additionally, there are FootBones.stl and FootSkin.stl, for those of you Duel Extruding.

Otherwise, I'd be impressed to see some of the techniques towards printing this and having a clean separation from support material. This (and deriviatives thereof) will hopefully rival things like: molded study models search.anatomywarehouse.com/search?keywords=foot&x=0&y=0