Skip navigation

DIY Test Equipment

2 Posts authored by: shabaz Top Member

Introduction

Current measurement can be really awkward when working with circuits. Voltage measurements are (usually) straightforward, but when it comes to current measurements the story is different. One typical approach is to insert a known resistance by breaking the circuit, and then measuring the voltage across it. This is difficult if one end of the resistor is not at ground potential, because oscilloscope probes are (usually) designed with the ground leads all connected together, and it will damage things if the grounds of different channels on the oscilloscope are connected to different parts of the circuit.

 

This project describes a very sensitive home-made current probe that doesn’t require a known resistance to be inserted. It has not been fully characterized but the initial results are reasonably promising. It was tested at currents of the order of single-digit microamps up to 10mA (it can be assembled for higher current ranges if desired), and it functions from DC to around 20kHz, and is fully isolated.

drv425evm.jpg

 

It is based around a very exotic magnetic field sensor known as a fluxgate magnetometer. Ordinarily this is quite difficult to build due to the requirement for hard-to-find mu-metal and a mix of analog and digital electronics. However, Texas Instruments offers an entire fluxgate magnetometer-on-a-chipfluxgate magnetometer-on-a-chip and an evaluation boardevaluation board. With some effort it is possible to build a current sensor or probe with it. It makes a handy test tool for measuring current in a circuit, in a less intrusive way than normal.

 

What is a Fluxgate Magnetometer?

There are several ways to make magnetic field sensors, and the fluxgate magnetometer offers very impressive sensitivity. There are slightly different topologies of fluxgate magnetometers, but in a nutshell they consist of windings around a core. If we use a Lego wheel tyre to act as a pretend core then ‘Excitation’ and ‘Sense’ windings can be placed around it as shown in the photo (the windings are the yellow and green wires in the photo).

fluxgate-lego-annotated.jpg

 

If we consider the core to look like two semi-circular half cores each with half of the excitation winding on it then an AC signal of sufficient power is applied such that each half-core reaches saturation (i.e. the magnetic field cannot increase any further) in both directions alternately as the AC signal changes direction.

 

The other coil, the green sense coil, is wound around the outside like a wrapper to the entire thing. When the core is in saturation the magnetic field does not change, and therefore there is no voltage across the sense winding. In other words, a changing magnetic field is needed to induce a voltage in the sense winding. The clever bit occurs when there is an additional magnetic field present (either created locally with another winding, or any existing nearby magnetic field as shown in blue in the photo above). Because the two half cores have their excitation windings in opposite directions, ordinarily the magnetic fields cancel out. But in the presence of a magnetic field, when the AC excitation signal direction changes, one half core will exit out of saturation slightly sooner than the other half core, or slightly later than the other half core, depending on the direction of the additional magnetic field. When this occurs, there is no balancing out of the magnetic fields! And since the magnetic field is no longer zero, during this time that the field is changing, a signal is generated in the sense winding. It is an easy-to-detect signal because the asymmetry caused harmonics of the excitation signal frequency, and it can be detected using analog electronics.

 

The basic design can be modified by having yet another winding known as the Compensation coil and an amplifier to drive it such that it nulls out the external magnetic field. The output of the compensation coil therefore becomes the output of the fluxgate magnetometer.

 

Fluxgate magnetometers have exceptional sensitivity and can detect the earth’s magnetic field. Texas Instrument has several ICs that contain all the signal generation and signal processing required to construct a fluxgate magnetometer. There is also one IC in the range which even integrates the core inside the package. I decided to use that IC for this project. All I needed to worry about was how to generate the external magnetic field, and that is possible with an external winding.

 

The diagram here from TI’s website shows the internals of the IC. All of this is integrated into a tiny square 4x4mm package.

drv425-block-diag-c.png

 

Why build a Current Sensor? What is a Current Sensor? What types are there?

The voltage across two points is easy to measure with a voltmeter/multimeter. If the voltage is changing over time then an oscilloscope can be used too.

 

The current through a wire is harder to measure; it often entails breaking the wire and attaching an ammeter/multimeter set to measure current. If the current is changing over time then one way to observe this is to insert a fixed value resistor in series with the wire, so that a potential difference (voltage) is created across the resistor. The voltage will be directly proportional to the current flowing through the resistor, and so then the problem has been reduced to one of observing a voltage which is easy to do with an oscilloscope. However, by adding a resistor the circuit has been modified slightly. To minimise this, the resistor is usually chosen to have a very low value. But if the value is too low then the measured voltage will be very low too.

 

Another issue is that sometimes it is desirable to have a way of measuring current with isolation; this is especially necessary if it is desired to measure current through different parts of the circuit simultaneously using an oscilloscope (the probe ground connections are all connected together and to ground usually).

 

So, resistors as current sensors can have limitations. Another type of current sensor looks very much like a transformer. It can work very well but usually just for AC signals; a DC component is not detected because there is no change of flux and therefore no voltage induced in the secondary coil.

 

Yet another type of current sensor is based around a hall effect sensor which detects magnetic fields. It functions from DC to tens or hundreds of kHz. It is primarily used for measuring currents in the tens or hundreds of milliamps and upwards.

 

Like the hall effect based sensor. a fluxgate magnetometer has the capability to allow the creation of sensors for both AC and DC signals because it measures the magnetic field, not an induced current like a transformer does. Unlike a hall effect sensor, it can be extremely sensitive.

 

It is possible to purchase current probes for oscilloscopes that are based on the fluxgate magnetometer principle but they cost thousands of pounds/dollars. This project uses a similar principle but only works to a low frequency range of about DC to 30kHz. This could be useful for examining dynamic current consumption of parts of circuitry. It is no useful for examining many modern DC-DC converter circuits however because they operate at very high frequencies nowadays.

 

This project doesn’t really compare to a commercial current probe for an oscilloscope, because they will function to tens or hundreds of megahertz.

However, this project is far cheaper and still offers some benefits. It has isolation just like a commercial probe. The other main advantage is the very high sensitivity (around 800 volts per amp sensitivity with a simple circuit).

 

Building the Sensor

As mentioned the fluxgate magnetometer resides on a single chip, so there is no work to do there. It is in a 4x4mm surface mount package (QFN) which is awkward to work with however an evaluation board is available with it pre-soldered. I used that.

 

To construct the magnetic field, I used a ferrite core; some experimentation here could be useful, I used Amidon FT-50-43 in my tests but others could be used too. Several will need to be purchased because it is almost inevitable that they will be damaged at the next step, the yield is very low. A slot was cut into the core, so that the 4mm fluxgate magnetometer could be a snug fit. With hindsight I didn’t need to cut all the way into the core, just the thickness of the IC would have been sufficient. Anyway, attempting to cut or file the core will almost certainly result in it breaking apart unless lots of care is taken. I couldn’t find a perfect strategy, but 3D printer owners could construct a jig to precisely hold the core during the cutting operation.

 

Enamelled wire was wound around the core; I picked 40 turns as a ballpark to experiment at, and 0.2mm diameter wire fitted well. A bit of glue can secure the ends from unravelling. The resistance of the coil is about 0.4 ohms, but with slightly thicker wire (which would fit) the resistance can be reduced. 0.3mm diameter wire would halve the resistance for example.

ferrite-and-winding.jpg

 

Next, it needs to be secured to the fluxgate magnetometer board. Since I wanted to experiment, I just used blu-tack (temporary putty) for now instead of a permanent glue. Although it looks like it might function poorly with such a trivial attachment, the result is very stable. The measured current does not fluctuate.

core-on-sensor.jpg

 

Initial Tests

In use, the circuit would be broken at the point where the current needs to be measured, and the ends of the wound coil would be attached into the circuit. For the tests below, it was decided to use a resistor and a signal generator as the circuit under test. The circuit was broken and the current sensor was inserted in. The output of the current sensor went to an oscilloscope. I borrowed an oscilloscope from work for this, it needed the big gun Tektronix MDO3000 so that I could use some advanced math features and waveform processing capabilities to make my life easier.

 

So, this was the topology:

test-topology-a.png

 

Although there was no need to connect the signal source to the oscilloscope, it was connected to measure the voltage across the input resistor, to determine how much current was flowing through the current sensor input. For all the traces below, the important trace is the yellow trace which is the output from the current sensor. The blue input trace is just a reference to see what the input signal looked like. For these initial tests, even though the current sensor responds to DC, the oscilloscope was set to AC input because the output has an approximate 2.5V offset. The oscilloscope bandwidth was set to 20MHz for these tests.

 

All measurements are approximate, since this was just an experimental circuit.

 

100Hz, 1mA RMS Input current

As an initial test, a low frequency (100Hz) was used. From the measurements at the bottom of the ‘scope display you can see that the input signal was 100mV RMS and the output was around 43mV RMS. Since the input blue trace was measured across a 100 ohm resistor (approximately), that means the current through the resistor was 1mA RMS. The yellow trace shows that the current sensor therefore has a sensitivity of just over 40 volts per amp (i.e. 43mV divided by 1mA).

100Hz1mARMS.png

 

There is some noise on the output, but that could partially be due to the measurement since it is a low-level signal (43mV RMS) that is being observed.

 

To examine if the trace could be cleaned up a bit, averaging was turned on in the MDO3000. At a default averaging setting (16 or 32 averages, I need to double-check), this is what the output looked like:

100Hz1mARMS-averaged.png

 

So, for repetitive current draw at around 1mA RMS and at low frequency, it is possible to get a very clean output from this solution.

 

10kHz, 100uA RMS Input current

As a more extreme test, the frequency was increased to 10kHz, and the current was reduced to 100uA. At this level I would expect the output to be noisier, and perhaps observe some phase difference due to delay between input and output, and see a change in gain perhaps if the frequency response is not flat. Here is the observed result:

10kHz100uARMS.png

 

With averaging turned on, this was the result:

10kHz100uARMS-averaged.png

 

The output is about 3.9mV RMS which corresponds to a sensitivity of 39 volts per amp. So, compared with the 100Hz 1mA RMS traces earlier, this result shows that the frequency response is fairly flat to at least 10kHz. These measurements were not precise, these are just quick measurements to characterize the behaviour slightly.

 

Building an Amplifier

By now it was clear that the output benefits from an amplifier to make best use of it. I used an Analog Devices AD8226AD8226, assembled into a 20x gain instrumentation amplifier on a breadboard. There isn’t a lot to the circuit (I’ll draw it up if there is interest), but basically it consists of a 2.7k resistor to set the gain, and a couple of 100nF capacitors for supply decoupling. It was powered from +10V/-10V supplies, and the 2.5V reference output from the DRV425 board was used as the offset input to the amplifier. Some trimming would be useful to completely null out the 2.5V offset, but it was mostly nulled out, enough for me to switch to DC on the oscilloscope, for some of the tests below. For a real design the frequency response of the amplifier should be confirmed to be flat; I didn’t characterise it since it was just a quick hack on a plastic breadboard, and I could always circle back if I saw any anomaly in the subsequent tests.

sensor-and-amp.jpg

Tests with the Amplifier

The diagram here shows the test topology:

test-topology-with-amp.png

 

10kHz, 100uA RMS Input Current

With the amplifier connected, the output was clearer and of course larger. I was no longer in the noise with the oscilloscope gain having to be set at max. I use a 1kohm resistor for this test.

new-10kHz100uARMS - with-amp-1kohm.png

 

The voltage across the 1kohm resistor is about 100mV RMS according to the blue measurement on the oscilloscope, so that corresponds to 100uA RMS input current. The yellow output is about 81mV RMS which means the sensitivity with the amplifier is 800 volts per amp.

 

With averaging turned on, the trace was again cleaner as expected:

new-10kHz100uARMS-averaged - with-amp-1kohm.png

 

I kept the averaging on, and with a square wave input (again at 100kHz, 100uA RMS), the bandwidth effects were apparent, but still a very clean and usable result:

new-10kHz100uARMS-square-averaged - with-amp-100ohm.png

 

10kHz, 10uA RMS Input Current

Since the results at 100uA RMS were fairly clean and usable provided some averaging was possible, I was curious to see if 10uA RMS was usable too. This is quite a small current draw! To put it in perspective, an AA sized battery (2000mAH) should (self-discharge excluded for this hypothetical experiment) last for 16 years if attached to a circuit drawing 10uA! Here is the result with averaging turned on:

10kHz10uARMS-averaged256 - with-amp-1kohm.png

 

10kHz, 10mA RMS Input Current

Since the low-level current measurements were not bad, I wanted to explore higher current values. I switched off the averaging and with the input current set to 10mA, I needed to increase the amplifier supply voltage from +10V/-10V to +15V/-15V to stop clipping, and the result is shown here:

10kHz10mARMS-15V - with-amp-100ohm.png

 

Summary

For the limited 1000:1 range of around 10uA to 10mA the circuit functioned well. It allows for fully isolated measurements from DC to 10kHz or beyond. While it would be quite useless for DC-DC converter measurements, it could have uses in developing low power circuits where current in sleep periods needs to be monitored as well as current during wake-up periods.

fluxgate-topology-color.png

 

By experimenting with the winding and amplifier, different current ranges could be implemented. I’d love to see what uses others could find for such a current measurement device with these characteristics.

 

I really enjoyed experimenting with the fluxgate magnetometer; it is awesome to have such high sensitivity in a low-cost, tiny device. I'm hoping to try non-current-sensing applications with it too.

DIY Test Equipment

Monthly project competitions, chances to earn prizes, you decide project themes, your ideas, your projects, turn ideas into projects.

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Introduction

This project is to build a handheld test tool, to measure how fast things are turning. It could have uses in vehicle diagnostics, or for checking how fast a drill is spinning. It could also be used in math/physics experiments to see how fast wheels or other parts are revolving. Basically if any machine is spinning you can measure its rotational speed in revolutions per minute (RPM) or revolutions per second (Hz).

The short (60 second) video here shows it in action:

 

It is low-cost (<$25) and easy-to-build, so it could be ideal as a beginner 'learning electronics/learning to solder' project. All parts and details are published in this blog post.

tach-top-view-switched-on.jpg

 

How does it work?

The principle is really simple; an infrared LED shines light on the target object. Reflections get sensed by a single photodiode 'eye'. Provided there is a reflective portion of the target object and a non-reflective portion (as an example, a piece of white tape could be stuck on a dark colored object, or a piece of black tape on a light colored object) then the reflected light occurs in pulses directly related to the number of revolutions per minute. The pulses are counted by a microcontroller every second and shown on a LCD display.

tach-opto-view.jpg

 

Working with the Microcontroller

This project uses a Texas Instruments MSP430 series microcontrollerMSP430 series microcontroller. A microcontroller in a nutshell is a computer-on-a-chip. it contains a microprocessor, memory, storage (often in the form of Flash memory) and lots of input/output (I/O) pins. Software is written and compiled/built into an executable file on a PC, and then programmed into the Flash memory.

In order to program the microcontroller integrated circuit (IC), a cheap development board development board is used. It has a 20-pin DIP socket so it is perfect for plugging in a microcontroller, programming it, removing it and then fitting it into your own projects.

msp-exp430g2-dev-board.jpg

 

To get started, plug in the development board into the PC using the supplied USB cable. Next, google ‘CCS Cloud’ and register at the TI website and the web browser will show a development environment. All coding and compiling can be done in the web browser, and there is no need to download and install any development software.

Go to File->New CCS Project and give the project any name (e.g. tachometer) and for the Device field select MSP430Gxxx Family and MSP430G2553.

ccs-step1.png

 

You’ll see that the CCS Cloud environment has created a file for you called main.c and it has a basic main function already inside in the editor pane. It will look like this:

ccs-step2.png

 

As a test, click File->Save and then click on the Hammer icon which is used to build the code into an executable file. The text in the Output pane will indicate Finished building: tachometer.This proves that the compiler is functioning. In order to download the code into the microcontroller plugged on the development board, all you need to do is click on the Run icon. The first time you do this it may download and install a little helper program to perform the transfer, and subsequently you don’t need to install anything to the PC.

ccs-step3.png

 

The program doesn’t do anything, so you may wish to experiment and blink the LED on the development board. To do this, type the following code into the Editor pane:

#include <msp430.h>

#define LED1_ON P1OUT |= BIT0
#define LED1_OFF P1OUT &= ~BIT0

/*
* main.c
*/
int main(void) {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
  P1DIR |= BIT0;

  while(1)
  {
     LED1_ON;
     _delay_cycles(60000);
     LED1_OFF;
     _delay_cycles(30000);
  }

  return 0;
}

 

It should look like this:

ccs-step4.png

 

Select File->Save then click the Hammer icon, confirm the Output pane successfully says Finished building: tachometer.hex, and then click the Run icon.

 

After a short pause the code gets transferred into the development board microcontroller, and the red LED should flash rapidly as the code was written to do. The executable file is written into non-volatile Flash memory, so if you unplug the USB cable and then re-insert it, the LED will start flashing again.

 

Now that hopefully you are comfortable with writing code and building it and installing it onto the microcontroller, the tachometer code can be installed. Go to github and copy the code there and paste it into the CCS Cloud browser editor pane so that it replaces the original code. Same as before, click on File->Save and then the Hammer icon, and again confirm that the output says Finished Building: tachometer.hex. Note that if there are any errors, there will be red error messages in the Output pane and they will need to be corrected. There should be no issue with the current code however.

 

Click on Run and the code will be installed into the microcontroller. Unplug the USB cable and then using a flat blade screwdriver carefully lever out the programmed microcontroller from the development board. It will be installed in the Cyclops-1000 circuit board!

 

Building the Circuit

There are different ways to build the circuit; for example using isolated pad proto board, or using a printed circuit board (PCB). To build it on a PCB, the computer aided design (CAD) files are sent to a PCB manufacturer; the typical cost is $20 for 10 boards. One PCB manufacturer is iTead, but others offer similar prices and results too. To use iTead, search for their PCB prototyping service, and purchase their 2-layer 10x10cm board option. Then go into your iTead account order and click on 'View Order' and there will be a button to upload the CAD files. The PCB CAD zip file for this project can be downloaded from github and uploaded to iTead as a zip file. That’s it! The PCBs should arrive within a week or two.

tacho-pcb-top.png

 

I initially built mine on isolated pad proto board. To start off, the power supply circuit is built. It can be verified by plugging in a battery and using a multimeter to confirm 5V and 3.3V outputs are functioning.

tacho-supply-schematic.png

 

Next, the optical portion of the circuit is constructed. It consists of an infrared LED, and a photodiode circuit that amplifies the received signal and then provides a high/low logic output. The output is inverted and converted to a 3.3V logic signal using the Q1 transistor.

 

To test this circuit with a multimeter, placing white card to cause a reflection should result in the signal output from Q1 to change from high (3.3V) to low (0V). Careful adjustment of the angle of the LED should allow for a reliable distance of about 10cm from the target using a white card target.

tacho-opto-schematic.png

 

The output from Q1 is connected to the microcontroller. The microcontroller circuit consists of a 20-pin DIP socket for the MSP430 series microcontroller, a reset circuit (R6 and C6), a 32.768kHz crystal, a supply decoupling capacitor (C7) and two pull-up resistors (R4 and R5) which together establish an I2C serial bus.

tacho-uc-schematic.png

 

The microcontroller that was programmed earlier can be plugged into the 20-pin socket once the entire circuit has been soldered.

tach-uc-pwr-view.jpg

 

The final part of the circuit is to attach the LCD display.

tacho-lcd-schematic.png

 

And that’s it! The circuit is very simple. Plug the microcontroller in, connect a 9V battery and everything should work. The LCD display will prompt you to point it at a rotating object and the display will automatically indicate the RPM value and the number of rotations per second too (in Hz).

 

Any questions, please feel free to discuss in the comments section below. Also, if you do improve the hardware or software it would be great to hear about it.

 

PCB Version

The PCB has a couple of optional features, in particular there is space for a push-button. It could be useful to implement new functions for example min/max display of speed where the speed is varying over time, or a ‘high-res’ mode where very high granularity is needed for the RPM measurement, or a 'counter' mode which just counts number of rotations forever until it is reset.

 

The PCB version is quicker to build and there is less chance of error during assembly.

 

Final Test and Assembly

The project functions to speeds beyond practical limits for rotating objects. To prove this, I pulsed an LED at known frequencies and pointed it at the sensor. It worked to beyond 15,000 pulses per second which is close to 1 million RPM. The entire project fits in a handheld casehandheld case; a window will need to be cut for the display, the optical parts and the power switch. Alternatively a 3D printer could be used to create something suitable.

tach-enclosure.jpg

 

The window was cut to be larger than the text display area, so that the text would be visible from an angle too.

rpm-bits.jpg

The window was fitted with a neutral density filter. This was glued on the inside of the case. For the push-button, I deliberately drilled a bigger hole so that a plastic cap that I had lying around (it wasn't designed for the specific push-button that I used) could fit. Other cylinder shaped plastic pieces could be used.

rpm-glue.jpg

It turned out that I didn't need to glue the cap to the push-button; it just sits on top loosely, and is fitted with a lip (I used a grommet) around it so that it won't drop out of the case. Since there is a lot of light bleed from the sides of the LCD, I cut a black piece of card to act as a surround and lightly glued it down (I used 'glue dots' so that it can be easily removed if necessary).

rpm-card.jpg

Here are some final photos of the assembled device:

rpm-case-side.jpg

rpm-case-top.jpg

 

How does the Software work?

The software is straightforward. It is examined in detail here.

tach-software-implementation.png

 

To examine it, look at the function called main(). The software sets up the crystal oscillator, and then sets a hardware timer inside the MSP430 chip to repeat every second. When the timer reaches one second the hardware will automatically call an interrupt routine. The main function also sets up another different interrupt to occur each time a falling edge signal occurs on the microcontroller. The edge interrupt pin is connected to the optical circuit.

 

The rest of the main function just loops forever, waiting for a fresh edge sum to be available, and printing it to the LCD.

 

Whenever the edge interrupt occurs, a counter is incremented. Whenever the 1-second event occurs the counter value is published in a global variable called edge_sum and then the counter value is reset.

 

Therefore the global variable edge_sum contains the total number of transitions that occurred every second. This value is multiplied by 60 to get an RPM value.

 

Summary

This project has shown how to build an RPM measurement device (tachometer) at low cost, and how to program the microcontroller and make modifications to the code. With the PCB this is a really easy beginners project and provides a tool for measuring the rotational speed of all sorts of machines.

 

Parts List

Note: A quantity of two parts is needed for some line items! Refer to the first column to see how many references there are to that part, to determine the quantity.

 

Ref
ValueDescription
C1, C7100n100n100nF ceramic capacitor
C2, C31u1u1uF ceramic capacitor
C4, C510u10u10uF electrolytic capacitor
C61n1n1nF ceramic capacitor
D1SD5620-001SD5620-001Honeywell SD5620 optoschmitt detector
D2IR LEDIR LED850nm infrared LED Vishay  VSLY5850VSLY5850
J2DIL headerDIL headeroptional - SMD 10WAY DIL header 1.27mm pitch
LCD12x16 Text LCD2x16 Text LCDMCCOG21605B6W-BNMLWIMCCOG21605B6W-BNMLWILCD
Q1BC547BC547BC547 transistor NPN
R11k1k1k resistor
R222k22k22k resistor
R347R47R47 ohm resistor
R4, R52.2k2.2k2.2k resistor
R647k47k47k resistor
R7180R180R180 ohm resistor
R8330R330Roptional - 330 ohm resistor
SW1Slide SwitchSlide Switchslide switch  OS102011MA1QN1OS102011MA1QN1
SW2Push SwitchPush Switchtactile switch 6.5mm x 4.5mm pin spacing Omron  B3F-1070B3F-1070
U1R-78E5.0-0.5R-78E5.0-0.5Recom R-78E series 5V 500mA DC-DC converter
U2MCP1702-3302EMCP1702-3302E3.3V LDO voltage regulator
U3MSP430G2553MSP430G2553MSP430 series microcontroller  MSP430G2553IN20MSP430G2553IN20
X132.768kHz32.768kHz32.768kHz crystal wire ended, 12.5 pF
MSP-EXP430G2MSP-EXP430G2MSP430 development board
DIP socketDIP socketDIP socket 20-way
EnclosureEnclosure117x79x24mm case with battery holder
PP3 battery clipPP3 battery clip9V battery clip
Proto boardProto boardoptional - 160x100mm perf pad board