Mooshimeter – a bluetooth multimeter

I just received my Mooshimeter from a kickstarter that I backed a while ago.

2015-01-28 11.42.182015-01-28 11.43.262015-01-28 11.43.35

The Mooshimeter is a small battery powered multimeter that talks to your smartphone or iPad over Bluetooth LE. Not all devices have BLE so you should check before jumping to buy this.

The bluetooth IC is the CC2540 which is an integrated MCU + bluetooth system. The analog front-end is the ADS1292 dual 24-bit delta-sigma converter. As far as delta-sigma goes, it seems to be a very nice part with a maximum sample rate of 8kHz.

I wanted to try out my new Mooshimeter so I clamped a beam-type load cell to my workbench:

2015-01-28 11.34.52

The load cell is a super inexpensive (cheap) beam cell that I bought on Amazon for about $25. A load cell uses a resistive bridge strain gauge to measure the small amount of deflection in a calibrated beam. The deflection follows the strain linearly. Using this relationship you can use a load cell to measure force such as gravity.

2015-01-28 11.35.24

Load cells are rated in (volts full scale) per (volt input)

This means if the input is 10 volts (typical maximum) the output of this particular load cell will be 20 millivolts when a force of 5kg (49 Newtons) is applied. This is a difficult value to measure with a multimeter. The Mooshimeter claims 24 bit resolution which should give us plenty of bits even with this small maximum scale of 20 mV.

I hooked up the strain gauge and measured 1.43 mV. This value is a combination of the gravity pulling on the load cell (aka the weight of the load cell) and mismatch in the strain gauge. I didn’t pay much for this load cell so I suppose I can’t expect great performance.

2015-01-28 16.32.21

I put a roll of solder on the load cell and measured 2.65 volts. In case you’re unsure: the polarity of the voltage is relative to whether you are pushing or pulling on the load cell. Many are bidirectional (but not all.)

2015-01-28 16.32.12

If we subtract the values, the solder weighs 1.22 millivolts. Previously we calculated that the full scale of 5 kg (49 Newtons) is 20 millivolts. So according to my load cell and Mooshimeter, my roll of solder weighs 1.22mV/20mV * 49 N = 2.99 N. This is 0.67 pounds. That sounds pretty good to me. My cheap OXO food scale says 0.675 pounds which corresponds surprisingly well!

The Mooshimeter app will show a graph vs. time of voltage (and current) I made a short video of me pushing on the load cell with my finger to demonstrate this.

2015-01-28 12.11.58I haven’t had a lot of time to play with the Mooshimeter but I think it will definitely show it’s usefulness as time goes by. Of particular interest to me will be long-term data logging which at the time of this writing is a feature that has not been finished.

 

Temperature compensated MOSFET biasing

A class AB MOSFET amplifier circuit is shown below:mosfetampThe MOSFET, in class-AB operation has a positive DC bias provided by voltage source V1. The purpose of the bias is to bring the transistor into it’s linear operating region, as shown by a datasheet graph of drain current vs. gate voltage:

IRF540 forward transconductance.

IRF540 forward transconductance.

The graph here begins at about 4 volts. The threshold voltage of the IRF540 (which I’m just using as an example) is somewhere around 4 volts.

Once you get beyond 4 volts, you can see that the drain current increases in a nice sweeping (exponential) arc.

Now imagine you are building a high power class-AB amplifier with V2 = 48v and quiescent current = 60mA. The power dissipated by the transistor is 2.88 Watts.

2.88 Watts will heat the transistor up a bit, depending on how nice your heatsink is. The transistor gate threshold voltage temperature coefficient is between -2 and -4 mV / C (millivolts per degree celsius)

So if the transistor heats up by 10C, the threshold voltage drops by about 30 mV. This could have a significant effect on the quiescent current, causing the transistor to get even hotter!

One way of dealing with this issue is to use a very simple temperature compensated bias circuit:

Temperature compensated bias circuit

Temperature compensated bias circuit using TL431.

The device I built this for is an RF power amplifier that uses the MRF6V2010 N channel MOSFET. The threshold voltage is around 2.3v for this device.

The TL431 is a dirt cheap ($0.14 US) shunt voltage regulator that has a built-in voltage reference, error amplifier, and pass transistor. I used an NTC (negative temperature coefficient) resistor, R10, which increases the feedback voltage on the TL431 as the temperature increases. This causes the output voltage to decrease, following a similar temperature coefficient as the MOSFET threshold.

Because the MOSFET gate passes no current (ok, maybe a dozen femtoamps) – the gate bias voltage supply is only capable of around a milliamp of DC current. The bias voltage leaves the potentiometer (R8, above) where it passes through a few RC networks to filter out RF energy that would add noise to the amplifier (or radiate power.)

I invite feedback. I’ve been using this circuit just fine. Would you have done it differently? How could I improve it?

MMBT5179 amplifier board

The MMBT5179 is a cheap NPN bipolar junction transistor designed for radio frequency applications. I designed this super simple 1″ square board to test the performance of this transistor.

I personally intend to use this part in the HF range from 10 – 30 MHz. Due to this being a two layer board I was unable to make the trace impedance 50 ohms. The traces would need to be >100 mils wide. However, the traces are extremely short with this being such a small PCB.

mmbt5179 board

mmbt5179schematic

As configured, the bias current should be about 11 mA. Intended supply voltage is 5.

Simulation shows gain of +20dB at 20 MHz. We’ll see!

This PCB is shared on OSH Park. It’ll cost about $5 for three copies.

OSH Park 4 layer stackup and impedance data

Here’s some data on the OSH Park 4 layer stackup:

oshpark_stackup

Here’s the data as typed into Altium:

oshpark_4lyr

 

If you want a 50 ohm trace on the top layer and the second layer is ground (as it should be) then you want the trace width to be 13.45 thousands of an inch:

wcalc_oshpark_top

That’s kind of wide. Let’s see if we can make it smaller by using an edge coupled microstrip (coplanar waveguide):

wcalc_oshpark_top_coupled

Not really. The coplanar waveguide will give you a thinner trace width (W) than a microstrip of the same Z0 when the height (H) is large, like if using a double sided board of normal 62 mil thickness.

But using an edge coupled microstrip will provide better shielding. Make sure to use stitching vias from the edge ground to ground plane.

If you’re making 100 ohm differential pairs then use these values:

 

100 ohm coupled microstrip3.6 mil traces are too small for OSHPark, however. If you stick with the smallest trace that OSH Park allows – 5 mils, the Z0 impedance is about 88 ohms. This is also good for USB as long as you’re not running it a long distance across your board.

This will work for 100 ohm differential pairs if you can accept the losses and you are using it for a periodic signal (clocking.)

If you are using this for more demanding applications then you will encounter bit errors.

 

Table completed

I actually completed the table around March 2013 but I neglected to update my blog. Here are a couple pictures:

DSC_0003 DSC_0007I skipped a lot of steps. Leave a comment if you have any questions.

Edited:

I just found a bunch of pictures of the leg building process, etc:

01-DSC_0001 02-DSC_0002 03-DSC_0003 04-DSC_0004 05-DSC_0005 06-DSC_0006 07-DSC_0007 08-DSC_0008 09-DSC_0009 10-DSC_0010 11-DSC_0011 12-DSC_0012 13-DSC_0013 14-DSC_0018 15-DSC_0019

GPS Preamplifier board

This is designed to amplify weak GPS signals at 1575.42 MHz.

It uses the inexpensive and easy to obtain Hittite HMC474SC70 amplifier chip which currently costs $3.16 at Digi-Key.

gpspreampAnd here’s a schematic:

gpspreampschematicSimple, eh?

The square spots are for an RF shield can (see parts list.) The gain of this assembly should be close to +15dB with a noise figure of 3.9dB. Thus this will make a terrible LNA and you should only use this with an integrated antenna-LNA such as this part from Digi-Key:

W4000G197Parts list:

Comment Pattern Quantity Components
+5v PADS_2 1 J1
10nF 25V 0603 SMD-0603 3 C3, C5, C7 CAP MLCC SMT
110R 5% 1206(3216) RESC1206(3216)_N 1 R1 110R 0.25W 5% 1206 (3216 Metric) SMD
1nF 50V 0603 SMD-0603 2 C8, C9 CAP MLCC SMT
1uF 6.3V 0603 SMD-0603 4 C1, C2, C4, C6 CAP MLCC SMT
Gain block 15dB SC70-6 1 IC1 HMC474SC70
47nH inductor SMD-0402 4 L1, L2, L3, L4 LQW15AN47NH00D
RF shield frame BMIS-201-F 1 SHLD1 RF shield frame/cover F/C
RF shield frame BMIS-201-C 1 SHLD1 RF shield frame/cover F/C
SMA SMA_LINX 2 J2, J3 Vertical SMA through hole connector

Performance:

It works! Performance is as predicted. I haven’t been able to test with the actual GPS antenna yet because GPS signal level is in the noise. Interestingly (to me) the amplifier is very wide-band. With a small piece of wire as an antenna, I am able to watch OFDM from the many WiFi devices, on the spectrum analyzer at ~2.4 GHz.

Future Goals:

This board is part of my learning and experimentation with RF techniques. I am new to RF design but not embedded systems. My goal is to eventually build a GPS receiver.2014-12-18 08.34.05

Board:

You can buy your own PCBs from OSHPark as I’ve shared this design.

Revised photodiode amplifier

I designed a new photodiode amplifier:
photodiode_amp2And an associated printed circuit board:

Photodiode amplifier PCBThe printed circuit board is available to purchase from OSH Park if you like.

I will update this post after I receive the PCB and test the circuit.

 

photodiode_amp_psThe first part of the schematic is the power supply. VIN is +15V.
The L78L12 supplies regulated +12V to bias the photodiode. The RLC lumped element filter that follows ensures a low noise voltage source for the photodiode bias. The filter response is (simulated) as follows:

photodiode_amp_psfilterThe filter quickly drops below the noise floor above a couple MHz. This is theoretical. Actual performance won’t be quite as nice.

The 47 Ohm resistors thrown into the filter will not measurably affect the photodiode response. The DC power will be no more than a few milliwatts maximum.

The AC power will probably be below the microwatt level, I’ll guess around -40dBm. Again, I’ll update this when I have some results.

photodiode_amp_RFThe next section I’ll talk about is the photodiode itself and the amplifier.
The photodiode is an OPF432. It comes in a handy package that has an ST style fiber optic connector so you don’t have to have any bulky external mechanical parts to couple light into the diode.

OPF432The photodiode is reverse biased at +12V. According to the datasheet this should provide a rise time of about 8 microseconds. I believe this refers to the time constant. The datasheet claims this part can be used up to 100 MHz which is a period of 10ns.

The signal rises in half the period which is 5ns. If the datasheet rise time is accurate at 8 microseconds, I believe the AC output amplitude (peak) of a 100 MHz modulation will be:

Current = (5ns/8us)*50A/W = .03125 A/W

A/W is amps per watt of input power. In my application the input amplitude may be approximately 10uW. Multiplying:

31.25mA/W * 10uW = 312.5nW

This sounds very low, but let’s convert to units of dBm (decibel milliwatts):

P = 10*log10(312.5nW)+30 = -35 dBm

The GALI-74 is an MMIC that conveniently provides a 50-ohm matched input and output with +25dB of gain from low frequencies up to well above the design goal of 100 MHz.

The output will be at about -10 dBm which corresponds to an amplitude of approximately 70 millivolts into a 50 ohm load.

photodiode_amp_dc

The final section of the schematic provides a low pass filtered output which indicates the DC amplitude of the incoming light.

 

ESP8266 WiFi module

Recently I received some really cheap WiFi modules.

The Wi07C isn’t much more than a little rectangular board with a WiFi chip, flash chip, and copper trace antenna.

esp8266

 

The little board on the left is the ESP8266 board. It’s wired to a CP2102 UART to USB bridge and powered by a 5V – 3.3V buck converter I had laying around.

I bought the ESP8266 board from a store in Korea called Electrodragon

Pinout and AT command reference here

I made 5 connections for this demonstration:
VDD to +3.3v
GND to GND
RX to TX on CP2102
TX to RX on CP2102
RST to +3.3v

On my computer I ran a perl script that listens for connections on port 8001 and simply spits out data that it receives. If it receives the text “PING?” then it responds with “OK”

So I connected to the CP2102 UART bridge using Realterm. The baud rate is 57,600. The line endings are CR but CR+LF will work fine.

I sent the following commands to the module to

1. Connect to my WiFi AP
2. Establish a TCP/IP connection
3. Send data
4. Disconnect

AT+CWJAP=”myAPssid”,”passphrase”
AT+CIPSTART=”TCP”,”192.168.1.104″,8001
AT+CIPSEND=6
PING?
AT+CIPCLOSE

Here’s a screen shot of what was echoed back to me on Realterm:

ScreenClip

So I actually sent the PING twice. The last character after PING doesn’t matter in my perl script. You can see the second time I sent 7 characters. PING is 4. There’s a space you can’t see, and then CR+LF for a total of 7. The +IPD,3:OK indicates that the host (the perl script) returned 3 characters: “OK” and then a CR character.

I’m impressed that a $4.50 WiFi module does anything at all, but it actually worked without much trouble so I’m very impressed.

I then ran a command that the module didn’t like, and it’s only responding with “busy now …” to any command I send it. I’ll have to toggle the RST line or power in order to reset the device. An acceptable caveat or will this prove to be a persistent problem?

Here’s the perl script I used:

 

#!/usr/bin/perl

use IO::Socket::INET;

# auto-flush on socket
$| = 1;

# creating a listening socket
my $socket = new IO::Socket::INET (
LocalHost => '0.0.0.0',
LocalPort => '8001',
Proto => 'tcp',
Listen => 5,
Reuse => 1
);
die "cannot create socket $!\n" unless $socket;
print "server waiting for client connection on port 8001\n";

while(1)
{
# waiting for a new client connection
my $client_socket = $socket->accept();

# get information about a newly connected client
my $client_address = $client_socket->peerhost();
my $client_port = $client_socket->peerport();
print "connection from $client_address:$client_port\n";

# read up to 1024 characters from the connected client
my $data = "";
$client_socket->recv($data, 1024);
print "received data: $data\n";

print $data;
# write response data to the connected client
$client_socket->send($data);

# read up to 1024 characters from the connected client
my $data = "";
$client_socket->recv($data, 1024);
print "received data: $data\n";

if($data =~ m/PING.*/){
print("PING\n");
$data = "OK\n";
} else {
goto shdn;
}
# write response data to the connected client
print $data;
$client_socket->send($data);

# close
shdn:
shutdown($client_socket, 1);
}

$socket->close();

 

 

Capacitor impedance

Ever since I began designing circuits, I’ve read about bypass capacitor usage.

Engineers make broad statements about what you obviously have to do. Disagreeing with this advice automatically makes you a neophyte.

Common phraseology of bypass capacitor lore includes:
– You must use a mixture of low and high value capacitors to filter low and high frequency transients.
– You must use a tantalum bulk capacitor
– Sprinkling 1uF or 100nF caps around a board is stupid
and I’ve not made this one up:
– If you don’t know how to properly design capacitor bypassing, you should not be an EE.
[Of course, by “proper” they mean follow their advice]

I’ve been told by other reputable sources that since good MLCC [multi-layer ceramic capacitors] of high value and good electrolyte are now available, that most of these rules are exaggerated as yet another way for some engineers to claim superiority over others.

I decided to perform a few simple measurements to help me figure out for myself what I need to do when designing a circuit with bypass capacitors. Feel free to post below and offer advice as to how I’m wrong and/or what I should do with my graphs.

Test setup:
I have a simple “DG8SAQ” Vector Network Analyzer that I bought from SDR-Kits. It’s a reasonably good value and covers the range of 1kHz to 1.3 GHz. Without any fancy impedance converters, I decided that using this 50-ohm system to measure capacitor impedance would not be an unreasonable analog to what is happening when a capacitor is used for bypassing.

Bypassing for high speed digital systems is demanding. Edge slew rates can easily reach into the GHz range for FPGA designs. Even common LVCMOS digital logic can be extremely demanding – a recent comparator I used (MAX962) will drive it’s output high/low in 2.3ns (specified at 5v. It will be somewhat slower at 3.3V)

What I decided to do is solder a couple SMA connectors adjacent to each other, as in the following picture:
2014-05-27 14.23.57

I calibrated VNA and soldered a few surface mount capacitors into the open space. I used the following values:
1 nF
10 nF
100 nF
1 uF

From basic theory we know that the impedance of a capacitor is, as written in Laplace domain:
1/(sC)

Where
s = j*W [complex frequency]
and
C = capacitance value in Farads

In reality, capacitors have ESR and ESL. ESR is equivalent series resistance, and ESL is equivalent series inductance.
Alternating current by definition makes the impedance of a capacitor change.
LCR

My measurement system is not perfect for at least one reason; the ESR of a capacitor is usually << 1 ohm. My VNA is a 50 ohm system. I cannot effectively measure the ESR with this system. These plots will reflect the ESL, which I can measure.

Firstly I measured a 1nF capacitor. This plot is the magnitude of the signal that goes through the capacitor. This is called “S21″
I measured from 10kHz to 100 MHz because this seems to be a range most people would be interested in:

[click image for larger version]
1nf_cap_impedanceNext I tested a 10nF capacitor of the same size and type:

10nf_cap_impedanceLooks pretty nice to me.

Now for the 100nF cap:

100nf_cap_impedance
I continued on with a 1uF capacitor. The plot is quite boring:

1uf_cap_impedanceIf you’ll notice: these last two plots went all the way up to 300 MHz. I thought there must be something interesting going on at some point. Not really.

My conclusions are based on the measurements that I’ve done. Obviously I have not included PCB parasitics in my test setup.
My conclusion is that for point-of-load bypass capacitors, the actual value of the capacitor makes little difference. I would not hesitate to use 100nF MLC-capacitors all over my PCB. Ideally the capacitors are placed as close to the power pins of the integrated circuits as possible, in order to make the current loops as small as possible.

Bypassing requirements for real circuits are very complicated. If you just have a fundamental sine wave current, you just pick one capacitor and be done with it.

I believe what I’ve shown is that the Fourier components of your load current that exceed about 1 MHz are easily handled by 100nF MLC capacitors, and that your lower frequency bypassing can be handled by a bulk capacitor that is located elsewhere on the board. Of course this depends on the inductance of your PCB traces.

Your system probably has intermittent loads switching on and off, or perhaps you’re building a switching power supply. The best bypassing setup would be an ideal capacitor of arbitrarily large capacitance value. This would theoretically cover your Fourier components from a few Hertz up to hundreds of MHz. Recently I’ve been using MLCC as large as 100uF with the X5R rated dielectric (never use Y5V!) I believe these new enormous MLCC are nearly ideal capacitors. They are expensive but I highly recommend them, especially if your alternative is a tantalum capacitor.