Senior Design

20130428_204455For my senior design I wanted to incorporate MEMS sensors and show off how awesome they are. The immediate project that came to mind was a segway style robot, or a quad copter. I mentioned these ideas to my mentor (Dr. Kocanda), but he suggested not to do those projects since they pop up fairly regularly. I recruited two others and we got to it!

So we tried to come up with some creative content and thought it would be a great idea to stabilize a vehicle with as few sensors as possible and incorporate a gyroscope. In the end we had two sensors: a gyroscope and a wheel encoder. We also needed the angle of the front wheels, but we assumed the steering servo would maintain whatever angle we were sending it, so that really makes it three inputs.flow diagram

The control system will try to stabilize the vehicle by compensating the steering and reducing throttle. In the video below I maintained a fairly constant throttle and just occasionally made minor adjustments. My steering input is displayed, and you can see the steering output – see video intro.

The hardware we went with was the adafruit boarduino for the microcontroller, parallax gyroscope module available at radioshack, two xbees – one serving as serial/programmer and the other as a kill switch for the inevitable times when something goes wrong and it takes off uncontrollably =P We were able to wirelessly tune and graph everything in real time without a restart. We could also wirelessly (and reliably) reprogram the arduino. For the vehicle we purchased an RC drift car from hobbytown usa.

A very rushed project!

A very rushed project!

Results? Decent, not great. I think the slow analog steering servo was a problem. I also noticed that at high speeds even if the system appropriately responded, the car would still spin out. In the end it’s worth mentioning that the system is purely reactive.

We should have added a simple proactive system – have the max steering angle allowed a proportional function of speed. At high speeds the driver shouldn’t be allowed to try to turn on a dime.

The system was pretty rough, but look at the time line! Not much time to complete this project and we were all taking a full load of classes while involved in various other extracurriculars. All of the engineering senior designs do take part in a senior design competition and we did end up coming in second.

Breadboards work surprisingly well with vibration! =P

Breadboards work surprisingly well with vibration!

I’ll keep the blog post short, but more can be found in the reports below:

Vehicle Stabilization Presentation – #3.2 (ppt)

Final Report (pdf)

Bode Plot on an Oscillscope

intropicMaybe you’re learning about filters and want to see the how your filter responds in the 10Hz to 1MHz range. This guide will show you how to make a low frequency ‘spectrum analyzer with tracking generator’ using a few cheap modules and an oscilloscope — Based off of a video done by Dave Jones over at EEVBlog. Dave does a great job going into the theory, so check out the video if you want to see how it works! He will also show you how to set up the scope. Check out my video below for the reader’s digest version.

Some important notes

For the audio crowd — the vertical scale is still in volts, not decibels. There is also no information on phase shift.

Arduino math

Arduino math

Brief Theory

The circuit from this guide generates a sine wave and the frequency of this sine wave ramps up exponentially. This creates a logarithmic axis on the horizontal axis of your scope. The filter under test will then react differently as the frequency is ramped up. Finally everything will be displayed on the oscilloscope which is synced via the external trigger. The oscilloscope and the arduino will also need  the same time settings.

a

15Hz-10Khz sweep with simulation

a

15Hz-1Mhz sweep with simulation. marker at 50Khz (approx peak)

One major problem is that the oscilloscope’s horizontal axis markings aren’t going to be placed correctly all the time. To solve this the microcontroller will calculate where the axis bars should be and generate a 1ms pulse at 10Hz, 100Hz, 1000Hz, etc… The two screenshots show different generated axis and there are some simulations to compare results.

Hardware

For this project I used an arduino (breadboard friendly) to do the timing/math/markings, but the star of the show here is the AD9850 DDS sine wave generator. It’s easiest if you are using a breakout for the AD9850. Luckly they can be found on ebay for about 5$ with free shipping! This seems to be the breakout specs from the original creator — EIM377_AD9850 (pdf)

Schematic

Schematic, add some decoupling caps as in the next photo

The AD9850 also needs a buffer amplifier. I decided to use the TS922IN from adafruit as a unity gain amplifier. Many op amps will do the job just fine, but get one that doesn’t require a dual power supply and has a high current output. If you want to do any impedance matching or if your filter is low impedance, be sure to add an appropriate terminating resistor.

Wire everything up and get you scope hooked up!

Completed circuit

Completed circuit (with filter on the right)

Code

What a mess! I coded this pretty quick and fudged a few things =P You’ll want to jump down to sweepTime_mS and get ready to input the correct values — I’ll cover these in the video.

https://github.com/thefatmoop/bode

Why did I have a bunch of these DDS modules floating around? They had something to do with an LCR meter I built ;p — more on that hopefully soon!

Easy High Voltage

Arcing slightly over 1.5 inches! Videos at the end.

Maybe you want to make a Jacob’s ladder, or give your robot a flamethrower. This is a simple guide on how to make high voltage from 12v capable of arcing over an inch! Not only that, but my guide will also show how do this in a way which won’t break down, and it’s completely solid state! I’m not going to dive into frequency response or the concepts behind a flyback and why it uses a ferrite core. There needs to be a high frequency (~20khz) square wave signal controlling the driver, and I’ll be using an Arduino. If you don’t want to use an Arduino, then use a 555 timer or any other micro controller.

Note: if you already have a flyback transformer removed and know how to be safe with high voltage, then skip to “The Build Plan:” This post is a tad long =/

The project will be designed around a transformer. A high voltage transformer needs to be selected, but where to start? There are a few household appliances which may be laying around the house that use a high voltage. Let’s look at a few:

A quick view of driver circuit.

Selecting transformer:

Microwave Transformer:

  • Pros: High current, easy 60hz, designed for high voltage, 2nd winding usually isolated
  • cons: Weighs A LOT!, it’s huge, and it only takes 120V to about 2-6kV

Standard Transformer with high secondary to primary turn ratio:

  • Pros: Usually small, easy 60hz, easy to find, cheap.
  • Cons: It’s not designed for high voltage, expect rapid insulation deterioration.

CRT Television/computer monitor flyback transformer:

  • Pros: Fairly small, light, designed for 15-50kV, easy to add a new primary, usually outputs DC!
  • Cons: complicated pin out and overall hard to reverse engineer, High frequency 10+kHz.

Neon transformer/oil burner transformer:

  • Pros: fairly ‘safe’, designed for 15-50Kv, designed to run/last a long time, usually easy 60Hz.
  • Cons: requires 120V, hard to modify (often inside a metal can), high current dangerous output.

Xray transformer/’Pole Pig’:

  • Pros: MONSTROUS voltage/power, designed to run/last a long time, usually easy 60Hz.
  • Cons: Unless you’re a mad scientist, you probably don’t have one lying around the house. Good luck finding one cheap, huge size/weight, and you’ll kill yourself.

Listed above are some of the options that immediately come to mind. Sometimes the transformers in a laptop’s back light is an option, but they don’t tend to last long when operating in the 10+kV range. Looking at the pros and cons of various transformers, I decided to go along with a computer monitor flyback transformer. I don’t know the pinout and I’m guessing the flyback’s primaries are designed for higher voltages, not the 12V we want to use. Let’s add a new primary to simplify things.

Removing the flyback:

If you’re a reader who wants to actually do this on your own here’s the rules for safety. If you don’t want to read, here’s a good video guide on how discharge: http://www.youtube.com/watch?v=bDAiLtTDuf4

  1. Unplug the monitor and make sure it is not touching anything metal or conductive — Glass face down.
  2. Most importantly only use one hand, preferably your right, when touching ANYTHING! NEVER use both hands, so if you were to get shocked the electricity wouldn’t travel from one hand to the other. If electricity went from your right hand to your feet, your heart *should* not have too much current running through it.
  3. Stand on something plastic at least two inches thick and don’t touch anything metal or conductive.
  4. Common insulators will fail at these voltages. Treat all wiring as if there is no insulation on it.
  5. Wear safety glasses, ear protection, and a thick long sleeve shirt. This is a large glass tube with a vacuum inside. If it popped there may be shrapnel. The front is very thick and extremely safe, but the tube is not designed to be safe at the back end.
  6. Don’t do this if you’re using any sort of electronic life sustaining gear: pacemaker, insulin injector. Find someone else dumb enough to do it for you
  7. Understand that you’re doing this at your own risk, and I don’t guarantee safety. I will not be liable for any computer/equipment damage or injury/death. I’ve been shocked by high voltage capacitors in the past and probably would not be here right now if I didn’t follow the rules above. Do not shock yourself even in nonlethal ways! you can still do nerve damage just shocking your hand!

The CRT monitor has two main high voltage capacitors: the flyback’s internal capacitor, and the glass tube itself acts like a capacitor. When you open the monitor there will be bare — no insulation — grounding wire running around the perimeter of the glass tube (near the screen viewing side), and the frame for the electronic boards should be metal too. Get some wires with alligator clamps at the ends and connect the tube frame’s bare ground wire and the electronic board’s frame. Now get a third alligator wire and clamp it to the grounded frame, and the other end to a flat head screwdriver. This screwdriver should have a thick plastic grip without any cracks! Hold the plastic screwdriver by the plastic end — keep away from anything metal — and wobble it under the suction cup electrode on the glass tube. You will eventually hit metal, if the monitor was recently on, possibly hear an electrical pop. Put down the screwdriver and pinch the back of the suction cup and pull it off. Remember to do this with a hand tied behind your back. Once it’s off, touch the metal again with the screw driver and then connect the frame grounding alligator wire to the metal electrode. Now prod around the circuit board with another wire connected to the frame’s ground to make sure nothing else is charged. After you feel as though you’ve poked the poor motherboard enough, congrats! it’s *hopefully* discharged! Now cut all the wires connecting the motherboard to the monitor, and I suggest you tie a frame ground to the pliers. Wriggle the motherboard out of the monitor and close up the monitor with just the glass tube inside and carry it to the trash.

So here we can see part of the motherboard for the monitor. The big black box front and center is the flyback transformer, as you probably guessed.

where to cut the PCB with a pliers

I find it easier to get some heavy duty pliers and cut around the transformer. Once the transformer is out on it’s own little PCB section, try to cut sections in between the pins. The PCB will tend to crack, but we can use this to our advantage.

Once there are little PCB islands with only 1 or 2 transformer pins, de solder the sections.

The build plan:

  1. Wire the new primary coil
  2. design a circuit to drive our new primary coil
  3. write the software for the micro controller managing everything
  4. test it! (safely)

Wiring a new primary coil:

This is usually very easy and you can start off with some thin wire just to test the transformer and driving circuit. The ferrite core is often exposed quite a bit and easy to wrap a new coil around. I wrapped a thin layer of masking tape, then a layer of electrical tape. I then used four layers of copper tape normally used for stained glass, and I was sure to solder the ends together.

Image from Wikipedia

Why did I use copper tape? Mainly due to the skin effect. Electricity tends to prefer the surface of a conductor at higher frequencies. This is why a Tesla coil operating around 1Mhz will mainly burn and not electrocute. This is also why some high frequency lines are pipes lacking any sort of core!

even a quick wiring works, but gets hot!

older non rectified flyback

Image from Wikipedia

I looked over the equations and constants used and they agree with my physics book: Essential University Physics by Wolfson Volume 2. It’s also wise to check an ensure that graphs match up with the equations when looking at questionable online sources, which in this case, the graph and equation did and were from Wikipedia.

That pin is a capacitor connected to the red high voltage output

What a nice primary! A little hot glue to hold it in place.

Designing the circuit:

There are many different ways to build a flyback driver. Mine uses a micro controller, in this case an Arduino, and a high power N channel MOSFET. This makes the circuit extremely simple to build and only has a few components. We’re going to be running this circuit at around 20kHz with a lot of current. To make things simple I’ll be using a Mosfet Driver, and this will allow us to easily achieve 12v gate-source voltage differential to minimize drain-source resistance, and the driver will quickly charge and discharge the gate-source capacitance, since it’s a high current half bridge.

Mosfets I’ve had great luck with:

  • IRFP260N – N Mosfet, buy at jameco.com (best for this project)
  • RFP30N06LE – N Mosfet, sparkfun.com — Will function decently without a Mosfet driver

Mosfet Driver:

For a larger list, please visit my Guide to the MOSFET!

  • MIC4422 -Driver, jameco.com discontinued, type “MOSFET driver” into jameco’s search. Farnell carries it!
  • TC4420 – Has the same pinout as the MIC4422 and features great ESD protection. A direct replacement for the MIC4422.

driver schematic (click to enlarge)

Note: the ground of the Arduino and the driver circuit are also connected.

minimum layout on breadboard. Large capacitor on 12v line

Now for anyone experienced with Mosfets, you’ll see I’m adding capacitors where they really shouldn’t be located. This will decrease performance ever so slightly, but from experience, will help protect the Mosfet and the driver. You may also want to wrap the connected ground and signal coming from Arduino around a small choke too.

completed circuit board with a small heatsink

entire circuit

Test Code:

This will slowly increase frequency. Voltage may be measured by the arcing distance. Use an old computer for this or increase delay time in setup(); which will give you time to unplug your computer from the Arduino. If you need to see the frequency, use an LCD screen for the Arduino. I haven’t had issues with this, but I wouldn’t recommend using an expensive computer for this project! Notice how I’m using a cheap netbook running from the battery.

Frequency sweep (pdf)

Final Code:

Once you’ve found a good frequency, just use the tone generating function.

flyback driver program (pdf)

Remember that your flyback transformer contains internal capacitors and needs to be discharged after use!

Word of Advice: Pulsing this circuit tends to have an EMP effect. If the Arduino crashes, it’s usually right when it was setting the registers/timers to output the signal. The computer on the Arduino will crash, but the registers may continue to output the signal which drives the flyback. Be careful of this! Components may over heat! The low voltage side may gain a net charge too which may shock you a bit when touching it. From experience this shock is usually mild, but you may want to earth ground everything if you’re worried… If the output voltage isn’t very high, try reversing the polarity of the primary coil since the transformer has an internal high voltage diode.

Want to measure the voltage? This is a tad bit difficult since the flyback’s output is extremely noisy. I would suggest building a voltage divider with 5 or so 10Mohm resistors in series and a 10k connected to ground. Have the voltage divider output connected to a capacitor. Run the flyback and then when it’s off measure the voltage on the capacitor to calculate the flyback voltage.

Some terribad quality videos!