How to Choose a Voltage Regulator for Your PCB Design

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - How to Choose a Voltage Regulator for Your PCB Design.jpg

Unless you are working with a purely AC system, your PCB will need to receive stable DC voltage to operate properly. A voltage regulator circuit provides the necessary DC voltage with fixed magnitude, even if the input voltage (line) or the output current (load) changes. Some circuits are more sensitive to voltage fluctuations than others, and some power lines are noisier than others. Any designer should understand how to choose the right voltage regulator for their board. Let’s take a look at the different types of DC regulators and go through some factors to consider when selecting a voltage regulator.

Types of Voltage Regulators

Voltage regulators are normally placed on the output from a full-wave rectifier circuit in order to remove the remaining ripple waveform. There is more than one way to classify a voltage regulator, but for the moment we will stick to linear and switching regulators. These regulators can be added to a layout relatively easily and provide reasonably stable output voltage for most applications.

Linear Regulators

Linear regulators use a BJT or FET to stabilize the supply voltage and are controlled with an amplifier. The amplifier compares the output voltage from the regulator to a precision reference and changes the transistor to maintain a constant output voltage. Linear regulators always step-down the output voltage (i.e., input voltage > output voltage). Linear regulators with low drop-out voltage are called low dropout regulators (LDO). Linear regulators provide the following advantages:

  • Low Noise: As there is no switching involved, these regulators generate low noise and are best used for powering sensitive circuits. In contrast, switching regulators are inherently noisy as they switch frequently in order to maintain the output voltage.
  • Low power: When properly designed, linear regulators can operate with quite low quiescent current. Switching regulators use complex feedback systems and end up using higher quiescent power. When operating as LDOs, these regulators can have very high efficiency (~90%).
  • Low cost: Linear regulators are less costly, and they are easy to add to a layout. They do not require too many components and filters. Usually, a capacitor is placed across the output to help regulate the output voltage.

linear-regExample linear regulator circuit

Switching Regulators

A switching regulator converts an input DC voltage to a more stable DC output with a power MOSFET or BJT switch. The output from a switching regulator is usually filtered and used to reduce switching noise on the output voltage. There are three types of switching regulators: buck (step-down), boost (step-up), and buck-boost (can provide step-up or step-down). Switching regulators provide the following advantages:

  • High efficiency: Since switching regulators work in either off or on mode, they tend to be more efficient. They can provide 90% or greater efficiency, which is very difficult in most linear regulators unless they are designed to as LDOs.
  • Step-up configuration: Linear regulators can only step down the input voltage, but a boost switching regulator can step-up the voltage. This is particularly useful in the case where a large voltage is required for a short period of time (e.g., the backlight in a camera).
  • Thermal performance: Linear regulators are less efficient, which means they tend to dissipate more heat and need a heat sink. Most switching regulators do not need heat sinks.

The buck and boost characteristics can be controlled with a PWM waveform, which makes this regulator ideal for use in applications where specific voltage levels are required. For example, you can use the PWM output from a microcontroller to power another circuit with a specific voltage level. There are many different ways to build a switching regulator IC, and we can’t possibly show every possible circuit. If you are interested in learning more about specific circuit layouts for switching regulators, take a look at the datasheets in your parts library.

Important parameters for choosing regulators

One question I often see on forums is how to choose a voltage regulator for different applications. There is no single answer to this question. You should consider the following characteristics when looking for a voltage regulator; note that these aspects apply to both linear and switching regulators:

Output voltage

If you need a step-up regulator, then you will have to use a switching regulator in boost configuration. If you are using multiple supplies in a system, typically one regulator is used for each supply. Regulators usually supply a fixed output voltage, although there are some regulators available on the market which you can use with some adjustable settings.

Efficiency vs. Noise

Switching regulators provide higher efficiency than linear regulators, but they generate more noise. Unnecessary electronic noise can interfere with other circuits when the regulator outputs high current. If you want your product to hit the market, it can be more difficult to receive EMC certification. If other circuits on your board are sensitive (e.g., purely analog components), then it’s better to choose a linear regulator.

Selecting a regulator with high power losses can make it almost impossible to meet efficiency goals. Linear regulators are less noisy, but they are very inefficient (except LDO), meaning some power gets converted to heat. If your regulator will run at high current, you should include heat sinks on the board. If you don’t have room on the board for a heat sink or if power dissipation is a concern, then a switching regulator might be a better option.

shutterstock_744239These 7805 linear voltage regulators from Fairchild include a heat sink on the back of the package.

Transient response

When output current changes quickly, there is a small spike at the output. The voltage regulator takes some time before it switches back to the same voltage. This is called a transient response. The transient response is usually a function of the output capacitance and load current. A fast transient response ensures that the regulator can deliver the required power. Check your component datasheets and look for the recommended bypass capacitor you should include on the regulator’s output.

Voltage Regulator Layout Considerations

Once you have chosen the right voltage regulator for your design, you’ll need to place it in the proper location on the board. In general, you will need one capacitor between output and ground, and one between the input and ground as close to the pins as possible. You should also carefully design traces so that they can carry the required current without overheating.

If you take a look at some of the open-source projects in Upverter’s™ project library, you’ll find some good examples of regulator layouts that you can use as a reference for your next project.

boost-reg-boardBoost converter control board from James Fotherby, created in Upverter.

A good layout tool makes it easy to design schematics for your board and capture it as an initial layout. Upverter® provides a huge library of reliable components that you can easily add to your schematic and layout, including a huge range of voltage regulators and much more. As a cloud-based tool, Upverter allows users to easily share their work, control revisions, and access their data from anywhere.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Project: Environmental Control System, Part 1

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - Project_ Environmental Control System, Part 1.jpg

A while ago, I reached out to a YouTube channel which I support on Patreon to ask if the user  required any custom electronics for his projects. He recently got back to me and we have a new project! We’re going to build an environmental monitoring and control system. He is building an experimental Mars base in the middle of the desert, and needs a custom system to monitor and control carbon dioxide (CO2) levels inside, primarily in the area he will be using for growing crops. The plants will consume CO2 as they grow, and animals (such as humans) living in the habitat will produce CO2 as they breathe. If CO2 levels rise too high, it could become dangerous, so air will need to be pumped through CO2 scrubbers, and if CO2 levels get too low, then CO2 will need to be released from a tank.

These were his only requirements, but I thought it would be fun to also include traditional environmental sensors, such as temperature, humidity and index of air quality. Furthermore, to display readings, it would be nice to use a 5-7” TFT capacitive touch screen to give something big and beautiful to look at.

Our specifications and requirements are fairly broad, which gives a lot of leeway for creativity as we go through the design. As with my other project articles, we will be planning and building this as we go. When mistakes are made we will learn from them together, and we will go through the thought process together when we encounter scope creep or find we need to modify the design.

Requirements and Specifications

Required functionality:

  • Read CO2 levels from the atmosphere.
  • Maintain CO2 levels utilizing CO2 scrubbers and tanked gas.
  • Display current and historical CO2 levels on a display.

Nice to have:

  • Temperature monitoring.
  • Humidity monitoring.
  • Index of Air quality monitoring.
  • Networking for multiple sensors in multiple areas of the habitat.

Part Selection

The most critical part of this design is whether or not we can find a CO2 sensor that will meet the requirements. Everything in the design relies on being able to sense CO2 levels accurately and reliably. The other sensors are more because I love collecting data, and it makes sense to build a full environmental monitoring system.

Carbon Dioxide Sensor

As usual, I start out at DigiKey because I’m most experienced with digging through and filtering DigiKey’s data. The other major suppliers all have great filtering mechanisms too, however, as I’m most familiar with DigiKey, I look at them first.

I’m looking for a gas sensor, so naturally we’re looking in the Sensors, Transducers > Gas Sensors category for in-stock parts that have an Active part status. If I need to make more of these devices months or years down the road, I don’t want to pick a part which is already obsolete or not recommended for new designs, and may not be available once current stocks run out. I’m filtering for anything that includes CO2 as a gas type parameter, then sorting by price.

Sensirion – SCD30

The cheapest result I found is the SCD30. Its datasheet looks pretty good, and it’s an I2C based sensor which is fantastic for getting accurate measurements from. This is definitely a good candidate; I’ve used Sensirion sensors in the past, and they left quite a positive impression on me. They have been easy to interface with and performed to the advertised specifications.

The dev kit for the SCD30 is quite expensive. While not necessary, a dev kit can provide a nice working implementation that is good for attaching a logic analyzer to if there are difficulties getting your own code to work with the sensor.

Amphenol – T6713

With a bit of a jump in price, the T6713 is a nice shiny gold sensor that’s a bit smaller than the SCD30, and works over a wider temperature range. It has higher precision, and has a self calibration routine built in to ensure optimal accuracy as long as the ambient carbon dioxide levels drop to around 400ppm a few times a week. Amphenol also have other types of sensors that do not need self-calibration, but are not as accurate.

My main concern for this sensor is it’s advertised high power consumption. I haven’t been told to optimize for power consumption, but if it does become a requirement in the future, it could rule out this sensor, especially if real world current draw is as high as the advertised figures. My experience with gas sensors in the past makes me feel as though turning the sensor on just to make a measurement will not give me as accurate readings as leaving it on all the time, because gas sensors typically like to be on all the time to run calibration routines and to keep the sensor elements activated. I don’t know what the internals of this sensor are, or if the calibration data is stored in non-volatile memory internally, so I can’t be sure my past experience applies to this sensor. When selecting parts, you typically try to reduce engineering risk, and get your new project off the ground as quickly as possible. This can very much make past experience with similar sensors influence the choice of parts in your newer projects.

A secondary concern for this unit is the self calibration, which also makes it accurate. With the sensor being installed in a closed habitat, it could completely skew the calibration data. The sensor is expecting levels to drop to the global average of around 400ppm, and uses the low point of its readings in a given period as a calibration reference. If we are artificially creating a low point by using CO2 scrubbers, or the crops that are growing consume CO2 bringing the levels below 400ppm, it could take the calibration too low. Likewise, if the environment never reaches 400ppm in a week, with elevated CO2 levels continuously present, it could easily skew the calibration to a higher percentage. The CO2 levels being too low is not great for the crops, and likewise, the CO2 level calibration shifting too high could be very dangerous to anyone living in the habitat. With this in mind, the sensor will need to be tested in an elevated CO2 level environment for at least a week to see what happens to the readings.

The dev kit, on DigiKey at least, is cheaper than the sensor itself. This is not the case at any other supplier, so perhaps it’s a temporary glitch. The fact the dev kit is cheaper than the sensor is pretty exciting, STMicroelectronics do this a lot with their ARM dev kits which makes them really affordable to start a project with. I love this model, as it makes trying out a device so much easier than dev kits costing hundreds of dollars, and makes it much more likely for a device to end up being used in my product.

Based on the dev kit prices, I’m going to give the Amphenol T6713 a try in this project. If it doesn’t meet the expectations, I’ll switch to the Sensirion SCD30 as my second choice. As we’re only building a couple of these units, the unit cost for the sensor is far outweighed by software development time. I’m providing this device for free, but my time still has value to me.

Microcontroller

I rarely use a microcontroller outside the ARM Cortex range, so I’m looking for an ARM Cortex M0 or M3 which has a dev kit (ideally one I already own), lots of RAM for graphics, USB and a decent number of pins for running a parallel display.

For this project, I feel as though MikroElectronica’s IDE might be the best option, due to the VisualTFT option for designing user interfaces quickly. So the microcontroller I choose needs to be supported by mikroC PRO for ARM. For dev kits I already own, this means I’m looking at a controller from STMicroelectronics, as I already have most dev boards they produce.

The cost of the microcontroller is pretty negligible in terms the total cost of this project. So as mentioned before, ST’s habit of offering an expensive microcontroller on a cheap dev board is definitely going to encourage me to use an over-the-top option for a microcontroller just for ease of use. If I was planning to build hundreds or thousands of these units instead, I’d be looking to optimize for price.

Since I’m not certain of my processing requirements, I’m going to start with an STM32F413 dev board, and look at switching to another processor if I find I need more or fewer resources as we go through the breadboard stage. The code compiled with mikroC will work on any supported platform, and could also be ported to a PIC or AVR just by switching IDE.

I specifically mentioned fewer resources as there are some interesting options for displays which could heavily influence the amount of resources required.

Display

As with the microcontroller, I need to find a display that has a controller supported by MikroElectronica’s VisualTFT software. The options cover the vast majority of the displays on the market, so it’s not particularly restricting to a choice.

MikroElectronica’s store has a good range of displays at reasonable prices, so to keep things simple for this project, I’m just going to order a display from their range. Again, we’re not optimizing for component cost on this project, we’re optimizing for minimal development time. Using a display that has a good datasheet and is known to integrate well with the development environment will potentially save me a significant amount of time over choosing a display from an online marketplace which would save me 20-30% of the cost of the display, or a 10% reduction in the total project cost.

I mentioned earlier that perhaps we will not need much memory depending on the display option. Well, the FT813 display controller is the reason behind that. It’s a display controller that allows you to build up a user interface, including touch screen capabilities, via SPI. One feature that really attracts me to the FT813 is the integrated ability to draw a bar graph. It might not seem like a huge deal, but when displaying environmental data, being able to offload the render and display of historical data could save a lot of programming time and a lot of memory.

So with that in mind, we will be using the FT813 display option from Riverdi, a European company that builds displays in Europe. They have a nice model with a bezel, and capacitive touch that has caught my eye, the Riverdi Display 5” UXB.

If we end up finding a reason not to use that, then a display based on the SSD1963 with capacitive touch would be the next choice. The TFT Proto 5 Capacitive touch screen display is only a few dollars cheaper and works over a parallel connection. A quick look through the SSD1963 shows that we’ll need to build the image in memory to send to the display the old fashioned way. This would need 9,216,000 bits of memory if we buffered the entire frame at once! Since we won’t find a microcontroller with that much memory on-chip, we would have to either implement external memory, or render line by line. This is where VisualTFT could come into play, allowing us to take care of a lot of the rendering effort with very little engineering effort.

Environmental Sensors

On my nice-to-have list, I have a few environmental properties to monitor, and after looking through sensors, I finally found the recently released Bosch BME680. It’s relatively cheap, and has all of the functionality I want built into one tiny package. Compared to other sensors that implement an Index of Air Quality output, this is but a small fraction of the cost of just an IAQ sensor. I’d be very interested in this device purely for the temperature and humidity sensors, and while I always love playing with a new sensor, having IAQ seals the deal for me. If it doesn’t work out the way I’m hoping for, I have a bin of temperature/humidity modules that can stand in for it. Then, we can skip the IAQ metric if we find during breadboarding that this device is a pain to deal with. Nevertheless, given that it’s from Bosch, that’s pretty unlikely.

Networking

I’m skeptical of the need for wireless networking on this device. It would be great to have a network of sensors throughout the habitat that can monitor the environmental conditions in each ‘room’ and use fans and ducting to shuffle air around. This would allow high CO2 air to be shuffled over to the crops, and low CO2 air from the crops to be moved out to where the high CO2 air is coming from. In reality though, I feel as though this ducting could impact on the available space within the habitat, as well as add a lot of complexity to the installation. The habitat is going to be relatively small, with very small openings between each room that would be negatively impacted by having ducting in the opening. A more practical alternative would be to simply have a couple of fans just slowly moving air around the entire habitat continuously.

Due to these reasons, adding some form of sensor networking is very low on my priority list. There is no internet or cellular connectivity in the desert location where the sensor will be operating, so logging to a nice cloud platform is out of the question. Therefore, I’m going to leave networking in the nice-to-have column, and if a reasonable use case can be made for it, we will investigate modules for it in the future.

It’s very easy to design a technical solution to a problem with very simple means, so before we head down that route, I want to ensure it’s necessary, no matter how fun it is to build networks of sensors!

Top Level BOM

Now that we have finally selected all the components, we will begin to test them in the next article using a breadboard. Our high level BOM of components to test is:

  • Amphenol – T6713
  • STMicroelectronics STM32F413
  • Bosch BME680
  • Riverdi Display 5” UXB based on FT813

As we test these components, we will determine whether they are suitable to be used for our environmental monitoring system or not. If the devices we test do not meet our requirements, then we will order alternative components to test instead. Then, once we have finished all the testing, we can proceed to schematic capture and layout.

Next Time

In the next article, we will use breakout boards and the dev kit for each of the high level components to determine whether they are going to meet the requirements of the project. This process should get us a fairly good skeleton firmware prepared as well as confirming the choices for each component. We will know what pins on the microcontroller we are going to use, which will ensure the PCB we design has a very high probability of success on the first iteration of the design process. In the meanwhile, if you want to gain more insight into why I made my decisions in this specific order, you can feel free to check my Guide to Starting a New Project.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Adding PCB ESD Protection to Your Design

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - Adding PCB ESD Protection to Your Design

Electrostatic discharge (ESD) occurs when two objects with different net charges come very close together. At a close distance, the electric field between these objects becomes very large and causes the medium between them to breakdown. In PCBs, a discharge usually originates when the user touches the board, or when metal held at a high voltage nears a conductor on the board.

Usual activities like plugging cables in/out, pushing buttons, or using a screen or keys can result in electrostatic discharge. This discharge can cause a high current pulse in the system that can damage ICs and other components on board. PCB designers need to be aware of some simple strategies for PCB ESD protection in their design.

Components for PCB ESD Protection

There are some components that can be added to your board from your parts library to protect against voltage spikes due to ESD. These components are usually grouped together as ESD suppressors. Here are some components you can use for ESD protection in your next design:

TVS diodes

Transient voltage suppression (TVS) diodes can be used to fix the voltage on a line to a safe level. A TVS diode is actually an array of diodes arranged in such a way as to provide very high impedance to normal range voltages. TVS diodes can be constructed in a loop arrangement (shown below) using two p-n diodes and a Zener diode. You can also use a back-to-back diode without forming a loop arrangement, or you can use an integrated circuit that provides TVS.

When a voltage surge occurs across the TVS diode, the diode will provide a path to ground for current before it can damage any components on the protected line line. The loop arrangement below causes current to dissipate to ground as to moves around the diode loop.

ESD1TVS diode for ESD protection

Capacitors

Capacitors connected to ground act like a high impedance source for any DC voltage, while they act as a short circuit for high frequency voltages. By strategically placing capacitors with the proper value on sensitive nodes, voltage surges can be discharged to ground safely. This method can potentially make the node respond slower and might cause a distortion of digital data. For this reason, capacitors are not normally used for PCB ESD protection in high speed designs.

ESD-Aware PCB Design Strategies

Placement of the ESD Suppressor

After choosing an ESD suppressor that is compatible with the electrical characteristics of your circuit, the next important consideration is its placement. The placement should be done such that IC receives the lowest possible voltage surge if ESD occurs. For moderate frequency signals and for typical ESD pulses, PCB traces act like inductors, meaning their impedance increases with frequency (ωL). The circuit with the TVS diode above now looks like this:

ESD4
Effect of line inductance on ESD

From the figure above, we can clearly see that the diode will be triggered quickly when L2>>L1. This will also mean that most of the current will get steered away from the protected line and L2 will also dissipate any ESD left on the protected line. This means we need to place the TVS diode as close as possible to the location where ESD might occur. There should be minimum inductance on the ESD suppressor connections to the line or ground. The energy of ESD pulse decreases as the trace length increases, so the trace length between the ESD suppressor and the protected IC should be as long as possible.

Limiting EMI from ESD

ESD produces strong voltage pulses that can produce electromagnetic interference (EMI) on other nearby signal lines. The primary source of radiation is between the ESD source and the suppressor, which acts as an antenna. If possible, you should keep the suppressor area away from other circuits and unprotected traces, otherwise they can carry the ESD signal to other ICs. Even without considering the inductances of each line, the protected and an adjacent unprotected line can act like a capacitor, which allows the voltage surge to pass between the two lines. The following figure illustrates how an ESD pulse can couple to an unprotected line:

ESD3ESD coupling to nearby traces because the two traces act like a capacitor

Vias Between the ESD Source and Suppressor

If there are any vias between the ESD source and suppressor, the via can also cause coupling to an unprotected line. Ideally, there should not be any vias between the ESD source and suppressor, as it increases the length of the line, causing more inductance on the line. This has two detrimental effects:

  • It will increase the ESD pulse energy in the protected line
  • It will increase the signal generated by the unprotected line through EMI

If the designer has no choice but to add a via, then they must make sure the protected line and suppressor are on the same side of the board, and the source is connected to the protected line only after the via (Case1 in the figure below). The worst possibility is that the source and protected line are on the same side, while the suppressor is on the other side; this should be avoided (Case2). In this case, it is best to use another via to connect the protected line after the ESD suppressor rather than connecting the ESD source directly to the protected line (Case3).

ESD-viaHow to add a via to reduce the impact of ESD on a protected line

Proper Ground Routing Can Reduce ESD

We saw earlier that we need to reduce the trace inductance between the source and the TVS diode to direct the voltage pulse away from the IC which we need to protect. The earlier image assumed that the suppressor has a good ground connection. In reality there might be some inductance between the ESD source and the TVS diode, or between the TVS diode and ground; this is shown in the figure below:

ESD2Parasitic inductance on the suppressor can direct more ESD voltage back to the IC

We can lower L3 by placing the TVS as close to the source as possible. In order to reduce L4, we need to connect the TVS ground pin directly to the ground plane using a via. If a direct connection is not possible, then use multiple vias in parallel on the trace that runs to the ground plane. You should make the drill diameter on each via and pad size larger to increase the surface area (to combat the skin effect). A ground via on a TVS suppressor should be filled with non-conductive material to keep the surface area large.

It is a good idea to incorporate ESD protection early so that you don’t need to make any last-minute changes to a complex layout. If you’re looking to create your next schematic and layout in an easy-to-use online PCB design platform, Upverter® provides these tool and many more,  allowing your to design boards from start to finish. As a cloud-based tool, Upverter allows users to share their designs, roll back to previous design versions, and access their data from anywhere.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Project Design Walkthrough: Airsoft Tracer Unit, Part 2

Get Started with Altium Upverter, Sign Up Now.

Upverter Expert - Project Design Walkthrough_ Airsoft Tracer Unit, Part 2.jpg

We’re back to building our airsoft tracer unit which we started in Part 1. If you’ve forgotten what happened in part one and don’t want to re-read the whole article, we were building a fancy array of UV LEDs that are activated by an airsoft BB traveling past a light gate, and are switched off when the BB reaches the other light gate. On this project, we’re going with the attitude that ‘if it’s worth doing, it’s worth overdoing’. So while most commercial tracer units use under 2 watts of UV emitters, and the most expensive are about 6 watts, we’re throwing over 170 watts of UV emitters into the tracer unit. This massive amount of UV light will make airsoft tracer BBs glow, as they have the same chemicals as ‘glow in the dark’ powder and paints. This makes the BB easier to track in low light or dark conditions, such as inside a building or after dark. In Part 1, we defined our project parameters and requirements, then selected the high level components we thought might work well for the project.

Now that you’re all caught up on the project, welcome to Part 2. In this article, we are going to prototype the project on breadboards to ensure all our component choices are valid, and determine/tune the values of several resistors and capacitors that are going to be critical to detecting the fast moving BB traveling past our light gate. I was hoping to also make a start on the software to see if we can exclude some of the components we chose in Part 1, and get the rudiments of the system functioning. However, I’m having a hiccup with one portion of the design which we will discover as we go through it in this article, so that will be covered in Part 3.

As I mentioned in Part 1, I’m building this project article by article—by taking the approach of having you follow along with me as I design the tracer unit from start to finish, as that allows more learning opportunities as we discard components, discover that parts are not optimal, and make mistakes along the way. This is not a writeup of a completed project, but a writeup of the journey to get there.

The Photogate

Since we cannot control the LEDs without the photogate, it is probably the most critical portion of the project. Therefore, I’m going to start by building the amplifier for the PIN diode, which we are using to detect infrared light at the photogate. The PD15-22B/TR8, which is the PIN diode we selected for the surface mount PCB, isn’t available in a through-hole package, nor is the OSRAM SFH 4641-Z IR emitter. To be able to prototype, I’ve chosen parts with comparable specifications to work with instead.

Testing the Diode

My first step is to check that the PIN diode is going to respond nicely to the 950nm IR emitter. To do this, I set my lab power supply to limit the current to the emitter to 20mA, and then connected the PIN diode directly to the oscilloscope probe. Operating in the photovoltaic mode, the diode acts a bit like a really bad solar cell, generating a small amount of voltage as it is exposed to light that it is sensitive to.

WavingLED

Waving the IR LED back and forth over the photodiode showed the response on the oscilloscope, so all looking good so far! You’ll notice the amplitude of the voltage is low, with 5mv/division on the oscilloscope.

Next, I wanted to see how fast the photodiode could respond in photovoltaic mode. For many applications, the photovoltaic mode is going to be sufficient, however, it’s relatively slow due to the capacitance of the diode junction. The voltage created by the light needs to charge the junction as if it were a capacitor, so the voltage has a rise time that is far less than instantaneous. To test this, instead of powering the IR emitter all the time and breaking the beam as we would in the final product, I added an N-Channel MOSFET to the breadboard. The MOSFET will control the IR LED with my function generator, thus enabling me to dial up any frequency I want and see what the response is. Channel 1 (below) on the oscilloscope is connected to the LED leg, and channel 2 (blue) is connected to the photodiode.

60hz

With a simple 60Hz signal, we can confirm everything is working before continuing on to more applicable frequencies.

slowresponse.jpg

Switching the IR emitter with just a 1kHz signal, we can already see significant effects of the junction capacitance. The rise time is around 212us, which for many applications might be fine, but is inapplicable in ours as we need to capture a much shorter signal. 

In the UK, we have joule limits for the energy of the BB as it exits the replica firearm. The highest joule limit is allowed for bolt action rifles, and equates to 500 feet per second with the lightest commonly used BB (0.2g). At 500 fps, we can expect the BB to occlude the light beam for about 20-40us. The actual period of time will depend somewhat on the exact implementation, but this ballpark figure should give us an idea what rise time to aim for. With a rise time an order of magnitude higher than this, photovoltage mode will not work for this application.

In part 1, this was already expected, so we designed a circuit to use the photodiode in photoconductive mode. As the junction is exposed to light, it is able to conduct current in the reverse-biased direction. As the junction conductance is directly correlated with the amount of light hitting it, the junction capacitance has no bearing on the rise time. We can use this conducted current to determine how much light is hitting the sensor instead of using the induced voltage. To do this, we need a transimpedance amplifier to convert the current into a voltage.

Soldering Op Amps to Breakout Boards

The op amps were also only available in surface mount, however, as they are in the common SOT-23-5 package, I have used breakout boards for them. If you’ve never tried soldering a relatively small and fine pitched component to a breakout board, it’s quite simple, even with thick solder and a wide chisel tip on your soldering iron. I use a 2.4mm wide chisel on my soldering iron for soldering even 0.4mm pitch and 0201 size components, so don’t feel as though you need anything more than a temperature regulated soldering iron to work with small surface mount parts.

You’ll only need a soldering iron, a flux pen and a set of tweezers. You can read more about my suggestions for these over on the Altium blog in my Kitting Out an Electronics Lab article. The breakout boards I have are from Sparkfun, and the pads look a little tarnished, so the flux is just going to make soldering to the pads much faster and easier.

DSC_1038_DxO_web

First, I will wipe some flux across all the pads on the board, then tack down one pin in the corner, ensuring that all the other pins are well aligned on their pads. To do this, I hold the component with curved tweezers onto the board, and bring in the freshly cleaned and tinned soldering iron tip. The solder on the tip will transfer onto the pad and lead, with the flux you already added to the board ensuring that the solder on the iron tip flows well. 

DSC_1039_DxO_web

At this point, you can add a little more flux to all the pins if you want. Continue soldering each pin with a one second long tap from the corner of the soldering iron tip so just the pad and leg of the part make contact. If you have a small bit of solder on the tip, it will transfer over to the pin and pad nicely, without shorting any of the pins. If you do short adjacent pins, you can add a little more flux and then use the soldering iron to wipe it away. The surface tension of the solder will cause some of it to pull away on a clean iron tip, and the flux will ensure it doesn’t oxidise and flows well.

DSC_1040_DxO_web

To ensure the breakaway headers get soldered on straight, and you don’t melt the plastic if you take too long, you can mount the pins into the breadboard and drop your breakout board on top. Then, just solder as normal. If you are worried that the pins of your breakaway header are tarnished, or that the breakout board is, you can add a little bit of flux here too. Make sure you’re using no-clean flux though, as you don’t want a sticky, mildly corrosive flux stuck between your header and the board.

Building the Circuit

I then built the circuit on the breadboard using the schematic the Analog Devices website calculated for us. However, to make prototyping easier, I’m using multi-turn pots, which I pre-set using a multimeter for the resistance in the schematic, instead of using exact fixed value resistors. I’m using an LM317 to create my 2.75V positive rail from a 5V supply generated by my lab power supply. I wanted a higher voltage coming into the breadboard for the IR emitter to run off, so I could use a larger resistor than if I powered the board with 2.75V. I didn’t have a close match to the correct current limiting resistor for the IR LED with 150mA at 2.75V. 

I’m using a Texas Instruments TPS60403 inverting charge pump to create the -2.75V supply for the op-amps. You can read more about negative voltage in my article on the Octopart website. The op-amps need very little current, so the 60mA charge pump is more than sufficient.

DSC_1033_DxO_web

To test the PIN diode, I’m using the MOSFET set up for the function generator and IR LED that I mentioned earlier. This will give me a continuous pulse of light that I can watch with my oscilloscope along with the amplifier output to see the response of the amplification circuit.

first1khztest.jpg

For the first test, I tried it out at 10kHz just to see if it would be better than the 1kHz signal we had previously. Clearly, the signal is looking much more square, but is looking pretty wavy! After a bit of poking around with the oscilloscope probe, I found that the noise was coming from the inverting charge pump, the output of which looked exactly like the flats of the blue waveform. Clearly, it needs a lot more capacitance than the datasheet suggests, needing around 40uF before the signal looked better.

As a note on the oscilloscope probes, this is a brand new oscilloscope for me, and I found out much later on in testing that the attenuation switch moves rather easily. It was set to 1x initially, but by the point of this screenshot, it had moved to 10x attenuation, so the voltage levels are all 1/10th of what they should be. This caused much confusion as to why the amplifier circuit just wouldn’t go above about 370mV no matter what I did! So lesson learned, check the test equipment settings before blaming the circuit, especially if it’s not test equipment you’re familiar with. You’ll see the attenuated voltages from here until almost the end. I wanted to keep the oscilloscope screenshots as they were taken rather than go back to replicate them with the probe set correctly, as I did say I would show all the goofs in this series!

Now that we verified that the circuit is amplifying the signal, it’s time to clean it up. I’m moving the oscilloscope probe between the two amplifier stage outputs to see the response. It’s an iterative process of first looking at the output of the first amplifier stage and turning the multi-turn pot’s adjustment until the output is looking as square as possible, then going to the second stage and turning the resistor between the stages until the signal looks as good as possible, and finally turning the feedback resistor for the second stage. This is repeated many times and at several frequencies well beyond what we expect the circuit to see in order to get the best tuned values we can.

25khztest.jpg

Now, at 25kHz, the response curve is looking about as good as it can. The small spikes on the trace are caused by some interference from the LED magnifying lamp I’m using as a light source on my workbench. I’m not sure if it is conducted through the power lines, is radiated electromagnetically, or if the LEDs are emitting some infrared light which is influencing the photodiode, either way, it doesn’t have any bearing on the actual circuit’s functionality.

Running my function generator with a 35% duty cycle, 5kHz square wave gives a 39.36us pulse for me to work with. This closely replicates the time of the BB traveling through the light gate, and should give a good indication of the signal edges the microcontroller will have to work with.

39usTest.jpg

It looks pretty good, and it was right about this point that I realized the attenuation switch on the probe had shifted earlier on during testing! This looks exception, and we have a 2.7-3.3v signal depending on how much light is hitting the sensor, and if I cover the sensor + led with a white box or not (amplifying the light).

Once the resistor values were well tuned, I switched out one of the capacitors as well, so I need to measure the multi-turn pot resistance and then re-draw the schematic for later reference. The schematic doesn’t need to be a perfect drawing, mine is just on a post-it sticky note giving me something to refer back to later.

While writing this, I’ve realised that since the LED will always be on and the BB will block the light, the signal here is the inverse of what we will expect in the actual tracer unit. This doesn’t really matter, however, as our edges look good on both sides.

DSC_1037_DxO_web

This could be a good stopping point for tuning the circuit, however, these resistor values don’t represent real-world sourceable values. I also need to build a second amplifier circuit so I can test fire a BB between two sets of gates, so I’ll build a second circuit with the values of resistor I have on hand.

real-values.jpg

Here’s a slightly lower duty cycle 5kHz signal with the circuit implemented using commercially available resistor values. I’ve also dropped the capacitance of the inverting charge pump which is also noticeable.

DSC_1041_DxO_web

The commercially available resistor values give us a good leading edge, but a poorer trailing edge. This will still be more than acceptable for triggering a microcontroller interrupt as far as I’m concerned. However, it will be interesting to see what it looks like when a BB travels past, as we may need to change resistor values to sharpen up the trailing edge.

Mock Suppressor

The final circuit boards of this project will be integrated into a mock suppressor attached to the replica firearm. For now, I need a way to mount the IR emitter and photodiode to the rifle to see what it looks like on the scope when a BB passes through. I designed a quick attachment for the end of a rifle barrel to hold the IR emitters and photodiodes a known distance apart. We said in the last article that the battery would determine the minimum length of the suppressor at 80mm, so I used that length with the photogates 6mm in from either end. 

suppressormockup

I wasn’t sure how straight I’d be able to get the part pressed onto the end of the rifle, so I made the bore through 12mm in diameter, as I didn’t want one of my very limited IR emitters or photodiodes to be damaged by a BB impact if I didn’t get the unit on straight.

DSC_1048_DxO_web

There’s nowhere to mount any UV LEDs, nor is there any intention to. This is just to test the photogates we are building against real-world conditions to ensure the amplifiers are going to be able to catch the passage of the BB.

DSC_1052_DxO_web

I printed the mock suppressor in PET-G with 0.3mm layers to reduce the print time. This gives a bit of an ugly print but it’s only the function we care about at this point of the project. I used hot glue to attach the IR emitter and photogate into the 3D printed adapter, then wired them up to the breadboard so we can start testing. I tried to keep the wires short enough to not allow much noise to be picked up, or have any odd effects on such a small signal from the photodiode, while still being long enough to manipulate the rifle attached to it without constantly disconnecting the cables that are just pushed into the breadboard.

45bb.jpg

My first test is with a 0.45 gram BB, which is the heaviest I have and therefore will travel the slowest. It’s worth noting I’m running the IR emitters at only about 40mA current, rather than the 150mA they are rated for, and that the emitter and photodiode are about 18mm apart. In the final board, the emitter and diode will be much closer, and I will most likely drive the emitter at a higher current. This will give a larger voltage range, allowing for clearer readings. As channel 1 (yellow) is looking a bit low voltage in my current temporary setup, there may also be some hot glue over the photodiode! Those are things that can be optimized and tuned on the final board, but at this point, I’m most interested in the response curve looking like something a microcontroller will trigger on.

32bb.jpg

My next heaviest BB is a 0.32g, and that is definitely traveling faster.

20bb.jpg

Finally, we have the 0.2g BB, which is traveling quite fast. How fast?

20bbspeed.jpg

If I add cursors to the oscilloscope display we can see the travel time is 444 μs to cover the 68mm distance between gates. That’s () 153.2 m/s or 502 feet/second. It sounds like it’s in the right ballpark area for a 0.2g BB, but to make sure, we can check with a 0.45g BB.

45bbspeed.jpg

The 0.45g BB covers the 68mm in 695us, which means it’s traveling at 97.84m/s or 321fps. This is the rifle I regularly play with, and I know I shoot at 320 fps ± 3 fps, as we must perform a chronograph test prior to playing to ensure our guns are safe and legal.

doublefeed.jpg

When testing the 0.2g BB, I accidentally double fed the gun, putting two BBs down the barrel at once. I thought this was actually pretty interesting to see, as having two BBs come down the barrel could definitely cause some issues in software if we get a second pulse on the first photogate before the second photogate has been triggered. I would have thought the two BBs would travel with the rear BB pushing the first one out, however, it looks like they were separated by at least the gate distance as they went down the barrel. This is definitely an edge case which we will need to account for in the firmware. We will need to ensure that a second pulse coming through the first gate before the second is triggered will not cause a race condition or leave the code in a bad state. This is the sort of event that real world testing highlights well, as using a function generator to provide the pulses will never cause these events to happen.

At this point, I’m happy with the performance of the photogate and know that it will perform well on a circuit board with perhaps some minor tuning of the feedback resistor values.

LED Power Supply

In part 1, I was very unsure of the LED power supply. I chose the TPS92691 LED driver as it has good performance characteristics for driving an LED, but with the soft start, it looked questionable whether or not it would be able to be switched on and off fast enough for the purposes of this application. I bought the TPS92691 evaluation module to give me a chance to try it out before committing to the design. If the part doesn’t work the way we want it to, and we commit to a PCB using that part, it will mean a revision of the PCB at the least.

As the UV emitters we’re going to use in the project are not particularly cheap, wouldn’t be easy to use in a breadboard or solder wires to, and emit light of a frequency that is rather harmful, I bought a pack of cheap white LEDs from an online marketplace that have similar current draw and forward voltage. They will make great stand-ins for the UV emitters.

My first test was to connect the eval module up to the LEDs and just switch the power supply on and off. The LEDs lit up very bright and current regulation was good. Once I knew the board was functional, I added an N-Channel MOSFET to a breadboard to allow my function generator to bring the shutdown pin to ground, disabling the driver. This will make it possible to rapidly turn the driver on and off by connecting a function generator to the gate of the MOSFET.

DSC_1045_DxO_web

At 5Hz, also known as ‘Disco Mode’, everything was working great. How about a higher frequency?

tpsdrv100hz.jpg

At just 100Hz, far below the speed we will need, the driver failed to either switch fully on or fully off. It was stuck in a limbo state of soft start and capacitor drain. 

DSC_1046_DxO_web

I had suspected this would be the case, so I shifted the MOSFET from pulling the shutdown pin to ground to instead pull the LED string to ground.

tpsdrvledgnd.jpg

That did not go as I had hoped. The driver is very confused by the lack of load with a sudden appearance of load. It gets itself into a state of doing a massive voltage spike to its maximum output voltage around once per second. It has no real correlation between the function generator’s signal and the LED power, and the ramp time is so long (almost 20ms) that it rules the TPS92691 out as an option for powering our LEDs.

The development kit for the TPS92691 was not cheap, but it was well worth the cost as a fully populated and useless circuit board would have been substantially more expensive.

Next Steps

I suspected the TPS92691 might not do what we needed when I was purchasing components. I had hoped it would but planned for it not to. I also picked up an STMicroelectronics STEVAL-ILL063V1 evaluation board, which was relatively cheap. I don’t know that it will do any better than the Texas Instruments part did, but it’s worth a try. This is a much simpler driver and evaluation kit, so I speculate that perhaps being less feature-rich it might cope with my less mainstream usage a little better.

The evaluation kit has VIN, GND, DIM and the LED positive and negative terminals. Given the simplicity of the terminals I’m going to jump straight to testing the board with the LEDs connected to the dev board and FET.

I powered up the evaluation board with the LEDs connected, and they are shining nice and bright. Now that the kit is proven to be functional, it’s time to try toggling the MOSFET from the function generator.

functiongen20hz.jpg

Before we get to that though, I just wanted to share the scope screenshot with no power connected to the evaluation kit. You’ll see why in the next screenshot.

noisy.jpg

Not only does the evaluation kit not react well to even 20Hz of control, but it’s also generating a significant quantity of electrical noise. The noise could potentially be dealt with in-circuit, however, it’s well beyond what I’d want to try to deal with on a very compact circuit board next to extremely sensitive signals (such as those from our photodiode). The fact that the driver doesn’t work as we wanted is slightly irrelevant at this point.

We’re now two dev kits down, and I don’t hold a lot of hope that a traditional LED driver will be able to react to the rapidly changing loads as we need. At this point, I have to ask myself, do we even need current regulation? With a maximum pulse time of around 640us, the LEDs should not be getting to the point of overheating. Essentially, we will be running pulse width modulation on the LEDs, with a pulse of the BB travel time, and a period equal to the time between shots leaving the gun. 

Obviously, we could easily add some crude current limiting with an LM317 or an LM334, or even more efficient current limiting with some op-amps and transistors, however, those solutions all add thermal loads and board space requirements I’m not sure we require to the project. I typically chase an ideal solution and use more components than are strictly required to make a functioning circuit, so I’m curious to try the other approach of issuing the bare minimum possible. 

Current limiting has always been so critical in running powerful LEDs in products I’ve worked on that it’s very hard for me to consider running these LEDs without some form of current limiting. Therefore, I’ve set up an experiment with my cheap LEDs to run overnight: for 10 hours, I’m going to pulse the LED on for 640us, and off for the rest of a 20ms period, which should give me 1.8 million LED flashes. If the cheap LEDs survive 1.8 million unregulated flashes, I feel as though I can safely run the UV emitters without any current regulation. While the forward voltage of these LEDs is the same as that of the UV emitters, the current is about only one third of the UV LEDs’. The higher power UV LEDs, however, will have a PCB to sink heat into. To be safe, I’ve set the LEDs on a ceramic dish and left them run unattended. The LEDs definitely need to run unattended as the pulse intensity and rate are headache-inducing after just a couple of minutes.

The Next Day

Exactly 10 hours later, the LEDs are still fully functional and only slightly above the ambient temperature. These are very cheap LEDs and I’m not sure if that makes them more or less robust than a relatively expensive UV LED. I’m going to take the gamble and skip the constant current supply, keeping in mind that if things don’t go well then we will need to revise the design after the first prototype circuit boards have been assembled. 

I ended up spending a couple of days reading technical journal publications and white papers trying to find what actually causes LEDs to fail, specifically UV emitters, and the research was fairly frustrating. The vast majority of literature on failure modes of LEDs and non-visible light emitters (IR and UV) are more focused on the entire lifecycle and degradation over tens of thousands of hours of usage. I’m more interested in the effects of doing bad things to the LED, like giving it too much current. It appears that LEDs are not particularly fussed about overvoltage, where most can handle significant ESD events in the forward direction but fail almost instantly if reverse biased. There are some mentions of overcurrent damaging the silicon through electromigration which is broadly classed under electrical overstress. I feel as though the short pulse duration and the extremely long period between pulses are going to be fine for this application. Even if my friend shoots 3000 BBs a day, which is a lot, we’re looking at around 2.04 seconds of total LED on time if his gun is slightly broken and the BB takes 680us to travel past the LEDs (I expect it will be under half this time). If he played one day per weekend, it’s just 106 seconds per year, or a bit under 18 minutes per decade of LED on time. 

So this has quickly become an interesting engineering trade-off, for me at least. By not utilizing current limiting, we could be drastically reducing the expected lifetime of the UV emitters, but at the same time, a decade of use is only going to be 18 minutes of total on time for emitters rated for tens of thousands of hours of use. Furthermore, as the battery depletes and its voltage exponentially gets closer to the emitters’ forward voltage, the current draw of the LEDs will also drop off exponentially.

Next Steps

The next article should be a lot shorter as we look at the firmware for the project. We’ll be trying to capture the photogate response with a microcontroller interrupt. I’ve had some issues in the past with platform-specific bugs using the MBED online compiler platform that could affect this, if I run into any issues I’ll switch compiler as it’s not worth the development time on a one-off project to fight bugs in platform libraries.

Once we have the very basics of the firmware designed, we’ll be getting into capturing the schematic, PCB layout, and finally building and using the project!

There’s still lots of interesting decisions to be made, and the fun of the hardware design and testing to come. I hope you’ll continue following along as we continue the project build.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Using PWM for DC Motor Control

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - Using PWM for DC Motor Control

Average DC value for different duty cycle

DC motors convert electrical energy to mechanical energy, and the speed of a DC motor is directly proportional to the value of the input DC voltage. The direction of rotation depends on the polarity of the input voltage. In many applications, you may want to control the speed or direction of rotation, and you can use pulse-width modulation (PWM) with an H-bridge as an easy technique for controlling speed and direction. In this article, we will examine what is PWM and how to use PWM for DC motor control.

What is PWM?

There are many types of modulation schemes that can be used to periodically change some aspect of a digital or analog signal (frequency modulation, amplitude modulation, phase modulation, etc.). As the name suggests, PWM is a type of modulation in which the width of the pulse is changed without changing the frequency (i.e., the repetition rate) of the signal. The amount of time the signal is in the HIGH state is called the duty cycle. As we will see, this quantity is fundamental in using PWM for DC motor control.

Using PWM causes the average DC value of the signal to change when passed through a low pass filter. If such a signal is fed to a DC motor, we can change the speed of the motor by changing the duty cycle of the PWM signal. The change in pulse width is created by increasing the on-time (HIGH value) of the pulse while reducing the off-time (LOW value) by the same amount so that the frequency of the signal is constant. Increasing the on-time increases the average DC voltage value of the signal, and vice versa. The following figure shows the variation in the average DC value with duty cycle.

Average DC value for different duty cyclesAverage DC value of a PWM signal for various duty cycle values.

A simple relation to calculate the average DC value is

pwm-eq1

where, V(REF) is the value of logic high. This allows analog control of a DC motor via digital signal, making it possible to use microcontrollers to drive DC motors. A microcontroller can change the pulse-width dynamically, providing an instant or steady change in the corresponding DC motor speed. We can see how output voltage changes dynamically with duty cycle:

pwm2DC motor speed vs. duty cycle

Amplifying the PWM output

Unfortunately, it is not possible to use the microcontroller output to drive a DC motor directly as the current is typically too low to drive the motor. In addition, all DC motors have a start voltage that guarantees the motor will begin moving in any orientation. In many cases, the output from a microcontroller might not be strong enough to start the motor.

Usually, a PWM signal is used to drive a BJT or FET switch that connects the DC motor to a high supply voltage. The voltage reaching the DC motor supply in this case becomes

pwm-eq2

The circuit for making this connection between the PWM output and the DC motor is shown below:

Schematic for a MOSFET driver circuit for using PWM for DC motor controlSchematic for a MOSFET driver circuit for a DC motor. Image source.

Using an H-bridge to Control Direction

If we need to control the direction of the motor, we need to reverse the current through it and the most common way to do it is using an H-bridge. The H-bridge contains four switches in a bridge type configuration with motor in the center.

PWM4An H-bridge for motor control

By selectively turning on different switches, we can change the direction of the current and hence the direction of motor rotation. This can also be used to put a sudden brake to the motor or let the motor freely run until it stops due to friction. Closing switches S1 and S4 will rotate the motor one direction, and vice versa when S2 and S3 are closed. The motor will break when you close switches S2 and S4 with the other switches open, or when you close S1 and S3.

If you like, you can digitally control the direction of the motor by placing transistors in the above H-bridge circuit in place of mechanical switches. For example, when transistors at S1 and S4 output HIGH, the motor will conduct in the same way as if mechanical switches were closed. The same can be said for the remaining switch configurations.

Using PWM for DC Motor Control in Your Next Project

Now that you have a fairly good idea of how to use PWM to drive a DC motor and construct an H-bridge for an additional degree of freedom, you can easily build a digital circuit for directional control and to amplify the input voltage to start the motor. This requires a PWM source and 5 discrete transistors. You can also use a microcontroller (such as those built into an Arduino) to generate a PWM signal and numerically control the duty cycle. If you don’t want to build the directional control circuit yourself, you can use a 298N dual H-bridge DC motor driver. An example of this project can be found here.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

PCB Design for Manufacturing: What Every Designer Should Know

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - PCB Design for Manufacturing_ What Every Designer Should Know

You’ll want to make sure your boards can hit the production line by following PCB design for manufacturing guidelines

PCB design for manufacturing refers to a large set of design processes, where the goal is to ensure your PCB layout is fully manufacturable. Some people like to bifurcate DFM into design for fabrication (DFF) and design for assembly (DFA), but DFM spans all of these issues. Following important DFM guidelines will help you avoid redesigns and move to production quickly.

In today’s consumer market, getting a product out in time is key to grabbing a customer’s attention and remaining competitive. If you’re an entrepreneur about to release a new product, your time to market can give you a major advantage over your competitors. Any troubles during manufacturing will require a rerun through the manufacturing process and extend the time to market. By following the DFM guidelines for PCBs, you can reduce the chances of failure and increase your yield. Let’s take a look at the DFM guidelines every designer should know so that your next layout can pass DFM review with flying colors.

Why is DFM Required When My Design Already Passed DRC?

This is the very first question a designer will ask when given set of DFM checks along with the usual design rule checks (DRC). The difference here is that DRCs are a set of electrical rules that are intended to ensure design functionality. DRCs look for existing design issues from an electrical perspective, while DFM identifies any features in a layout that can’t be fabricated with standard PCB manufacturing processes.

DRC errors normally manifest themselves during the PCB layout phase, while DFM issues might not come up during a DRC. In other words, a given layout could pass your DRCs, but that doesn’t mean it will be manufacturable. Traditionally, manufacturers took it upon themselves to fix DFM problems in your layout, but this can create new problems as designs become more complex. As a layout designer, you should actively avoid DFM issues when creating your PCB layout rather than rely on a manufacturer.

Important PCB Design for Manufacturing Considerations

There are some DFM defects that you should check in any design. After some practice, you’ll learn to identify many of these problems quickly as you build your PCB layout.

Acid Traps

Acid traps in a PCB are basically acute or odd angled spaces or small features in your design that can cause acid to pool during etching. The residual acid gets caught in these areas and doesn’t get washed away. As a result, the copper around these areas starts to erode, creating open or high impedance connections. With smaller and thinner trace, it is easier for residual acid to form an open circuit.

Solder bridge between two pins
Acid trap created due to an acute angled trace routing

Some software has built-in DRCs for this particular issue. If yours doesn’t, then manually watch for potential acid traps and make sure to remove all odd trace angles on square pads.

Islands

These are free floating areas of copper on plane layers. Any copper pour that is disconnected from ground can also qualify as an island. If these areas are large enough, they might act like an antenna, causing noise and other interference within the board.

islandIsland creation due to disconnected copper

Solder Bridges Between Pins

High pin-count ICs have tight pin pitch. Therefore, it is essential that solder mask be included between pins in the PCB layout. The solder mask can act like a dam that prevents a large blob of solder from falling between pins and creating a short.

Solder bridge between two pins
Solder bridge between two pins on an IC. Image source: sparkfun.com.

Copper-to-Board Edge Clearance

Much of the PCB manufacturing process is automated. The copper-to-board edge clearance is the space where automated equipment grips the board and transports to other processing equipment. If there is insufficient space, then shorts can be created when current is applied to the panel during the electroplating process. The space requirement depends on the equipment being used for board transportation. Be sure to contact your fabrication house to get these specifications.

Thermal Paste Masks on Heat Sinks

Heat sinks remove heat from an electronic component through direct contact with a metal or thermally conductive paste. If the paste mask opening is too big for the heat sink, the molten solder might cause the component to float off the pad during the soldering process. This can create lots of wrong connections. Try to divide the paste mask opening into several small ones.

Cold Solder Joints or No Solder Connections

Any vias on a pad can cause solder paste to wick through the via suring assembly. This will result in a cold solder joint or an unsoldered connection. Therefore, you should check how close a via hole can be to a pad. Via-in-pad is normally use in HDI designs, otherwise the via will be connected to a pad with a small trace. If your tool doesn’t check for this, makes sure to do this check manually based on your assembly house’s requirements.

Insufficient Annular ring

An annular ring is the area of copper pad around a drilled and finished copper plated via. The primary purpose of an annular ring is to create a strong connection between a via and the copper trace. There should be enough copper around a via to form a solid connection between the copper traces and the via in a multi-layer PCB. If the drill size is larger than the size of the pad being drilled, the pad can disconnect from the via barrel or the internal signal/plane layer. You can learn more about annular ring requirements in this article.

 

Appropriate drill size for a given annular ring
Appropriate drill size for a given annular ring. Image source: pcbway.com.

Your PCB Design for Manufacturing Checks and Your Design Software

It is always a good idea to use a PCB design platform that provides important DFM checks. Don’t forget to contact your fabrication house and ask them about their DFM requirements. Taking care of these problems early can prevent an unnecessary redesign and improve the quality of your finished board.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Project Design: Complete IoT Temperature Logger for Beginners, Part 1

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - Project Design_ Complete IoT Temperature Logger for Beginners, Part 1

I have a confession to make for this project: I love collecting data, storing it, graphing it, and getting as much of it as possible. Altium Upverter® has a lot of users who are relatively new to circuit board design, which is fantastic, so I wanted to create a beginner project to introduce less experienced makers to my love of collecting data. We’re going to build a wireless temperature logger that will store data in a web platform, which we will build ourselves, thus allowing us to graph temperature over time, as well as allowing us to see the current temperature where each sensor is.

Embedded programming can be intimidating, especially when it involves wireless networks and web requests, so we’ll be making use of the excellent .NET nanoFramework to make development and debugging incredibly easy. I’ve wanted to use the .NET nanoFramework in a project since writing the article on high level programming languages in embedded projects on the Altium blog. This is a perfect project to use a high level language for, as it keeps the code very simple, easy to debug, and makes what could be the very complicated task of interfacing with a WiFi network and accessing the internet with it much simpler. Not to mention, using the .NET nanoFramework will make us able to rapidly write and test firmware for the device as we prototype it, and refine that firmware on the circuit boards we design and build without much stress.

If you’ve never built a website before, you might be a little worried about the idea of building a web platform to log the data we collect. Don’t worry, I have set up the guide for that part of the project to be easy to follow, and put two different paths that you can follow depending on your preference, and that will result in the same functionality and appearance: an ASP.NET Core with WebAPI based platform, and a PHP based platform. Both are built on open source technologies, and both will run on Windows, Mac or Linux. We will be using this web platform in a range of IoT projects in the future, so we will be building it to be extensible and operable with multiple sensor types. Everything in this project will be open source, and you will be able to freely use it and modify it for personal or commercial use.

Following along with this project will give you an excellent starting point for future projects that need to collect data, log it to a remote server, and present it to an end user. Whether you’re building an industrial asset tracker or agricultural crop monitor, you’ll be able to use this project as a starting point for your hardware, firmware, and web design.

Specifications

The specifications for this project are broad, but very simple. As I mentioned in my Guide to Starting New Projects, typically for the projects I write about, I state the overall goal of the project, then proceed on to component selection. However, we have a few different segments that make up this project, so we can break down the specifications a little more precisely.

Hardware

The hardware for this project needs to be able to connect to a wireless network, take temperature readings, and send those readings to a website. It would also be very nice to display the temperature reading on a screen as well. The final hardware should also be in an enclosure for protection, which we can 3D print to suit the board we design.

The temperature sensor within the device should be as accurate as possible, and capable of reading from -30°C to +50°C.

Firmware

The firmware for the device will need to store temperature readings locally, but not necessarily in non-volatile storage, so if there are technical difficulties with the network or website, we don’t lose data that was unable to be submitted at the time of recording. 

The firmware should take temperature readings at regular intervals and both display the current temperature on the display and upload the reading to the website.

Web

The website should have a dashboard that is able to display the current reading for each device, as well as a graph of the temperature for the past day. Each device should be able to be viewed individually, showing the full temperature history it has recorded.

Users should be able to register for access to the portal, as well as login. User registration should require email validation to be completed prior to the user being able to login.

An admin user should be able to add new devices to the system as well as edit or remove existing ones. The recorded data types should be configurable through the web interface rather than hard coded, so additional device types can be added in the future. 

Component Selection

Given the relatively simple nature of the device we’re building, there are not very many component decisions we need to make. That being said, this project does need some components so let’s take a look at what we might need.

Microcontroller

As I’ve already made the decision to utilise the .NET nanoFramework for this project, our choices for a microcontroller are limited to those that the community has built support for. For this project, the ESP32 looks to be exactly what we need, it’s very low cost, has integrated WiFi, is supported by .NET nanoFramework, and offers options for a pre-certified module version of the microcontroller. There isn’t much point looking into other options when the ESP32 has so many great features for this project.

We’ll start off with the ESP-WROOM32 based DEVKITC for the ESP32, which should give us everything we need to prototype the device.

Display

There are many different types of displays we could utilize for this project, from the humble 16×2 character display up to a nice touch screen TFT display. However, this is a simple project with simple goals, so I want to use the 1.8inch 128×160 pixel color TFT display based on the ST7735S controller that I’m using in the thermal camera project that you can find on my blog. I haven’t tried using this display with the .NET nanoFramework before, but it is a SPI display so it should be a good choice. 

Temperature Sensor

The key component in this device is of course the temperature sensor. There are many routes we could take for a temperature sensor—on the budget side of things there are thermistors, moving up to analogue temperature sensors with built in compensation. From there, we can start looking at low cost digital temperature sensors which use I2C or SPI to communicate with the microcontroller, and on into the premium grade digital temperature sensors.

I feel given this project is beginner oriented a basic digital I2C sensor is going to do the job nicely. These generally give far more precise readings than an analogue sensor, as the conversion is completed by the sensor itself, along with the algorithm to convert the analog voltage into a temperature measurement.

A sensor such as the very simple TMP102 will do the job very nicely. If you want to take the project to the next level, you can optionally implement a temperature and humidity sensor such as the Si7021 which is very popular. 

Power Supply

Our device is going to need some form of power, as this project is beginner oriented, we’re not going to delve into making this a battery powered IoT device. The component options we’ve selected would definitely support being battery powered, however we just want to keep this project simple. As such, I think a simple micro USB connector will be adequate for powering the wireless sensor. If we need to make it portable, an external battery pack/power bank would suit our requirements.

For prototyping purposes, this means we don’t need to order any extra components, as the microcontroller dev kit is also USB powered, and we can utilise the supply from it to power our sensors.

When we layout the PCB, we will need a 3.3v voltage regulator to drop the 5v from the USB line to a usable level, however there are a myriad of low cost linear voltage regulators that will do the trick.

A linear regulator has no engineering risk as far as I am concerned, as such, it’s not something I would include in my prototyping BOM. If we were designing and building this device for a client or mass production, it would be helpful to include the LDO at this point so that it could be considered from a budgetary point of view.

The High Level BOM

Our major components for the device are now selected, and we’re looking at utilizing:

  • ESP32 wireless microcontroller
  • ST7735S based display
  • TMP102 temperature sensor

I’ll order the dev kit and breakout board for the sensor, and while we wait for those to arrive, we will get started on a web interface to receive the data.

Next Time

In the next article in this series, we’re not jumping into the electronics, as we need to build the web platform first. To test the electronic design, we’ll need to have a web API to call in order to prove the connectivity portion of the design. We will start with the ASP.NET based platform, as the code created for that can be reused in the .NET nanoFramework code we’ll be running on the ESP32 microcontroller. The PHP based IoT portal will follow at a later date, as the project progresses.

After the ASP.NET IoT portal has been created, we will get back to electronics. We will prototype the temperature sensor design on a breadboard to prove out the schematic and firmware prior to designing a PCB in Altium Upverter.

If you’re not interested in building the IoT portal yourself, the complete code will be available on GitHub for you to use if you want to follow along with the hardware development of this project, or use it for any other project you have in mind.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.