Designing A USB Breakout Board!

I often need to intercept USB signals for decoding and measurement purposes.  I cut a cable apart last time I needed one but to be honest I much prefer doing things properly.  I also noticed that nobody seems to sell a similar product on Ebay, Aliexpress or Amazon!  I did find a vendor in the USA on tindie:

USB Inspector
Image Copyright – Misperry via Tindie

https://www.tindie.com/products/misperry/usb-inspector/?pt=full_prod_search

I also found this product on tindie which is similar but has a current monitoring circuit built in:

https://www.tindie.com/products/Kaktus/usbuddy-usb-development-tool/?pt=full_prod_search

A friend of mine and blog reader found this one:

https://friedcircuits.us/50?search=usb

Either of these products would work for my purposes but the first product’s shipping costs from the USA seem a little extravagant and I only wanted one or two.

The second product uses pin headers to allow connection which are a bit close together for my liking. It’s often the way of things.  When I cannot obtain what I want I make my own!

The circuit is very simple:

The PCB layout is a little more complicated.  I would like to keep the board as small as possible but maintain the recommended conductor impedance that a USB cable should have.  By maintaining the impedance it means that signals can be correctly measured and power is not needlessly wasted.  The USB specification document is possibly one of the hardest pieces of technical literature I have had to read.  I don’t recommend it unless absolutely necessary:

http://www.usb.org/developers/docs/usb20_docs/#usb20spec

There is also a standard for USB cables which dilutes the information into a slightly more readable format (note – I am being overly sarcastic):

BS EN 62680-2-3:2015

The standard is not free to read however…but memberships to local and university libraries yields useful results.

A USB 2.0 cable must have many specifications but the two most critical that I am interested in are:

  • Cable impedance – 76.5 Ω to 103.5 Ω
  • Current carrying capability – 500 mA (standard) or 1.5 A from a dedicated charging port.

The information on the current carrying capability is confusing as there is mention of 5 amps on the wikipedia article:

https://en.wikipedia.org/wiki/USB#Power-use_topology

So based upon the above information we need to ensure the board layout has tracks capable of carrying 1.5 Amps of current at 5 Vdc and that the data pairs D+ and D- are routed as a differential pair with 90 ohms impedance.  I picked 90 ohms as a reasonable middle value and it was cited in this application note from Silicon Labs:

https://www.silabs.com/documents/public/application-notes/AN0046.pdf

Here is a useful article on layout guidelines for differential pairs:

http://www.eetimes.com/document.asp?doc_id=1144365

Basically I want to make sure my breakout board doesn’t ruin the USB signals by interrupting them. USB cables are actually proper transmission lines and the cable should be screened and the internal cables twisted to maintain uniform impedance.  The D+ and D- tracks which are differential signals will need to be routed close together above a solid ground plane (Microstrip transmission line) ensuring that both tracks are exactly the same length.  Most PCB routing software like eagle have built in calculators and tools to assist with this.

Here is an excellent (and free) online trace width calculator:

http://www.4pcb.com/trace-width-calculator.html

I entered the following information into the calculator:

  • Current: 1.5 Amps (I’m going with the lower value specified)
  • Copper thickness: 35 µm (Standard 1 oz copper thickness for FR4 PCB material)
  • Temperature Rise: 10 °C (Just a guess)
  • Ambient Temperature: 25 °C (Just a guess)
  • Trace Length: 35 mm (just a guess for now)

I’m only going to have a two layer PCB so I’m only interested in external traces.  Here is what the calculator came up with:

  • Required Trace Width: 525.491 µm or 0.525491 mm
  • Resistance: 33.612 mΩ
  • Voltage Drop: 50.419 mV
  • Power Loss: 75.628 mW

So that sets the PCB track thickness to be at least 0.6 mm.  I may well go with 1 mm as space should not be a problem.

Next we need to set the track impedance above a ground plane which is otherwise known as a microstrip transmission line.  Here is another very useful (and free) calculator:

https://www.eeweb.com/toolbox/edge-coupled-microstrip-impedance

If people need to read up on what an edge coupled microstrip layout is then please check out the link below.  It is essentially a method of setting the impedance of PCB tracks based upon the thickness and width of the track, the thickness of the dielectric material (FR4 PCB) and Wheeler’s Equation.

https://en.wikipedia.org/wiki/Microstrip

Transmission line theory is complicated and to be honest I have no intention of attempting to simplify it…I’m not sure that I could.  Basically this is some of the RF black magic people talk about…. I’m trying to keep things simple.  I would suggest that anyone who is serious about electronics and electrical signal propagation needs to have a basic understanding of transmission line theory and how to layout PCB tracks to properly interface connectors with circuits.

Here is what I fed into to the calculator:

Trace Thickness: 35 µm (Standard 1 oz copper thickness for FR4 PCB material)
Substrate Height: 1.6 mm (Standard FR4 PCB)
Trace Width: 1.5 mm (I chose 1 mm value above but went for 1.5 mm to get the right impedance)
Trace Spacing: 0.12 mm (I chose this value as a guess after trying a few different values)
Substrate Dielectric: 4 (This is the relative permittivity of FR4 PCB material)

The calculated result gives a differential impedance of 89.8 Ω – close enough!  So all that’s needed is to set the D+ and D- tracks to be 0.12 mm apart and 1.5 mm thick and try to keep the tracks the same length…If we manage that we have the 89.8 Ω impedance needed to ensure that the USB signals remain unaffected when we use the PCB.

Now that we have all of the track properties calculated we can design the PCB layout.  There is a tool in Eagle for doing this that ensures that the differential tracks are routed together.  You have to label the net names with an ‘underscore P’ and an ‘underscore N’.  I set the label for my D+ and D- nets to ‘TEST_P’ and ‘TEST-_N’ but any sensible names will do.  I then routed the +V and GND tracks manually and then set the autorouter to route the top layer.  I cannot seem to get the differential pair tool to work otherwise.  Here is what the board layout looks like:

Edit – I have updated the design after some valuable feedback from Aamir Ahmed Khan (Thank you!) – I did not remember to set the track separation distance in my original layout, I have rectified that and my calculations.  Here is the new and now hopefully correct layout.  (Note to self – I should not rush when designing PCB layouts and writing informative blog posts!).  I found the easiest way to do this was to set the grid to 0.2 mm spacing with the alternative at 0.1 mm and route the differential tracks by hand one after the other.  That enabled me to ensure the tracks were correctly separated and of the correct thickness.  I also set the ground plane isolation to be 0.2 mm to ensure the track on the bottom layer was correctly isolated…Lets see if this works!  I hope the PCB fabricators are able to etch the board for me with such precise track isolation…I can always run a scalpel down the gap though.

I will probably get the whole thing manufactured by Elecrow and for that I will need a bill of materials.

Qty Device Package Parts Vendor Part Number Description







1 USB 2.0 Socket USB X1 Farnell 2134385 AMP USB 2.0 connector
4 Ring_Test 1X01_LONGPAD +V, D+, D-, GND Ebay.co.uk 292175228920 Ring Test Connector
1 M02PTH3 1X02_LONGPADS JP7 Farnell 3418285 Standard 2-pin 0.1″ header pins
1 USB 2.0 Connector USB-A-H JP1 Farnell 1696544 USB Connectors

Here is the PCB render:

My plan is to have ten boards made, keep two for myself and flog the rest!

That’s all for now – Langster!

Having electronic breakout boards manufactured in China by Elecrow

I have an online shop where I sell some of the items I have designed and written about.  I normally have the PCBS made in china and then populate them and test them myself at my local hackspace or when I’m in a rush on the kitchen worktop – Note to young engineers: a surer method of annoying your significant other I have yet to find!

It is often quite stressful and difficult for me to hand solder surface mount components. I have to test and fault find the circuit and get everything working….after that shipping the orders in good time only compounds the issues.  It’s all about being prepared and patient…I am not always good at being prepared and then my patience wears thin!

I get my PCBS made in China by a company called Elecrow:

https://www.elecrow.com/

They sell all sorts of useful bits and pieces for the electronics hobbyist and also have a PCB manufacturing service and now more recently a PCB assembly service.

I have had at least fifty PCBS made by Elecrow and the quality has always been excellent.  The price has always been acceptable and the service excellent.  I may have also quietly lost my temper with my ineptitude in assembling surface mount components on small printed circuit boards and decided to see how much it would actually cost to get the whole product made by Elecrow.

I saw the new service advertised on the site and clicked on the appropriate page:

https://www.elecrow.com/pcb-assembly-p-366.html

Next I uploaded the gerber files for the project in a zip file along with the bill of materials with at least two sources for the components and the package sizes.  Ensuring the design is correct and the bill of materials is correct is critical…I cannot stress this part enough!

The initial price I paid to have the project assessed and the printed circuit boards and solder stencil made was £32.05 or $41.76 USD. This all started on a Sunday night on the 23rd of June.

A very helpful lady named Shelley got in contact within a day to say the order had been received but production would not start as they couldn’t open the bill of materials spreadsheet I had sent with the gerber files.  I made the mistake of not uploading the bill of materials in the Microsoft Excel format, very quickly resolved by resending the BOM in the correct file format.

Shelley got in contact within a few days to provide a quote for fitting the standard components or for fully populating the PCB.  The full cost was another £61.41 or $80 USD for ten fully completed PCBS which I thought was quite reasonable so I sent the money over and hoped for the best.

I also sent through some basic instructions and tips on how to populate the PCB gained from my own experience in doing it – I didn’t want anyone else to struggle populating the PCBS like I had and I also wanted to be sure that when the boards arrived they worked first time!

On the 12th of July Shelley emailed to say that the boards had been manufactured and that component population was about to start.  She did say that they had issues with the Op-Amp I had chosen but this was sorted pretty quickly….luckily my circuit will work with just about any Op-Amp so I wasn’t too worried.

On the 18th of July I got an email from someone named Sunshine to say that the my order was complete and shipped by DHL.  I didn’t actually bother tracking it but it arrived today on the 24th of July, well packaged in a sturdy cardboard box and bubble wrap.  Each PCB was individually wrapped in a zip lock anti-static bag with some anti-static foam on the header pins.

Every single one of the boards worked perfectly.  Here are some photos of the PCB etc…I didn’t take any of my smiling face!!!  The coin is a one pence sterling coin for scale.

Populated Pressure Sensors From Elecrow!
Check out the reflow soldering!

For the price (£93.46 or $121.76) I am very happy with the service that Elecrow provided and I will be getting more of these boards and other boards fully populated when I need to.  Shelley did say that If I get a higher quantity of PCBS made up the price quoted would reduce.  I just hope I manage to sell them all so that I can get more things made…maybe I should spend more time advertising over designing and blogging?!??

I doubt that I will ever sell enough of these to retire but I do enjoy keeping my hand in the manufacturing process – it is very useful to know how to get things made and if I ever do come up with a cunning plan…I mean product I can realise it fairly quickly and efficiently with Elecrow’s help.

That’s all for now – Langster!

How to make a Twin T Notch Filter

Analogue Electronics can be hard!  If an engineer doesn’t do much design or calculations all the time the skills can be lost.  I have personally probably forgotten far too much.  Helpfully there are reference materials both online and in books to help remind ourselves what we need to do!

I need to design and implement a band stop filter.  This because I need to make some circuit measurements and the 13.56 MHz signal (inherent to the circuit being measured) is swamping the input stage of a spectrum analyser.  I would like to be able to measure all the signal above 30 MHz without it being affected by out of band noise.  This is a common problem when using sensitive electronic instrumentation…what appears on screen is not always correct due to unknown out of band noise.

A Twin T Notch Filter Circuit

The go to circuit of choice in these situations is known as the Twin T Notch filter.  It’s a great filter circuit that is easy to implement because of its low component count.  The websites below discuss the theory behind band stop filters and Twin T Notch filters:

https://en.wikipedia.org/wiki/Band-stop_filter

http://mysite.du.edu/~etuttle/electron/elect15.htm

http://www.radio-electronics.com/info/circuits/rc_notch_filter/twin_t_notch_filter.php

https://www.allaboutcircuits.com/textbook/alternating-current/chpt-8/band-stop-filters/

The quick way to design such a filter is to set the required parameters and then use the formula given. The parameters for my filter are:

  • Must use preferred component values
  • Must not filter signals above 30 MHz
  • Must have at least 30 dB of rejection at 13.56 MHz

The formula for calculating the component values is:

Now we can either plug some numbers into the formula above and try and get close to where we want to be or we can use an online calculator tool.  I am all for quickness and see little point in doing mathematics when I don’t have to!  Here is a very useful site for calculating Notch filter component values:

http://sim.okawa-denshi.jp/en/TwinTCRtool.php

Credit should definitely be given to the engineers and Okawa-Denshi Electronics Design in Japan!

The useful thing about simulators is the component values can be selected based upon those available and not some pie in the sky value…some less helpful calculators prescribe using component values which either do not exist in the real world or require the skill of a police detective to obtain!

I also have found that when using online circuit calculators it is important to fix at least one of the component values before you start calculating things.  I entered 13.56 MHz as the centre frequency for the filter and set the value of C1 to 10 pF and C2 and C3 to 4.7 pF as these are real world (preferred) values in the E6 series.

Useful site for preferred values:

http://www.matrixtsl.com/courses/ecc/index.php?n=Capacitors.PreferredValuesCapacitors 

The online calculator did it’s thing and provided the circuit below:

The Centre frequencies were:

  • Flow = 13.555950 MHz
  • FHigh = 13.679649 MHz

The frequency response of filters is often shown as a special type of graph known as a Bode plot. This is shown below:

I have no doubt that if properly constructed this circuit would provide the filter response I’m looking for – It has 40 dB of rejection at 13.56 MHz, it doesn’t filter the signal for frequencies above 30 MHz but the resistor values whilst available are not values I have readily to hand.  Because of that I’m going to tweak the capacitor values and run the calculator again.

I have changed the values of C2 and C3 to 22 pF which follows the rule that C2 and C3 must be roughly double C1….Here is the circuit that the calculator came up with:
Again…this circuit would probably work but I’m still not happy with the resistor values.  They are hard to obtain.  I’m going to increase the values of the capacitors again and see what happens.  The values I have chosen are C1 = 15 pF, C2 and C3 = 82 pF

The resistor values are now much more common and available.  Lets hope the filter response is good enough.

The Centre frequencies were:

  • Flow = 13.496806 MHz
  • FHigh = 13.654780 MHz

The corresponding Bode plot:

From the numbers given and by interpreting the Bode plot this circuit meets my requirements. If I wanted I could fit a 22 pF capacitor in the C1 position and a similar result will be obtained.  That will also change the resistor values as well:

I’m liking these values the most as I am certain I have all of these components available.  I wasn’t sure if I have a 15 pF capacitor. It’s not a value I use much – easily obtained from any good component vendor but always best to use what you have!

The resistor values are now much more common and available.  Lets hope the filter response is good enough.

The Centre frequencies were:

  • Flow = 13.374485 MHz
  • FHigh = 13.587897 MHz

The corresponding Bode plot:

Now that we have our component values we need to calculate the power requirements.  In this case I want to be able to put as much electrical power through the filter as possible.  The signal strength of the 13.56 MHz signal in my case will be at least 20 Watts.  Therefore each component must be capable of withstanding that power level without being burnt out.

I happen to know that the 13.56 MHz signal will be coming from a signal generator and amplifier at +30 dBm.  If we convert +30 dBm into Watts we find that it is 1 Watt.  So all components need to be rated for one Watt or better. Just for fun here is the formula:

dBm = 10 * Log10 * 1 * 10^-3 (Watts)

We need to rearrange to get Watts:

10^-3 (Watts) =10^(dBm/10)) 

If we now plug the values in we get:

10^-3 (Watts) =10^(30/10))

Which is equal to 1000 * 10^-3 Watts or 1000 milli-Watts which is 1 Watt 

So all of the resistors need to be 1 Watt rated or better.  I’m going to need a small enclosure with connectors for this circuit and that means I’m probably going to need a printed circuit board.

I have used these diecast boxes in the past for this purpose – they are useful because they come with BNC connectors already fitted:

They are made by Pomona Electronics and are available from most good electronics vendors like RS components and Farnell Electronics.  My only complaint is the cost – £28.04 – yikes!

The datasheet for the box is here:

http://www.farnell.com/datasheets/63791.pdf?_ga=1.89445531.125022660.1487507564

The dimensions of the Box are below:

Rather unhelpfully the inner dimensions are not provided – I hate it when that happens. However it isn’t too much of a concern, reasonable estimations can be made.

If the printed circuit board is 36 mm x 33 mm and when populated is less than 25 mm high it will fit the above box well enough.

Here is how the layout came out:

I have chosen to use surface mount components throughout and 2512 size resistors so that the power requirements are met.  The board should easily fit inside the enclosure chosen.  The dimensions shown are in mm – for those that might be interested.

Just for fun here is how the PCB will look when populated:

ISO view of the Notch Filter PCB
The top side of the Notch Filter PCB
The side view of the Notch Filter PCB

Just for fun and because I wanted to practice my 3D drawing and modelling skills I have drawn up the Pomona 3231 Box.  It is available for download at the 3D warehouse if people are interested. Here is the PCB inside the box:

Top view of the PCB in the 3231 Pomona Box

ISO view of the PCB in the 3231 Pomona Box

Finally all that is left to do on this is create a bill of materials and calculate the total cost for this Filter.  I normally buy my components from Farnell Electronics but anywhere would do.

Component Value Quantity Footprint Part Number Cost (£) Notes
Resistor 390 Ohms 5 2512 2476478 0.604 3 Watt resistor from Farnell
Resistor 27 Ohms 5 2512 2476450 0.604 3 Watt resistor from Farnell
Capacitor 82 pF 10 0603 722078 0.015 C0G from Farnell
Capacitor 22 pF 10 0805 1759489 0.0323 C0G from Farnell
PCB N/A 10 N/A N/A 14.04 10 PCBS from Elecrow
Pomona 3231 Case N/A 1 N/A 1234948 28.04 From Farnell

Unfortunately I could not get an 0805 82 pF capacitor which is annoying but I can fit an 0603 part. The total cost for the above is £43.34 – That is enough components and PCBS to make one complete unit with plenty of spares.  The cost of a single unit alone is £29.70 which I think isn’t too bad.  Those pomona cases are very expensive – I might investigate a cheaper solution at some point.
The good news is all of the resistors I found are 3 Watt parts which means the filter will be able to work with high power signals!
The more astute readers may know that it is possible to buy a notch filter from various RF vendors.  I did consider these options and for those that may be interested the following websites have them on sale:

I couldn’t find one that specifically sells a 13.56 MHz Band Stop Filter although I suspect such products do exist.  I doubt that I would be able to buy one for less than £30
If I do decide to make one of these I will test it and provide the results and photos.  Hopefully this was of interest to someone – Take care always – Langster!