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 »

First flight of the Hexacopter!



It's been a difficult journey, but we finally got the first flight of our DIY Drones Hexacopter. A special thank you goes out to the whole UAV team at Freeside Atlanta for donating their time, money, and resources to this project.

 Slade, who did several hours of last-mile troubleshooting to get the UAV in the air, is flying it by hand. Check out the video on Youtube, which shows us testing the pitch, yaw, and roll of the unit and finally getting flight. We were pretty surprised at how smoothly it flies.

Stay tuned, as we'll be setting up and configuring the UAV controls so that it can follow GPS waypoint flight paths. We're also going to be posting another video that explains how everything works, how we did the troubleshooting on the initial flight, and some new in-flight footage.

Constant Current Dummy Load - continued


Since the last installment, I've finalized the initial PCB design and sent it off to Seeedstudio for fabrication. I've never designed a through-hole (TH) construction board before but in general all the same rules apply to SMD and TH boards I believe.

200W 0.1Ω load
 
30W 1Ω load
10x10Ω 3W in ||
25 turn
trimmer pot
I changed up a few things during the PCB design phase of this project that I thought would be interesting to mention. I added a pair of trim pots to design. One trim pot reduces the maximum voltage going into the first op-amp stage. The second is the in the feedback loop of the first op amp stage. At maximum resistance, 3000Ω to GND (R2 of the voltage divider), with the 820Ω R1 (there for its role as a low pass filter in addition to the voltage divider), I should see a 27% voltage gain. Turned down to 0Ω, that pot creates a situation where the output is the high output voltage of the op-amp (essentially infinite gain). Something like 8V for the op-amp/input voltage I am using. Why did I bother to design a mechanism to adjust the highest voltage output across the load down to200mV and up to 8V? Well, so I could use a bunch of different load resistors with this circuit and not have to worry about lighting anything on fire with the knob after setting trimmers to their "final" value. I 0.1Ω load resistor is going to burn 10 times the current of a given voltage than a 1Ω resistor so it occurred to me that having a flexible system made a lot of sense. I got the trimmers on ebay for a quarter each, so while they are much more expensive than a normal resistor, they save me having to build a different board for each load resistor. You can trim it up for a given load within a minute with just a multimeter.



Basic MOSFET operating voltage graph
I also included to a switch so the user can switch between operating the main current MOSFET in the linear region (aka triode mode or ohmic region) or in the saturation region (aka active mode or fully enhanced). You can operate the MOSFET in the ohmic region by applying a relatively flat DC voltage on the MOSFET gate below the saturation voltage. The MOSFET behaves like a adjustable resistor in this mode. When operated in the saturation region (by putting high voltage on the gate) the MOSFET channel has its lowest possible resistance it has to offer but as a result you need to switch it on and off in order to limit the current. I hypothesize that the MOSFET will run cooler at a constant current in saturation mode then it will in the ohmic region but it remains to be tested. I decided to offer both options in the circuit because I figure both have their objective value. I show the difference on the scope in the video above.

In addition to these admittedly minor hardware revisions I also created the previously posted rotary encoder library so I could have both fine and course control over the output current. Might as well take full advantage of the digital circuitry, right?

The two holes labeled "LOAD" top center of the PCB rendering below are points you can use to measure the voltage across the load. That number, with a little basic Ohm's Law calculus, will tell you the current going through your load. It will be a useful point to pull data for an analog panel meter. The boards should be here within a couple weeks and then I'll build a couple up and post them up. I'll also bring one to Freeside to put on the shelf. It's always handy to have a precision load when doing electronics work.

I added the Freeside logo in copper on the top of the board.
It will be interesting to see how that looks in real life.

Arduino Rotary Encoder Library with Velocity Sense


While working on the constant current load project I found that while nice, the multiple turns required to turn up the power up was a little annoying when you just wanted to hurry up and get to a high value. The standard solution is to have a "fine" and "course" knob. Since I designed the input in the digital realm it seemed like software was the obvious solution. Why not sense the speed the user is turning the knob and extrapolate the pace of change based on that input. It seems intuitive to me. I implemented it as a little C++ library that you can drop into your arduino/libraries directory.

Here is the most trivial implementation of the library.
#include <RotaryEncoder.h>;
RotaryEncoder encoder(A0,A1,5,6,1000);
void setup()
{  
  Serial.begin(57600);
}
void loop()
{
  int enc = encoder.readEncoder();
  if(enc != 0) {
    Serial.println(enc);
  } 
  delayMicroseconds(5);
}

Inside the library, the code counts the number of the sequential clicks in one direction within less than the time constant you pass in when you instantiate the object. In the above example, the selected time constant is 1000µs (the 5th variable). If the user waits longer than that amount of time the counter resets. If the user changes direction the counter resets. To determine the return value I divide the counter by the 4th variable you pass in, 6 in this case, and then multiply that by 5 (the 3rd  variable) and return that value. Turning anti-clockwise is the same except that I make it negative (multiply value by -1). So, if you turn the knob 30 times in a clockwise direction I will return (30/6)*5 or 25. Bear in mind that 30 times doesn't mean 30 detents of the encoder. Each encoder is different. The ones I have in my drawer return 4 times per detent, YMMV.

The library is available here.

In order for this to work, you need to have clean reads of the encoder (or it will reset the counter). To do this effectively, you really need to "debouce" the switch. I've never been able to effectively do this in software. I use 10000pF capacitors between the A pin and GND and B pin GND. This makes the circuit very well protected from bad reads. Furthermore, you need to check the value more frequently than it can change otherwise the quadrature signal will become out of sync and you will not know what direction you are turning.

Tonight (July 14th, 2012): Chili fundraiser for the Offroad Wheelchair Project

The Off-Road Wheelchair is a device that will enable a person of limited mobility to experience the outdoors. Freeside Atlanta is interested in putting our engineering skills to the test, and showing the world we can create anything we put our minds to. We have the space, the tools, and the talented people to make this happen - we just need your help to purchase the materials and make this project a reality. The idea originated with Robin Beattie, who participates in regional Burning Man events, like the Alchemy Arts Festival here in Georgia. The festival takes place on a farm, with terrain features like gravel, light mud, paths with tree roots, and moderate changes in elevation. The Off-Road Wheelchair will be designed to traverse this environment, enabling Robin to get around in a place that would normally be closed off to her and others with limited mobility. Upon completion, the Off-Road Wheelchair designs and notes will be released under a Creative Commons (by-nc) license, which means that anyone can continue to contribute improvements on the basic design, so long as it remains for non-commercial purposes. The hope is that the Off-Road Wheelchair can be replicated at other regional Burning Man events, so that even more of the disability community can participate in this unique survivalist camping experience. This is our second fundraising round for the project. The first round of the project was at the Alchemy Arts Fundraiser, where we were the 3rd highest funded project of the evening, pulling in about a third of our requested project budget. This is a link to the Google Document describing the project, detailing the proposed budget, and outlining a few design ideas: https://docs.google.com/document/d/1ZLHe4XJtBqOgrQDVOkIZ0MtLGelBoQc-T4lL8dtgoAE/edit Our fundraiser will feature unique chili creations from the kitchen of Joy and Pain Cooking, plus possibly an auction of some kind, and possibly other fun surprises. Additionally, let me explain how the parking situation will work. This is Freeside Atlanta's page explaining how to get to the space: http://wiki.freesideatlanta.org/the-space The parking needs to happen towards the "back" of Freeside and the Metropolitan, so that everyone comes in through the rear garage doors. This is the marker called "Roll-up door access" in the embedded Google Map. Generally, in order to avoid a parking disaster, I recommended parking along the north and north-west part of the property. Please do not park in front of any garage doors (including Freeside's) as this puts you at risk of getting towed. Don't hesitate to email me if you need help getting there. You can email [masked] with the subject gatecode (one word). That will automatically reply with this month's gate code, if you need it. http://www.meetup.com/Freeside-Atlanta/events/70965732/

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);
    setDAC(val);
  }
  delayMicroseconds(50);
}

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);
    delay(del);
}

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!