## Bode Plot on an Oscillscope

Maybe 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

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.

15Hz-10Khz sweep with simulation

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, 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 (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.

## Linear resistive divider for the ADC

Simulation of changing -24v to 24v into ~ 0 to 5v.

This is a topic that’s very simple, but I’ve seen individuals do it in ways that are really over complicated. My example will show how to measure from -24v to 24v using a 10bit Analog Digital Converter (ADC) with an analog reference of 5v. The micro controller for this example will be an Arduino since it’s easy to get up and running. If you are having issues with selecting resistor values for your situation, leave a comment and I’ll help you out!

Design and deriving the equation:

Circuit and deriving the equations.

This is a circuit that’s basically an addition to the simple voltage divider which gives one the ability to measure high voltage ranges using an ADC with limited voltage ranges. I’m going to be using a voltage divider that starts out at half the Vdc, which is 2.5v for the Arduino’s 5V power. From there I’m going to use a higher valued resistor to pull the 2.5v up to nearly 5v at it’s peak positive voltage, and down to 0v for its minimum negative voltage. If you wanted to measure just negative voltages then get rid of Rc (use infinity in the equation).

Equations required with explanation.

For deriving the equation, I just used nodal analysis. As you can see there is no calculus or anything very math intensive, but there are some variables. This isn’t a guide on circuit analysis, but if you need some tutorials on signal analysis look around youtube or try the book – Schaum’s Outline of Basic Circuit Analysis. Just as a warning there are a similar methods of doing nodal/mesh analysis that will get different equations but yield the same final equation.

Note: Vout is the output of the resistive divider, which will be what’s connected to the Arduino’s analog input (ADC). Vout should only go from 0-5v. Vac is the input to the overall circuit which may vary from positive to negative voltages. Vout may be found by using 5*(double)analogRead(pin)/1024.

Usage notes:

This isn’t a volt meter! If you build it and you’re not measuring a voltage, you’ll notice that it reports a few volts although nothing is connected. Connect Vac to Ground and you should get close to zero volts. As you can see the example above is fairly low impedance, but you can use higher resistors.

The two resistors standing up are both 10k. Two 10k resistors in parallel are equivalent to 5k. Red wire running off of picture is Vac and black is ground.

As for problems: the only thing I can think of is if the ADC wasn’t giving off good readings. If you’re measuring something that’s time critical or behaves sinusoidally, don’t put any capacitors on Vout since this will do a phase shift on Vout. If you’re worried about voltage spikes then you could use two  zener diodes facing oppositely. Also remember that in this example the voltage spread is over 24*2 = 48 volts, so with a 10bit ADC that’s 48/1024 ~ .5 volt increments.

Example code and material:

Voltage equations from above (pdf)

Arduino example program (pdf)

I was going to use this for a 3 phase triac driver with simple pwm. I needed a zero volt detector on one phase which would allow me to calculate the other phases and trigger the triacs at the right time. Originally I was going to sample the voltage with the ADC and look for about 2.5v coming to the ADC. I ended up using a simple voltage divider and a comparator which is definitely a better route! Now you can measure negative voltages with your ADC or Arduino!

## Standard Deviation and Moving Average

Recently my neighbor paid me to build a key less entry system for his dorm room. I decided to go the economical route and use a button/potentiometer that sits outside the door and an Arduino on the inside that controls a servo connected to the lock. For my room, I thought it would be interesting to use a Ping))) ultrasonic distance sensor instead of the potentiometer and lose the button.

The Ping))) sensor kept taking readings while my hand was moving. In order to fix this I decided use a Moving Average filter, then calculate the Standard Deviation of the values currently included in the M.A. filter. When my hand is still, the Standard Deviation will become very small.

Example code:

M.A._and_S.D.(pdf)- “storeValue(variable);” is how to enter data into the array, then call M.A. and S.D.

Not much of a circuit required! Arduino's regulator also powers Ping))). Servo has it's own 5v regulator... needs capacitors

pingDoorLocker(pdf) – As you can see, this program blew up a little…

I tried to make the M.A. and S.D. code very easy to follow. Some things could have been combined in the S.D. and Variance method, but to the beginner what I wrote above is probably easier to understand since it follows the equations. As for the pingDoorLocker – I threw that code together very quickly.

Follow up notes: That was probably the worst way to do this project… I thought of a few ways how to write the program that would chop the code WAY down, but this is an example about using M.A. and S.D.! Pretty bad use of a M.A. filter if you ask me!

His door unlocker.

Since I did put a few hours into building my neighbor’s door opener, here’s an image of it! He didn’t want numbers on the potentiometer dial, so I made the LED flash the number that is currently being entered.

Code for his door opener (pdf) – leave a comment if you want schematics/code on rapid share since pdf loses tabs.

## A Beginner’s Guide to the MOSFET

IRFP260N image from warf.com. Pins are Gate, Drain, Source from left to right.

If you need to switch high current and or high voltage loads with a micro controller you’ll need to use some type of transistor. I’m going to be covering how to use a MOSFET since it’s a better option for high power loads. This guide will be just a brief introduction that will discuss how to drive a MOSFET in a simple manner with the ultimate goal of making it act like an ideal switch. I’m not going to get into any of the topics such as Triode region, Saturation, Threshold Voltage, etc…

Refer to the N or P channel basic wiring schematics and remember the three pins: Gate, Drain, and Source. When I mention something like Gate-Source potential difference, I’m talking about the difference in voltage between the two pins.

Thank you Farnell.com for supplying many of the parts that will be part of this review/guide. I wanted to also mention that all parts performed great!

N channel MOSFET

How to think of a MOSFET:

A MOSFET may be thought of as a variable resistor whose Drain-Source resistance (typically Rds) is a function of the voltage difference on the Gate-Source pins. If there is no potential difference between the Gate-Source, then the Drain-Source resistance is very high and may be thought of as an open switch — so no current may flow through the Drain-Source pins. When there is a large Gate-Source potential difference, the Drain-Source resistance is very low and may be thought of as a closed switch — current may flow through the Drain-Source pins.

P channel MOSFET

N channel – For an N channel MOSFET, the source is connected to ground. If we want to let current flow, we can easily raise the voltage on the gate allowing current to flow. If no current is to flow, the gate pin should be grounded.

P channel – Looking at the P channel MOSFET, the source is connected to the power rail V2. In order to allow current to flow the Gate needs to be pulled to ground. To stop the current flow, the gate needs to be pulled to V2. A potential problem is if V2 is a very high voltage it can be difficult raising the gate to the V2 voltage. Not only that, but the MOSFET has limitations on the Gate-Source potential difference. Also note that logic is inverted for a P type MOSFET!

Drain-Source resistance – Ideally we want Drain-Source resistance to be very high when no current is flowing, and very low when current is flowing. The main issue using MOSFETs with micro controllers is that the MOSFET may need 10-15 Gate-Source potential difference to get near its lowest Drain-Source resistance, but the microcontroller may run on 5v or 3.3v. Some sort of MOSFET driver is required.

IRFP260N gate capacitance

IRFP260N current curves.

Gate-Source Capacitance – There is also a capacitance on the Gate-Source pins which prevents the MOSFET from switching states quickly. In order to quickly change voltage on internal capacitance, the MOSFET driver needs to be high current. It needs to actively charge (source) and discharge (sink) the capacitor too (for N channel)!

MOSFET Drivers:

A  half bridge is capable of doing what was mentioned above! There are many ICs available which can do this. Here’s a list of just a few that I’ve tested. Schematics are also provided!

Fet driver is a Half Bridge

• MIC4422YN – Max of 18v, 9Amps peak, 2 Amps continuous.
• MCP1407 – Max of 18v, 6Amps peak, 1.3 Amps continuous.
• UCC27424  – Can drive two MOSFETs, Max of 15v, 4Amps typical.

All of these drivers performed nearly identically (~20ns rise, ~30ns fall). Note that although these can be used for more than just MOSFET drivers, these chips do not have much heat dissipation capabilities!

MOSFETs I’ve tested:

It was originally part of the plan to get some data about these guys, but I have been very busy with school. The MOSFETs have plenty of graphs inside the datasheets!

P MOSFET body diode causing unintentional current to flow.

UCC27424

MIC4422YN and MCP1407

• IRFP260N – 200v, 50A, N channel.
• IRF3703PBF – 30v, 210A, N channel. Misleading ratings! Read my Datasheet Notes at end.
• RFP30N06LE – 60v, 30A, N channel.
• FQP27P06– 60V, 27A, P channel.

An Important Reminder – Don’t forget that typically the heat sink on the back of a mosfet is connected to the Drain! If you mount multiple MOSFETs on a heat sink, the MOSFET must be electrically isolated from the heat sink! It’s good practice to isolate regardless in case the heat sink is bolted to a grounding frame.

Body Diode – Mosfets also have an internal diode which may allow current to flow unintentionally (see example).  The body diode will also limit switching speed. This won’t be a concern if you’re operating below 1mhz.

Great cheat sheet, includes MOSFETS. – akafugu.jp

Side note about Gate – Source voltage: MOSFET Gates can go above or under the source voltage. So for an N channel mosfet with a source at 0v, a -10v on the gate would allow current to flow. Verify this with your MOSFET’s datasheet!

Schematic Diode – If the load is somewhat inductive, you’ll need to put a diode to discharge the inductor. If you want more detail, look at the International Rectifier pdf at the end. My “Intro to the Boost Converter” also talks about the nature of inductors when quickly switched on/off.

Gate-Source ringing – There are a few methods that I’ve heard of / seen to limit ringing on the gate. Ringing decreases efficiency, and if excessive, can damage the MOSFET. You can use a zener and resistor in series with the zener’s cathode connected to gate, anode connected to source for N channel. P channel will have the zener flipped. Add a resistor to limit current going through the zener, and watch those breakdown voltages! There is also another diode you could look into called the TVS diode.

Datasheet notes – If a part has too good to be true ratings, check the application notes carefully. For example, the IRF3703PBF claims 210 Amps continuous drain current at 25ºC. We don’t have to do any thermal calculations to know 220 Amps is a TON of current for a TO-220 package! A closer look on page 8, note 6 reveals that it can pass a maximum of 75 Amps continuously due to the package thermal limitations. For future advice: IRF is pretty good at giving accurate ratings, but you have to look for things like this. Now in the real world lots of testing reveals if your design is bad, or if you’re working with a dishonest or incompetent supplier with inaccurate/misleading data sheets.

UCC27424, MIC4422YN, MCP1407

Arduino Mosfet Example

Without the driver, the Gate takes longer to charge, and it peaks at 5v. Excessive ringing due to no gate ringing suppression.

International Rectifier MOSFET application note

High speed MOSFET driving guide

## Boost Converter Intro with Arduino

Driving some neon lights.

Let’s say that you’re trying to drive a few Nixie clock tubes, or you want to make a strobe light. A variable high voltage DC power supply from 50-200+ volts may be required. Transformers are terrific, but difficult to find the right one and a pain to wind. Why not use a boost converter? They’re easy and don’t necessarily require a guru for basic operation. This guide is meant for the individual who wants to build a simple boost converter, and may need refreshing on the theory. It will also help determine what parts will be required.

Is this guide right for you?

Basic inductor and boost converter equations. D is the duty (0 fully off, 1 fully on)

Boost converters typically get less efficient as they increase voltage out/voltage in ratio. If 100+ volts are required from a 12v source, the load will need to be a fairly high impedance. Don’t expect to run a 60watt light bulb from this boost converter! If precision is required, you may want a dedicated boost converter IC which will do the job better. This guide is intended for educational purposes.

Microcontroller:

I’m going to be using, oh you guessed it — an Arduino for this example! As usual any micro controller will do (3.3v or 5v), but this project requires analog voltage reading. If your favorite micro controller doesn’t have an ADC (Analog to Digital Converter), buy one or you can make your own!

Theory:

Boost converters work by taking advantage of a fundamental property of inductors: inductors use stored energy to maintain current. The key is that the inductor will vary voltage to maintain whatever current was present before the system (circuit) changed. Once the power supply is removed from a charged inductor, it may be easier to think of the inductor as an electromotive force rather than a passive component. Refer to the images to see it a bit more illustrated. Some of the key inductor equations are also listed.

Basic overview. Original image from Wikipedia.

On state – Current can flow through the closed switch. There is a potential difference across the inductor. The fundamental property of inductors tells us that the inductor resists change in current. Initially the inductor current is near zero when the switch closes, but current will ramp up quickly as the inductor charges till the circuit goes into the Off state.

Off state – Current no longer flows through the switch. The inductor tries to maintain current, and it acts as a current source which means that voltage can sway, in this case it flips polarity due to discharge. The inductor voltage will immediately jump up to the voltage of C3 and maintain original current till the potential energy of the inductor is transferred to the capacitor. As the capacitor charges, the inductor will continue to jump up the the capacitor’s voltage, even if it’s much greater than Vin.

The Circuit:

Schematic, C1, C2 are 12V. C3, FET1, and D1 must be rated for high voltage output. Arduino shares ground with this circuit. ~12v means around 12v, that’s not a negative.

The mosfet(FET1), diode (D1), and capacitor (C3) will need to be rated for voltages greater than the peak voltage. The mosfet and diode will need to have a current rating greater than the current peak — see equations. The more capacitance the better, and a ballpark number from the capacitor equation isn’t a bad idea. When it comes to duty, I would suggest not going over a .9 (230 duty for Arduino pwm) duty. If you already have a diode you want to use, then use the diode’s max current as the peak current and solve for the duty. This will be the maximum duty without damaging the diode.

Important: Mosfet Driver for the IRFP260N is required. This mosfet’s Gate-Source pins have a capacitor in parallel (downside on all mosfets). This capacitance is significant and will tend to resonate with the Arduino’s signal. This may damage the Arduino, and will dramatically reduce mosfet efficiency.

Boost converter circuit.

Frequency: My Arduino sample code will be using f = 31250 Hz pwm. It seems like any higher frequency results in a less efficient system, and 31250 hz is inaudible. This will also be using phase correct pwm – more on this in section 17.7.4 atmega328 datasheet.

Feedback: There are calculations to estimate the high voltage output, but in reality there are many factors which affect this output. I found that a feedback system works better. This feedback will output 5v when C3 is at 255 volts, and output 3.3v at 168V. If the feedback voltage is too high for the ADC, adjust the voltage divider! Look at the TI pdf at the bottom (pdf pg 9).

Selecting parts:

Here are the key components that may need to be purchased. I suggest buying from Jameco or Digikey if purchasing in the states.:

1. Capacitor – There will need to be a high voltage capacitor – larger the better. I used a 330uF 200V capacitor that I found in an old computer Power Supply Unit. Laptop PSU (usually), computer PSU, and CRT monitors will have decent sized high voltage capacitors. Find an old CRT monitor to dig into! Check myEasy High Voltageguide to safely discharge a CRT monitor. Buy some capacitors here, or here!
2. Diode – A regular 1N4007, but it’s not recommended and will probably fail! A Schottky diode or some other ultra fast recovery diode is much better. There are some nice diodes in CRT monitors. I’ve used the RL4Z, 5JUZ47, 5VUZ47, all scavenged from CRT monitors. Buy some here, these should work too.
3.  N channel mosfet – IRFP260N available here or here, rated for 200v, 49A.
4. Neon Light. With DC, the ground is what lights up!

Mosfet Driver – I’ll be using the MIC4422YN. The MCP1407  or the UCC27424P should work too. If using more than 12 volts, watch the voltage requirements of these guys.

5. Inductor – Buy or make your own inductor. I’ve used a 120uH, 871uH, 1000uH, and a 5000uH inductor with this circuit. All work fine. Larger inductors store more energy in its inductance which requires less current. The main drawback is that Equivalent Series Resistance (ESR) is higher with inductors that have many windings. When buying an inductor, watch the current rating!

Code for Arduino:

Simple code: boost code

PID code (Arduino pid library 1.0.1): boost code PID

Download .pde files from Rapidshare (down) – I’ll eventually put everything up on github. I know those pdfs are very inconvenient

Other Notes:

With boost converters, core saturation can be an issue with some designs. Remember that this design charges up a capacitor to 200V! This is dangerous and could be deadly if misused! The inductor is a current source when it’s discharging. Beginners are unfamiliar with current sources so I avoided explaining it like that.

Here’s an example of a dedicated buck/boost converter IC from sparkfun!

Handy References:

It’s always difficult knowing how in depth to go in the guides. My guide was written to get the nooblet up and on his feet. If this isn’t enough I’d suggest the links below. The TI boost guide really goes into detail.

TI boost guide (slva061.pdf)

## Easily measuring inductance with Arduino

bidirectional analog to digital - using LM741 as comparator.

So you need to make or measure an inductor, but you don’t have an oscilloscope or signal generator? Measuring inductance with a handful of cheap common parts is certainly possible. I’ve verified this method is accurate with a scope from 80uH to 30,000uH, but it should work for inductors a bit smaller or much larger. There are some contingencies to keep in mind when it comes to measuring inductors — more on this in “Other Notes:

There are three components that you’ll probably have to buy, but they can be picked up at your local Radio\$hack: LM399 and two 1uF non polar capacitors – look at the schematic. If you don’t want to shop at radio\$hack, there is a list of products at the end that should work.

No Arduino?

There is 1 digital output and 1 digital input, so this will work with most micro controllers. The output works better with a high current and uses ~33mA at 5V. The only thing left is to measure the rising edge to falling edge time on a square wave. You may want to look at the code if you’re unsure about how to enter the equations, you too can measure inductance with a microcontroller!

LM741, LM339 comparison and a picture showing bell like behavior.

A short lesson on the theory:

An inductor in parallel with a capacitor is called an LC circuit, and it will electronically ring like a bell. Well regardless of the frequency or how hard a bell is struck, it will ring at it’s resonating frequency. We will electronically strike the LC bell, wait a bit to let things resonate, then take a measurement. There is some internal resistance so this is really an RLC circuit, and I’ll talk about this more in the math.

Now micro controllers are terrible at analyzing analog signals. The ATMEGA328 ADC is capable of sampling analog signals at 9600hz or .1ms, which is fast but no where near what this project requires. Let’s go ahead and use a chip specially designed for turning real world signals into basic digital signals: The LM339 comparator which switches faster than a normal LM741 op amp, but there will be a schematic for the LM741 too.

As soon as the voltage on the LC circuit becomes positive, the LM339 will be floating, which can be pulled high with a pull up resistor. When the voltage on the LC circuit becomes negative, the LM339 will pull its output to ground. I’ve noticed that the LM339 has a high capacitance on it’s output, which is why I used a low resistance pull up.

Math:

LC equations

Since our wave is a true sinusoidal wave, it spends equal time above zero volts and below zero volts. This means that the comparator will turn it into a square wave with a duty of 50%, and pulseIn(pin, HIGH, 5000); will measure the time in microseconds elapsed from rising edge to falling edge. This measurement can then be doubled to get the period and the inverse of the period is the frequency. Since the circuit is resonating, this frequency is the resonating frequency.

To the left are the equations where f is the resonating frequency, c is capacitance, and L is inductance. Solving for inductance will result in the last equation

Since this is an RLC circuit due to internal resistance, it won’t change any characteristics of the resonating frequency. The RLC will still resonate, but the amplitude will die out. With a low resistance the RLC will tend to latch onto the exact resonating frequency quicker. For you EE’s think of the frequency response of an RLC with low resistance versus high resistance.

Parts that should work:

review the circuit before buying anything. All resistors are 1/4 watt, but anything will work.

Using LM339 (works better at high frequency)

The Circuit:

Pick whichever circuit is better for you, but the one using the LM339 is better. Both the capacitors are 1uf metalized film, but anything that is non polar will work. It will need to be very close to 2 uF though. You can not use a capacitor that marks which connection is ground. One thing you may notice is that the LM741 is geared for analog computing. This means that it requires a negative voltage on it’s V- pin. If you don’t have a power supply that offers this, use two AA batteries to go 3v below ground as shown. The LM339 doesn’t need this and there is no problem inputting a negative voltage. Remember that the LC circuit will vary above and below ground. Here’s a picture of the breadboard.

Using the common LM741 op amp. D2 is a 1N4001 too.

Code:

Code for Arduino – With large inductors, you may need to increase the timeout on pulseIn() from 5000 to 10000. If you’re having issues with very small inductors – under 200uH – increase the delayMicroseconds() right before pulseIn() to a larger value ~500uS.

Other Notes:

Not accurate enough? If you look at the equation and you’ll see that the capacitor’s tolerance is key. Expect your results to be accurate within ~10% with a 10% tolerance capacitor. What does this mean? Let’s say you’re using a 10% tolerance capacitor, and the Arduino spits out that the inductor is 1000uH. Well this means that the inductor is in between 900uH and 1100uH. Think of a bell curve if you’ve taken a statistics class – most capacitors with 10% tolerance will be under 10%. (pdf)

If you require a very accurate measurement for a system running at a very high frequency, then this method is definitely not for you due to parasitic capacitance, which isn’t taken into account. This method uses low current to measure inductance, so saturation characteristics will be unavailable (measurements will be taken in an unsaturated state.) This won’t be an issue for most people.

There is this wonderful thing called permeability. Filling an inductor with certain materials changes the inductance without changing the coils. This is similar to mutual inductance in transformers. Ever notice how high frequency transformers are made with nearly non conductive ferrite, and 60hz transformers are made with an iron/steel?

Another method that doesn't work well with Arduino.

You could make a metal detector. Inductors that don’t have closed fields — not magnetically isolated — will change their inductance when something with a different permeability than air is near.

If you have access to fast sampling rates, you can use the method on the right too, but it will require a p type mosfet to really pump some current into the inductor and R1 less than an ohm or so, but greater than the equivalent series resistance of the inductor. This method will probably run into saturation issues if the sample isn’t taken quickly, but if you’re smart about it you should be able to get information about the saturation characteristics.

And there you have it! This is the most difficult part to build on a diy LCR meter.