Circuit Design Archives | DMC, Inc. https://www.dmcinfo.com/blog/category/embedded-development-programming/circuit-design/ Thu, 05 Feb 2026 16:02:02 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.3 https://cdn.dmcinfo.com/wp-content/uploads/2025/04/17193803/site-icon-150x150.png Circuit Design Archives | DMC, Inc. https://www.dmcinfo.com/blog/category/embedded-development-programming/circuit-design/ 32 32 MOSFET Power Loss Calculator https://www.dmcinfo.com/blog/17021/mosfet-power-loss-calculator/ Mon, 27 Nov 2023 09:10:29 +0000 https://www.dmcinfo.com/blog/17021/mosfet-power-loss-calculator/ Online MOSFET Power Loss/Dissipation Calculator and Guide for Engineers In the world of power electronics, understanding and minimizing power losses in Metal-Oxide-Semiconductor Field-Effect Transistors (MOSFETs) is crucial for optimizing efficiency and performance. This guide explains the basics of calculating various types of power losses in MOSFETs, including conduction, switching, reverse recovery, deadtime, and gate charge […]

The post MOSFET Power Loss Calculator appeared first on DMC, Inc..

]]>
table input[type="number"], table select, table input[type="text"] { font-size: 14px; padding: 4px 6px; min-width: 90px; } #share-tools { margin: 12px 0 20px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } #project_name, #share_button, #share_link { font-size: 14px; padding: 4px 6px; height: 28px; box-sizing: border-box; } #project_name { min-width: 240px; } #share_link { flex: 1 1 260px; min-width: 260px; max-width: 520px; } #project-name-row { margin: 8px 0 12px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } #loss-bar-container { margin: 14px 0 6px 0; width: 100%; max-width: 1100px; } #loss-bar { display: flex; height: 20px; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; background: #f5f5f5; } .loss-segment { height: 100%; min-width: 0; } #loss-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 6px; font-size: 12px; } .loss-legend-item { display: inline-flex; align-items: center; gap: 6px; } .loss-swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; } #thermal-container { margin: 18px 0 10px 0; width: 100%; } #thermal-table { border: 1px solid #ccc; border-collapse: collapse; width: 100%; } #thermal-table th, #thermal-table td { border: 1px solid #ccc; padding: 6px; text-align: left; vertical-align: middle; } #thermal-table input, #thermal-table select { padding: 4px 6px; font-size: 14px; min-width: 90px; } #thermal-table .help { font-size: 14px; color: #444; } #thermal-status { font-weight: 600; } #main-table, #thermal-table { width: 100%; box-sizing: border-box; } /* Keep main and thermal tables aligned */ col.col-param { width: 22%; } col.col-value { width: 22%; } col.col-units { width: 15%; } /* Consistent cell styling across both tables */ #main-table th, #main-table td, #thermal-table th, #thermal-table td { padding: 6px; text-align: left; vertical-align: middle; border: 1px solid #ccc; font-size: 18px; font-family: inherit; } /* Definition blocks as cards */ .param-block { margin: 12px 0; padding: 12px 16px; border: 1px solid #ddd; border-radius: 20px; background: #fafafa; } /* Parameter name at the top of each card */ .param-name { margin: 0 0 6px 0; font-weight: 600; font-size: 15px; } /* A row: label on left, text on right */ .param-detail { display: flex; align-items: flex-start; gap: 12px; margin: 6px 0; font-size: 16px; line-height: 1.5; } /* Left column: fixed width, bold label */ .param-detail em { font-style: normal; font-weight: 600; color: #333; flex: 0 0 130px; text-align: right; } /* Right column: fill remaining width */ .param-detail span { flex: 1; } /* Calculation blocks styled similarly to cards */ .calculation-block { margin: 16px 0; padding: 12px 16px; border: 1px solid #ddd; border-radius: 20px; background: #fdfdfd; } .calculation-block h4 { margin-top: 0; margin-bottom: 8px; } .formula { display: inline-block; margin: 4px 0; padding: 4px 8px; font-weight: 600; font-family: Consolas, "Courier New", monospace; font-size: 14px; border-radius: 3px; background: #f3f3f3; } /* Consistent heading spacing in definitions section */ h3.wp-block-heading { margin-top: 24px; margin-bottom: 8px; } h4.wp-block-heading { font-size: 16px; margin-top: 0; margin-bottom: 6px; } @media (max-width: 600px) { table input[type="number"], table select, table input[type="text"] { font-size: 8px; padding: 2px 4px; min-width: 40px; } #main-table th, #main-table td, #thermal-table th, #thermal-table td { padding: 4px; font-size: 8px; } #thermal-table .help { font-size: 8px; } #thermal-table input, #thermal-table select { padding: 2px 4px; font-size: 8px; min-width: 40px; } }

Online MOSFET Power Loss/Dissipation Calculator and Guide for Engineers

In the world of power electronics, understanding and minimizing power losses in Metal-Oxide-Semiconductor Field-Effect Transistors (MOSFETs) is crucial for optimizing efficiency and performance. This guide explains the basics of calculating various types of power losses in MOSFETs, including conduction, switching, reverse recovery, deadtime, and gate charge losses.

MOSFET Power Loss Calculator

Power Loss Breakdown (largest to smallest)
Conduction Switching Reverse Recovery Deadtime Gate Charge Output Capacitance
Parameter Value Units Description
Vbus Volts Bus voltage
Current Amps Current
f_sw Switching frequency
Vgate_drive Volts Gate drive voltage
Rds(on) Drain-to-source on resistance
Qg Gate charge total
Td(on) Turnon delay time
Tr Rise time
Td(off) Turn-off delay
Tf Fall time
Qrr Reverse recovery charge
Vsd Volts Body diode Forward Voltage
Coss Output capacitance of the MOSFET
Conduction Loss (P_cond)   Watts Power loss due to conduction
Switching Loss (P_sw)   Watts Power loss during switching
Reverse Recovery Loss (P_rr)   Watts Power loss due to reverse recovery of the body diode
Deadtime Loss (P_dt)   Watts Power loss during deadtime
Gate Charge Loss (P_gate)   Watts Power loss due to gate charge
Total MOSFET Power Loss   Watts Total power loss in MOSFET
Thermal Check (does not affect power loss calculations)

The thermal section does a quick “what will my junction temperature be?” check using the total power loss you calculated. You supply the thermal resistances and ambient temp; it multiplies total loss by the chosen Rθ, adds ambient, and shows ΔT, estimated Tj, and whether you’re under your limit.

Not sure which numbers to use? RθJA comes straight from the MOSFET datasheet and assumes the part is soldered to the datasheet’s test PCB (usually no custom heatsink). RθJC is also from the datasheet (junction to the case). RθCA is your own path from case to ambient; your heatsink, board, and airflow. If you don’t have a heatsink model, pick RθJA. If you do, choose RθJC + RθCA so the heatsink path is included.

Parameter Value Units Description / Help
Mode JA = datasheet junction-to-ambient (often bare PCB). JC+CA = datasheet junction-to-case plus your heatsink/board path.
RθJA °C/W Datasheet Junction-to-Ambient. Soldered to PCB, no custom heatsink model.
RθJC °C/W Datasheet Junction-to-Case.
RθCA °C/W Case-to-Ambient for your heatsink/board/airflow.
Tamb °C Ambient temperature around the MOSFET.
TJ,limit °C Chosen max junction temperature (125 to 150°C typical).
ΔT °C Temperature rise from total loss × thermal resistance.
Estimated TJ °C Tamb + ΔT. First-order estimate.
Rθ used °C/W The active path (JA or JC+CA) used for the estimate.
Status Enter values to estimate junction temperature.

 

Parameter Definitions & Loss Formulas

Electrical Parameters

Vbus

What it is The bus or supply voltage applied across the MOSFET and its load. It is the electrical “push” driving power through the system.

Why it exists A power stage needs a voltage source to move energy. Vbus sets the maximum voltage the MOSFET must block and switch.

How it affects performance Higher Vbus reduces current for the same power which lowers conduction loss. At the same time, higher Vbus increases switching loss because the MOSFET spends time switching with both voltage and current present. It also stores more energy in the MOSFET internal capacitances that must be charged and discharged every cycle, and MOSFETs rated for higher voltage usually have worse on resistance and higher cost.

Design implications Higher Vbus improves conduction efficiency but raises switching stress. Lower Vbus helps switching efficiency but increases current. Choose Vbus based on topology, switching frequency, and power level.

Practical ways to optimize it Pick MOSFETs with enough voltage headroom, minimize stray inductance in layout, and select a switching frequency that balances conduction and switching losses.

Current

What it is The current flowing through the MOSFET when it is on. This is the MOSFET main job, passing load current from drain to source.

Why it exists The MOSFET forms the controlled conduction path that sends energy to the load.

How it affects performance Conduction loss rises with the square of current. Higher current increases temperature rise and stresses the package, and layout resistance becomes more important as current climbs.

Design implications Your system voltage and power requirements set the current. The MOSFET must be chosen to handle this current without excessive heating.

Practical ways to optimize it Use thicker copper, shorten high current paths, parallel MOSFETs when needed, or increase Vbus to reduce required current.

f_sw

What it is The switching frequency. It is how many times per second the MOSFET turns on and off.

Why it exists Switching allows the converter to control voltage and power. The frequency sets how quickly regulation can respond.

How it affects performance Higher frequency shrinks magnetics which saves size, but higher frequency increases switching loss because the MOSFET transitions more often and increases heating and EMI.

Design implications Frequency is a major efficiency lever. Use the lowest frequency that still meets your size, noise, and control requirements.

Practical ways to optimize it Use MOSFETs with fast transitions, improve layout to reduce ringing, and use a gate driver with enough current for your chosen frequency.

Vgate_drive

What it is The gate to source voltage applied by the gate driver. It controls how strongly the MOSFET turns on.

Why it exists A MOSFET channel forms only when the gate is charged. Higher gate voltage strengthens the channel.

How it affects performance Higher gate drive reduces on resistance. Very high gate drive increases gate charge loss and can damage the gate if it exceeds limits, and too low gate drive prevents full enhancement which increases heating.

Design implications Use the recommended gate drive voltage from the datasheet. More is not always better.

Practical ways to optimize it Use a gate driver capable of delivering enough current, ensure clean gate traces, and follow safe operating limits for the MOSFET.

Rds(on)

What it is The drain to source resistance when the MOSFET is fully on. It is an unavoidable resistive component of the channel.

Why it exists The channel is made of doped silicon and has finite resistance. Larger silicon area reduces this resistance.

How it affects performance Lower Rds(on) reduces conduction loss directly. Larger die area that gives low resistance often increases gate charge and capacitance, which can increase switching loss, and Rds(on) increases as temperature rises.

Design implications Lower Rds(on) is great for high current or low frequency designs. At higher frequency you balance Rds(on) with switching performance.

Practical ways to optimize it Choose MOSFETs with balanced Rds(on) and gate charge, keep the device cool, and use the recommended gate drive voltage.

Qg

What it is The total gate charge needed per switching cycle. It tells you how much effort it takes to turn the MOSFET on and off.

Why it exists The gate behaves like a capacitor. Moving charge in and out shifts the device state.

How it affects performance Higher Qg slows switching if the driver cannot supply enough current and increases gate drive loss. Reducing Qg often increases on resistance.

Design implications Low Qg is helpful at high frequency. For low frequency converters it is less critical.

Practical ways to optimize it Use a strong gate driver, keep gate traces short, and choose MOSFETs with a good balance of Qg and Rds(on).

Td(on) and Td(off)

What they are The delays before the MOSFET begins turning on or off after the gate signal changes.

Why they exist Internal capacitances and the structure of the gate region create brief delays.

How they affect performance Long delays increase deadtime which forces the body diode to conduct. Excessive delay reduces efficiency and raises diode stress.

Design implications Shorter delays improve efficiency in synchronous converters.

Practical ways to optimize them Use a faster gate driver, ensure clean signals, and avoid unnecessary gate trace length.

Tr and Tf

What they are The rise and fall times during switching transitions. These define how long the MOSFET spends in the region where both voltage and current are present.

Why they exist Gate charge, driver strength, and internal capacitances limit how fast the MOSFET can transition.

How they affect performance Longer transition times increase switching loss. Very fast transitions reduce loss but can cause noise and ringing.

Design implications You want transitions that are fast enough for efficiency but not so fast that EMI or overshoot becomes a problem.

Practical ways to optimize them Tune gate resistance, use proper PCB layout, and pick MOSFETs with suitable switching characteristics.

Qrr

What it is The reverse recovery charge of the MOSFET body diode. It is the leftover charge that must be removed when the diode stops conducting.

Why it exists The diode stores charge while it conducts. That charge does not disappear instantly when current reverses.

How it affects performance Higher Qrr causes current spikes and additional heating and hurts efficiency in fast switching applications.

Design implications Low Qrr is important in synchronous converters and high frequency designs.

Practical ways to optimize it Choose MOSFETs with optimized body diodes or move to devices with inherently low Qrr such as superjunction or wide bandgap parts.

Vsd

What it is The forward voltage drop of the MOSFET body diode when it conducts.

Why it exists The diode is built into the MOSFET structure and conducts during deadtime or reverse current events.

How it affects performance Higher Vsd increases loss during deadtime and the diode heats up more at high current or long deadtime intervals.

Design implications Low Vsd is helpful when the diode conducts often, but Qrr typically matters more at high frequency.

Practical ways to optimize it Use MOSFETs with optimized diode behavior and minimize deadtime.

Coss

What it is The output capacitance between drain and source. It stores energy that must be moved during switching.

Why it exists The MOSFET internal structure forms parasitic capacitors.

How it affects performance Higher Coss increases energy loss each time the MOSFET switches, affects switching speed and voltage overshoot, and Coss loss rises quickly with higher bus voltage.

Design implications Low Coss is valuable in high voltage, high frequency applications.

Practical ways to optimize it Use MOSFETs designed for low capacitance, reduce switching frequency, and keep layout inductance low.

Thermal Parameters

RθJA

What it is The junction-to-ambient thermal resistance from the datasheet. It tells you how many degrees the silicon junction will rise for each watt of power the MOSFET dissipates on the specified test PCB with no special heatsink.

Why it exists Any real device has to dump its heat into the surrounding air. The package, solder, and PCB copper form a thermal path that resists heat flow, similar to how an electrical resistor resists current.

How it affects performance A higher RθJA means the junction gets hotter for the same power loss, reducing safety margin and lifetime. A lower RθJA keeps the device cooler and lets you safely run more current or accept higher losses.

Design implications RθJA is most accurate when your mounting and PCB look like the datasheet test conditions. In dense layouts with many hot parts or different airflow, the real effective thermal resistance can be worse.

Practical ways to optimize it Use wider copper areas, thermal vias, thicker copper, and avoid trapping hot air around the device. If RθJA alone is not low enough, move to a package that can connect to a heatsink and use the RθJC + RθCA path instead.

RθJC

What it is The junction-to-case thermal resistance from the datasheet. It describes how easily heat flows from the silicon junction into the package case or exposed pad that touches your heatsink or PCB.

Why it exists Between the silicon and the outside world there are die attach materials, leadframe, and package plastic, all of which slow heat flow and add thermal resistance.

How it affects performance Lower RθJC means the junction tracks closer to the case temperature, so a good heatsink can keep the die much cooler. High RθJC limits how effective your heatsink or copper plane can be.

Design implications RθJC is the key number when you plan to mount the MOSFET on a heatsink or heavy copper area. It lets you estimate junction temperature starting from measured or simulated case temperature.

Practical ways to optimize it Choose packages with low RθJC (for example power packages with exposed pads), mount them with good thermal interface material, and follow layout recommendations so the thermal pad is fully soldered.

RθCA

What it is The case-to-ambient thermal resistance for your specific cooling path: heatsink, PCB copper, thermal interface material, and airflow.

Why it exists Heat leaving the case must travel through metal, interface material, and surrounding air. Each of these adds resistance to heat flow, just like resistors in series.

How it affects performance Lower RθCA means the case runs closer to ambient temperature for a given power loss, giving the junction more headroom. Poor heatsinking (high RθCA) quickly pushes junction temperature toward its limit.

Design implications Combined with RθJC, it sets the effective junction-to-ambient resistance of your custom design (RθJA ≈ RθJC + RθCA). It drives decisions about heatsink size, airflow, and board copper area.

Practical ways to optimize it Use larger or more efficient heatsinks, add airflow, choose good thermal interface materials, and design PCBs with solid copper areas and thermal vias under the device.

Tamb

What it is The ambient air temperature around the MOSFET, usually the air just outside the board or heatsink rather than room temperature measured far away.

Why it exists Heat can only flow into something cooler. The temperature of the surrounding air sets the starting point for how far the junction can rise before reaching its limit.

How it affects performance Higher ambient temperature raises junction temperature for the same power loss and thermal resistance, reducing safety margin. Cooler ambient gives you more headroom for power or lifetime.

Design implications You must use realistic ambient assumptions for your product environment, not just 25 °C lab conditions. Enclosures, nearby hot components, and limited airflow all make the effective ambient hotter.

Practical ways to optimize it Improve airflow, separate hot parts, avoid enclosing the MOSFET in small sealed spaces, and consider derating current or power for worst-case ambient conditions.

TJ,limit

What it is The maximum junction temperature you are willing to allow, often chosen below the absolute maximum rating in the datasheet.

Why it exists Semiconductor reliability and lifetime drop sharply as temperature rises. The datasheet absolute maximum is a do-not-exceed value, not a comfortable operating point.

How it affects performance A higher chosen TJ,limit lets you run more loss or current but reduces lifetime margin. A lower TJ,limit improves reliability but may require a better MOSFET or stronger cooling.

Design implications Picking TJ,limit is a design trade-off between efficiency, cost, and reliability. Safety standards or company guidelines may define the maximum allowed junction temperature for long-life products.

Practical ways to optimize it Start from datasheet limits and application requirements, then adjust MOSFET selection and cooling so the estimated Tj under worst-case conditions stays below your chosen limit with some margin.

Power Loss Calculations

Conduction Loss (P_cond)

What it represents Losses when the MOSFET is fully on and simply carrying current. This is the resistive heating from Rds(on).

Why it exists The MOSFET channel behaves like a small resistor when on, so any current through it creates I²R heating.

Formula For a simple case with constant current:
P_cond = Current^2 × Rds(on)
In real converters you often use RMS current and include duty cycle. The calculator can account for that behind the scenes if extended.

How it affects performance Grows with the square of current, so higher current hurts a lot. Increases with temperature because Rds(on) rises as the device heats up, and tends to dominate loss in low frequency, high current designs.

Design implications Conduction loss is often the first thing to check in high current systems. It pushes you toward lower Rds(on), better cooling, or higher Vbus to reduce current.

Practical tips Choose MOSFETs with suitable Rds(on), keep them cool so resistance stays low, and use thick copper and short traces to avoid extra resistive loss.

Overlap Switching Loss (P_sw)

What it represents Losses while the MOSFET is turning on and off. In this time the device sees both significant voltage and current.

Why it exists The MOSFET cannot jump instantly from off to on. During each transition it passes through a region where it is partially on and the product of voltage and current creates heat.

Formula A common approximation for hard switching is:
P_sw = 0.5 × Vbus × Current × (Tr + Tf) × f_sw
Where Tr and Tf are the rise and fall times. This calculator also adds a capacitance related term consistent with the Coss model below.

How it affects performance Increases linearly with bus voltage, current, and frequency, and increases with longer rise and fall times. It becomes dominant in many high frequency converters.

Design implications Once switching loss dominates, simply lowering Rds(on) does not help much. You need faster switching devices, stronger gate drive, or lower frequency.

Practical tips Use a strong gate driver, keep gate loops tight, tune gate resistance to balance speed and EMI, and avoid unnecessarily high switching frequencies.

Reverse Recovery Loss (P_rr)

What it represents Loss caused by the body diode inside the MOSFET when it turns off and dumps its stored charge.

Why it exists When the diode conducts, charge accumulates in its junction. When current reverses, that charge must be removed which causes a brief extra current spike and extra heating.

Formula A common approximation is:
P_rr = Qrr × Vbus × f_sw

How it affects performance Grows with bus voltage and switching frequency, shows up as current spikes and ringing that stress components and cause EMI, and matters much more in fast synchronous converters than in slow or diode based designs.

Design implications Reverse recovery can quietly dominate losses at high frequency even when Rds(on) looks good on paper. Low Qrr becomes a key selection parameter.

Practical tips Choose MOSFETs with low Qrr body diodes, consider wide bandgap devices for very high frequency, and keep loop inductance low to reduce overshoot during recovery.

Deadtime Loss (P_dt)

What it represents Loss when neither MOSFET in a half bridge is on and the body diode conducts during deadtime.

Why it exists You must insert a small deadtime so that high side and low side are never on at the same time. During this time, current has to flow somewhere, usually through the body diode.

Formula In a simple synchronous half bridge, an approximation is:
P_dt = 2 × Vsd × Current × (Td(on) + Td(off)) × f_sw
The factor of 2 accounts for both edges in one full switching period.

How it affects performance Increases with diode forward drop, current, deadtime, and frequency, and shows up directly as heat in the MOSFET and extra stress on the diode.

Design implications Too much deadtime wastes energy in the diode. Too little risks shoot through. There is a sweet spot that keeps efficiency high and the converter safe.

Practical tips Use gate drivers that provide adjustable deadtime, minimize propagation delay mismatch, and choose MOSFETs with good body diode behavior if the diode will conduct often.

Gate Charge Loss (P_gate)

What it represents Losses in the gate driver from charging and discharging the MOSFET gate every cycle.

Why it exists The gate is capacitive. Moving charge Qg at a voltage Vgate_drive every cycle consumes energy that ends up in the driver and the MOSFET gate network.

Formula Each full cycle charges and discharges the gate once, so:
P_gate = 2 × Qg × Vgate_drive × f_sw

How it affects performance Grows with Qg, gate drive voltage, and frequency. It does not heat the MOSFET much directly but adds to system power loss and driver heating and limits how many devices you can drive from one controller.

Design implications At very high frequency or in multi phase systems, gate drive loss is no longer negligible and it influences both MOSFET and driver selection.

Practical tips Pick MOSFETs with a good balance of Qg and Rds(on), keep gate drive voltage at the recommended level, and use drivers that can handle the required total gate charge.

Output Capacitance Loss (P_coss)

What it represents Loss from charging and discharging the MOSFET output capacitance every switching cycle.

Why it exists The MOSFET drain to source capacitance stores energy at Vbus. Each time you switch, that stored energy is moved around and usually ends up as heat.

Formula A common approximation is:
P_coss = 0.5 × Coss × Vbus^2 × f_sw

How it affects performance Grows quickly with bus voltage because it scales with V² and increases linearly with switching frequency. It can become a dominant loss term in high voltage, high frequency converters.

Design implications At higher voltages, Coss performance can matter more than Qg. Selecting a MOSFET with low output capacitance can give a significant efficiency gain.

Practical tips Use MOSFETs optimized for low Coss at your operating voltage, keep switching frequency reasonable, and minimize parasitic inductance that interacts with Coss to cause ringing.

Summary

This guide provides an introduction to the power dissipation characteristics in MOSFETs under various operating conditions. These calculations are helpful for anyone looking to understand the efficiency and performance of MOSFET-based power electronic systems.

Learn more about DMC's Embedded Development and Embedded Programming expertise. 

The post MOSFET Power Loss Calculator appeared first on DMC, Inc..

]]>
Trying Out ARM Mbed OS’s New Support for USB Device with Some Retro Hardware https://www.dmcinfo.com/blog/21018/trying-out-arm-mbed-oss-new-support-for-usb-device-with-some-retro-hardware/ Fri, 30 Aug 2019 09:24:58 +0000 https://www.dmcinfo.com/blog/21018/trying-out-arm-mbed-oss-new-support-for-usb-device-with-some-retro-hardware/ Many products feature USB to facilitate communication between various devices, to transfer files easily, support hardware peripherals or add other features. While working on embedded systems, we have developed a variety of devices that utilize USB in these ways. The ease of implementation of USB largely depends on the hardware and software infrastructure that the […]

The post Trying Out ARM Mbed OS’s New Support for USB Device with Some Retro Hardware appeared first on DMC, Inc..

]]>
Many products feature USB to facilitate communication between various devices, to transfer files easily, support hardware peripherals or add other features. While working on embedded systems, we have developed a variety of devices that utilize USB in these ways.

The ease of implementation of USB largely depends on the hardware and software infrastructure that the microcontroller manufacturer provides. As of release 5.12.0, ARM Mbed OS began supporting USB device for several targets. This provides a nice layer of abstraction between the various manufacturers’ USB implementations and the USB class code. There are a variety of USB classes that are supported by default: USB MSD, USB HID, and USB Audio.

In this blog, I’m going to try out this new USB device support and create a USB Mouse out of an old joystick.

Setting up the Project

I want to test out the USB HID class which will allow the device to interface with the PC as a USB mouse. I am going to start by creating a basic ARM Mbed OS project. If you have never done that before, take a look at this guide.

For this project, I am using a NUCLEO_F429ZI development board which is one of the supported targets for using mbed’s USB device. I set the target in my project by using the command “mbed target NUCLEO_F429ZI”. Make sure that your compiler is also set correctly according to the compiler that you have installed.

For the test, I am going to copy-and-paste the example main from the file mbed/usb/device/USBHID/USBMouse.h.

C++
#include "mbed.h"
#include "USBMouse.h" 

USBMouse mouse;

int main(void)
{
  while (1)
  {
      mouse.move(20, 0);
      wait(0.5);
  }
}

Try and compile the project by running “mbed compile.” If you successfully build this project, then you are ready for the next steps. If not, make sure the target you are using is supported by ARM Mbed OS’s new USB device.

Note, not all of the targets with hardware USB support Mbed’s USB device abstraction! Also, make sure you have the latest version of ARM Mbed OS in your project.

Running a Quick Test

Load the compiled program onto your target development kit. I am using a NUCLEO which has a STLINK on-board, so the development kit shows up as a drive when I plug it in. Just drag-and-drop the compiled “_your_project_name_.bin” onto the drive to program.

To test the USB HID device, plug in the User USB port to the PC in addition to the debugging port which is needed for power. On your PC, you should see that a new USB device is detected. Once setup, your PC’s cursor should slowly move across your screen in 0.5-second steps.

We are now ready to bring in the retro hardware to complete our USB device!

Adding Some More Hardware

apple joystick

I have an old Apple Joystick IIe that I want to use as a USB joystick; so I need a custom USB adapter. The joystick electronics are very simple. There are two pushbuttons with pull-down resistors and two variable resistors, one for each axis, with one side tied to V+.

To interface to the joystick, I connect 3.3 V on the NUCLEO to the V+, connect the GND on the NUCLEO to the joystick ground, connect the push-button outputs to digital inputs on the NUCLEO, and connect each axis output to a NUCLEO analog input with a 100 K ohm resistor to ground.

I pulled all of this together quickly with a small prototyping board. The connector itself is just half of an RS232 serial cable.

microcontroler for joystick

Now, with a bit of firmware, we can get this retro joystick to operate with any modern OS.

The code below is what I quickly put together to read the analog inputs of the joystick, read the button presses, and send corresponding USB Mouse events. When using one of the various supported USB device classes, Mbed can substantially decrease the required development time.

C++
#include "mbed.h"
#include "USBMouse.h"

USBMouse mouse;

AnalogIn ainx(A0);
AnalogIn ainy(A1);

DigitalIn right_button(D6);
DigitalIn left_button(D7);

int main()
{
	float x = 0;
	float y = 0;

	bool prev_right_button = true;
	bool prev_left_button = true;
	
	const float mid_x = ainx.read() * 100.0;
	const float mid_y = ainy.read() * 100.0;
	
	while (1)
	{
		// Update the X, Y position
		y = ainy.read() * 100.0;
		x = ainx.read() * 100.0;

		float x_move = x - mid_x;
		float y_move = y - mid_y;

		if (x_move < 0)
			x_move = 2 * x_move;
		if (y_move < 0)
			y_move = 2 * y_move;

		if ((abs(x_move) > 4.0) || (abs(y_move) > 4.0))
		{
			mouse.move(-1 * x_move, -1 * y_move);
		}

		// Update the button presses
		bool current_right_button = right_button;
		bool current_left_button = left_button;

		if (prev_right_button != current_right_button)
		{
			if (current_right_button)
			{
				mouse.press(MOUSE_RIGHT);
			}
			else
			{
				mouse.release(MOUSE_RIGHT);
			}
			prev_right_button = current_right_button;
		}

		if (prev_left_button != current_left_button)
		{
			if (current_left_button)
			{
				mouse.press(MOUSE_LEFT);
			}
			else
			{
				mouse.release(MOUSE_LEFT);
			}
			prev_left_button = current_left_button;
		}

		wait_ms(10);
	}
}

Testing it Out

Plug it into the PC and try out this retro joystick working with a modern machine!

joystick and controller

This is a great way to get a simple USB device going, but often a product will require more customization or non-supported USB class. If this is the case for you, come talk to our embedded development and programming group to see what solution makes sense for you!

The post Trying Out ARM Mbed OS’s New Support for USB Device with Some Retro Hardware appeared first on DMC, Inc..

]]>
DMC’s Custom Bootloader https://www.dmcinfo.com/blog/21075/dmcs-custom-bootloader/ Thu, 22 Aug 2019 13:44:10 +0000 https://www.dmcinfo.com/blog/21075/dmcs-custom-bootloader/ For anyone who has worked on an embedded project, you can understand the hassle of loading code onto a microcontroller. To alleviate this issue and cut down on the extra time that comes from this process, DMC designed and built a custom boot loading tool. This boot loader communicates with MCUs using UART (Universal Asynchronous […]

The post DMC’s Custom Bootloader appeared first on DMC, Inc..

]]>
For anyone who has worked on an embedded project, you can understand the hassle of loading code onto a microcontroller. To alleviate this issue and cut down on the extra time that comes from this process, DMC designed and built a custom boot loading tool. This boot loader communicates with MCUs using UART (Universal Asynchronous Receiver/Transmitter). UART communication uses physical circuitry to send and receive serial data between two devices.

dmc custom bootloader

The DMC boot loader has three important features that help improve its use. The first of which is it has an onboard micro USB port. This port allows for serial communication with a CPU via a USB to micro USB cord (like you would use to charge a phone).

The second important feature of the boot loader is that it has onboard reset and boot buttons. This allows for the user to easily put their MCU into boot loading mode by resetting the MCU while pressing the bootloader button.

The third feature of this board that is important is the five-pin connector. This connector is how the bootloader communicates with the target MCU.

For most DMC embedded projects, there is a standard 5 pin header that is compatible with the boot loader’s connector. Through this mounting, we can send and receive the serial data, as well as reset and put the board into boot loading mode. Even if a board doesn’t have a compatible mount, you can manually connect the boot loader’s TX, RX, boot, ground, and reset pins to the appropriate locations on the target board to achieve the same functionality.

This tool is one example of many internal initiatives DMC has undertaken to be more efficient and profitable.

Learn more about DMC's Embedded Development and Programming Solutions. Contact us for additional information.

The post DMC’s Custom Bootloader appeared first on DMC, Inc..

]]>
How To Disassemble and Fix a Fried S7-1200 PLC https://www.dmcinfo.com/blog/22198/how-to-disassemble-and-fix-a-fried-s7-1200-plc/ Mon, 21 Jan 2019 09:52:33 +0000 https://www.dmcinfo.com/blog/22198/how-to-disassemble-and-fix-a-fried-s7-1200-plc/ Don’t you hate it when your coworker inadvertently wires up a 24V PLC to wall power and lets out the magic smoke? Just such a mishap happened in our lab a while back and the broken PLC was sitting around in the junk bin for a while. Figuring there wasn't anything to lose, I decided to […]

The post How To Disassemble and Fix a Fried S7-1200 PLC appeared first on DMC, Inc..

]]>
Don’t you hate it when your coworker inadvertently wires up a 24V PLC to wall power and lets out the magic smoke? Just such a mishap happened in our lab a while back and the broken PLC was sitting around in the junk bin for a while. Figuring there wasn't anything to lose, I decided to try my luck and see if it could be revived

Fortunately, the Siemens S7-1200 series PLCs are quite easy to disassemble, and I was able to replace the damaged components and restore it to a proper working condition. I definitely wouldn't trust this refurbished PLC to run a critical system, but for testing code in our lab, it should be just fine. I would also recommend reaching out to the manufacturer if you are running into issues with a production PLC, keeping in mind that any warranty may be voided if you attempt to fix it yourself.


Opening the Enclosure

Using a small flat blade screwdriver to push in the side tabs, it's easy to pull the enclosure apart and separate the power conditioning PCB from the main board.

 

Surveying The Damage

I immediately noticed the burn marks coming from the positive voltage supply pin, but everything else looked okay, and there was no visible damage on the main board.

PCB burn marks

The first component in the circuit is a fuse, designed to limit the damage from precisely this type of mishap. Using a multimeter to check for continuity showed that it was in fact blown, as one would expect. I went ahead and jumpered it out with a wire wrap connection.

wire wrap across fuse leads

Now What?

Unfortunately, the fix wasn't going to be that easy. Measuring the resistance across the voltage supply terminals, I found there was now a short circuit. After checking all the components that go across the voltage bus, I found that the culprit was a small Zener diode.

Its purpose is to suppress spikes in the supply voltage, but unsurprisingly, applying 120 VAC far exceeded its maximum power dissipation rating and caused it to short out. Simply desoldering the offending diode from one of its pads fixed the short, and after reassembling the PCBs and applying power, I was surprised that the PLC powered up and was fully functional. Clearly, the protection circuitry had done its job.

desoldered diode

Patching Everything Up

Even though I now had a working PLC, leaving it as-is would mean that it would most likely not survive a second jolt of high voltage, so I went ahead and replaced the fuse and Zener diode to make it almost as good as new at a cost of less than $2.

 

After that, it's easy to snap everything back together, power it up, and watch the blinkenlights turn on!

 

Conclusion

I hope you enjoyed this sneak peek under the hood of a device that we work with on a daily basis. It was nice to see that Siemens designs their PLCs to be pretty robust and easy to disassemble, unlike the typical consumer electronics devices you tend to see these days. Share your own stories of hacking PLC hardware in the comments section below!


Learn more about DMC's Siemens S7 PLC programming expertise and embedded design expertise

The post How To Disassemble and Fix a Fried S7-1200 PLC appeared first on DMC, Inc..

]]>
The Product Development Process: How to Bring Your Product to Market https://www.dmcinfo.com/blog/25824/the-product-development-process-how-to-bring-your-product-to-market/ Tue, 15 Mar 2016 15:45:38 +0000 https://www.dmcinfo.com/blog/25824/the-product-development-process-how-to-bring-your-product-to-market/ Have you ever had a product design idea? Our engineers created this overview of the product development process to demystify how to bring your product to market.  Learn more about DMC's Custom Software and Hardware Development services.

The post The Product Development Process: How to Bring Your Product to Market appeared first on DMC, Inc..

]]>
Have you ever had a product design idea?

Our engineers created this overview of the product development process to demystify how to bring your product to market. 

Learn more about DMC's Custom Software and Hardware Development services.

The post The Product Development Process: How to Bring Your Product to Market appeared first on DMC, Inc..

]]>
Exploring Altium: Using Design Variants https://www.dmcinfo.com/blog/25943/exploring-altium-using-design-variants/ Fri, 29 Jan 2016 09:35:21 +0000 https://www.dmcinfo.com/blog/25943/exploring-altium-using-design-variants/ One of my absolute favorite things about embedded design is watching a product evolve over the development cycle. From unboxing the first prototype all the way to the release of the deluxe commercial model, each revision of the design poses new and interesting challenges. One of these challenges is managing each revision of the electrical […]

The post Exploring Altium: Using Design Variants appeared first on DMC, Inc..

]]>
One of my absolute favorite things about embedded design is watching a product evolve over the development cycle. From unboxing the first prototype all the way to the release of the deluxe commercial model, each revision of the design poses new and interesting challenges. One of these challenges is managing each revision of the electrical schematic and PCB layout in a way that minimizes human error and maximizes automation.

Altium Designer has an excellent tool to assist the embedded engineer in managing changes between revisions and within different variations of a base design: Design Variants (sometimes called Assembly Variants).

Introduction to Design Variants

So, when do Design Variants come into play? At DMC, we use this tool primarily to manage situations where components that exist on the schematic are not intended to be installed on the PCB. There are many reasons why a component might be placed on the schematic but not on the final board. Here are a few key cases:

  • Designs with functionality that can be stripped away for “basic” flavors of the product/solution
  • Prototypes intended to test functionality of two or more similar (but not identical) circuits; one example would be evaluating two 5V power supplies for the lowest noise
  • Designs with a matrix of pull-up and pull-down resistors to indicate the PCB/hardware revision to the microprocessor so that it can re-assign I/O addresses or enable/disable functionality accordingly

Let’s take the first case above. DMC recently executed an embedded design for Chicago Dial Indicator (CDI), a company that manufactures (among many other products) high-quality electronic dial indicators. DMC originally connected with CDI to help innovate their flagship electronic dial indicator (you can read more about that project here). After launching that product, CDI approached us again to revitalize their EMS device, which connects multiple indicators to a single device to show data, log measurements, and provide an easy interface to a PC or measurement system.

DMC suggested designing a PCB that could interface with an expansion board to double the channel count without any additional hardware designs. Sure, we could have designed and managed two separate boards, but with Altium’s Design Variants functionality, this was a breeze. Let’s take a look!

Variant Management

Below is an excerpt of the schematic that shows the device interface channels. Rather than copy-pasting each individual channel, we’re using the multi-channel functionality of Altium, which you can see above the sheet symbol for a device channel: REPEAT(MTI,1,4) will create four copies of the sheet, MTIA, MTIB, MTIB, and MTIC

In the upper-right hand corner (by default) of the schematic editor, you’ll find the Design Variants button, which launches the Assembly Variants Management window.

Adding a New Variant

Launching the Variant Management window will show you a screen like the following:

For the Basic version of this PCB, we only want to populate two of the four channels (MTIA and MTIB). First, let’s add an assembly variant called “Basic”. Find the “Add Variant…” button on the bottom left of this window and click it. You will see the “Edit Design Variant” window below:

I selected “Allow variation of fabrication outputs.” This isn’t critical, but sometimes you’ll want to omit certain footprints for components that are not installed.

After clicking OK, you should see the Variant Management window again with a new column for the variant you created. Let’s find the components that will not be fitted for the “Basic” variant of this design. In my case, I am de-populating channels MTIC and MTID, so I’ll highlight any components with either of those prefixes in the “Designator” field.

To bulk-edit these parts, right-click on the highlighted “Component Variation” field, hover over “Set Selected As” and then click “Not Fitted”.

After this action, all of the highlighted parts should now show “Not Fitted” in the Component Variation field.

Design Variants and the Schematic

Now that your design variant has been created and configured, it’s time to take a look at the schematic to check our work. Find the Design Variants button again (in the upper-right hand corner of the schematic editor by default). Next to it is a drop-down menu that shows the selected Design Variant. This field will probably show “[No Variations].” Click on the drop-down and find the variant you just created.

The default view of the Schematic Editor is the “Editor” view (so creative). If you look on the bottom toolbar, however, you will see one or more tabs next to “Editor.” In the case of multi-channel schematics, each of the individual channels will be accessible here. If the schematic is only used once, there will only be a single tab.

If I click on channels MTIC or MTID, the two channels that will not be installed on my Basic variant, the schematic editor will show red x-marks over all of the components that are marked as Not Fitted.

Nice! I would encourage you to double-check all sheets of your schematic when creating design variants, as this is an easy way to spot mistakes (such as a component that has been marked Not Fitted by accident).

Generating Outputs – BOM

Now comes the most powerful part of creating design variants – generating design outputs! The first document we’ll generate is the Bill of Materials, or BOM. The BOM lists all of the manufacturer part numbers in your design and links each one to a schematic component. This document is very important to the PCB assembly house, who typically purchases the components in the BOM and loads them into a pick-and-place machine.

When managing design variants manually, it’s necessary to indicate which components and designators will not be populated. One way to do this is to label the unused components with DNI (Do Not Install), DNP (Do Not Populate), Not Fitted, or something similar. Unsurprisingly, this is not a fool-proof solution, as some manufacturers may not recognize or understand these directives.

A better way is to eliminate the unused components and designators from the BOM entirely. Sure, you can delete them by hand, but this is inherently error-prone and can be quite time-consuming. Instead, let’s let Altium handle this for us. In your Output Job file (if this is a new project, you may have to add one using File -> Add New to Project -> Output Job File), select the appropriate design variant from the top of the window:

Then, simply generate your BOM. I selected the basic version of my PCB, which omits two of the four device channels. Let’s see what happened. The first image below is the default BOM, which does not omit any channels. Notice that you can see components with MTIA, MTIB, MTIC, and MTID prefixes.

The second image shows the BOM generated for the Basic variant, which shows only MTIA and MTIB components.

Nice!

Generating Outputs – Pick-and-Place

The second document of importance is the Pick-and-Place file, which contains the location and orientation of each component in the assembly. This is the file used by pick-and-place machines to mount components on a PCB prior to soldering.

Components that are not populated on the PCB are almost always marked as such on the BOM (or removed entirely as discussed above). The pick-and-place file is often neglected, which sometimes leads to confusion during the assembly process. I have seen situations where the “DNP” designator on the BOM was missed, and DNP components were installed anyway. Had those parts’ entries on the pick-and-place files been omitted as well, the assembly house would not have loaded the components in the pick-and-place machine in the first place.

Generating a pick-and-place file for your assembly variant is very simple. From the PCB Editor, make sure the proper variant is selected by choosing it from the drop-down menu on the toolbar (just as you did from the Schematic Editor earlier). Then, click File -> Assembly Outputs -> Generates Pick and Place Files. Voila!

Below is a WinMerge comparison between the default and variant pick-and-place files, which clearly shows that the DNP parts are completely omitted from the variant version. Even though it’s not essential to generate the pick-and-place file this way, it’s an additional way to validate the design during the hand-off to the manufacturer.

Summary

Design Variants in Altium are a powerful tool for handling situations where a base design can be assembled into multiple versions or “flavors.” This article covered the case where parts are not populated to create a “Basic” version (where the base design is the “Deluxe” version with more functionality). Design Variants can be used to change part parameters (like a resistor value or a part number) as well. If you find yourself managing a lot of design outputs manually, it might be time to let Altium shoulder the brunt of the work for you!

Learn more about DMC’s embedded design and circuit design services.

The post Exploring Altium: Using Design Variants appeared first on DMC, Inc..

]]>
Repairing an NI USB-6351 X-Series DAQ https://www.dmcinfo.com/blog/27281/repairing-an-ni-usb-6351-x-series-daq/ Tue, 09 Sep 2014 16:19:32 +0000 https://www.dmcinfo.com/blog/27281/repairing-an-ni-usb-6351-x-series-daq/ Recently, I’ve needed to do some proof of concept testing for a LabVIEW-based project. The only special I/O requirement for my prototype was a +/- 10V analog output that is capable of sourcing at least 1mA of current. The good news was that DMC owned just the piece of hardware: an NI USB-6351 X-Series DAQ. […]

The post Repairing an NI USB-6351 X-Series DAQ appeared first on DMC, Inc..

]]>
Recently, I’ve needed to do some proof of concept testing for a LabVIEW-based project. The only special I/O requirement for my prototype was a +/- 10V analog output that is capable of sourcing at least 1mA of current. The good news was that DMC owned just the piece of hardware: an NI USB-6351 X-Series DAQ. The bad news was that it was handed to me with the caveat that it doesn’t turn on and may or may not smell bad when plugged in. Undeterred, I resolved to resurrect our $1500 out-of-warranty brick.

Since the unit showed no signs of powering on, the first order of business was to verify the main power source. Finding nothing wrong with the 12V external power adapter, I set off to get my hands dirty and investigate the internal circuitry.

pcb

Thankfully, NI made the DAQ very easy to disassemble. The entire PCB assembly slides out in one piece after the removal of a couple screws. Nothing seemed charred or obviously damaged and nothing dramatic happened when I tried giving it power again. So, I started the highly technical operation of poking around at various chips to see if anything was hot.

Nothing felt scalding hot, but there was a section of circuitry warm enough to raise suspicion. Especially so because a nearly identical set of components nearby was cool to the touch. The hot circuits included an LM2673-ADJ adjustable switching regulator (U54) connected to a 33uH power inductor (L6) and 5A-rated BAT540C Schottky diode (D25). The circuit was regulating the 12V from the external adapter to a somewhat strange 1.2V. The neighboring circuit, on the other hand, was taking the same 12 volts and outputting a standard 3.3V.

PCB 2 pictured here.

Checking the datasheet for the LM2673-ADJ, I discovered that its output voltage is controlled by a resistive voltage divider. I found the appropriate resistors in the PCB, measured their resistances, and calculated the designed output voltages for the two regulator circuits. The circuit supplying 3.3V was designed as such while the one outputting 1.2V should have been outputting 5V.

The most likely cause of this discrepancy was that the regulator was supplying excessive current due to a damaged component somewhere on the 5V power rail. In doing so, it would trigger its over-current and/or over-temperature protection and reduce its output voltage. I checked and found that there was indeed a very low amount of resistance between the 5V power rail and ground. Whatever component was causing this would be sinking a lot of current and therefore necessarily be quite hot.

It didn’t seem like the sort of thing that’d be hard to find.

My prime suspect was diode D25 that sits across the regulator’s 5V output and ground. I removed it only to find that 5V and ground were still shorted together. I verified with my multimeter that the diode was damaged and contributing to the short, but it clearly wasn’t the only offending component. Thinking that the problem was isolated to the immediate vicinity of the regulator, I removed output capacitors C125, C126, and C127. No dice. A little desperate, I removed the regulator chip itself. 

Using an adjustable current limit lab power supply, I can feed power directly into the shorted 5V power rail. Whatever component was causing the short would surely heat up enough for me to detect. With the power supply voltage limited to 5V, I started cranking up the current. Eventually, I found myself pouring over 3A into the circuit board at a mere 1V.

I found two potential culprits. Just above the 3.3V regulator circuit, there was a circuit block that contained a power inductor designated L11 and a tiny 6-pin surface mount component designated Q38. Both were intensely hot. Under the assumption that inductors don’t just go off and fail, I turned my attention to Q38. I could make out the markings “A41AC” yet no amount of searching yielded any useful results. Frustrated, I decided to remove the chip altogether.

PCB 3 is pictured here.

As soon as Q38 was gone, the short-circuit I was hunting went with it! I knew the DAQ wasn’t fixed, but I couldn’t stop myself from attempting to power it on right there. All I had to do was plug in the external 12V power brick while simultaneously using the lab power supply to replace the 5V regulator I removed.

Once connected over USB, NI MAX detected the DAQ immediately. I was ecstatic. It amazed me that the device seemed to be functioning normally. The digital I/O seemed to work, so I went to test what I needed from the DAQ in the first place: analog output. The behavior I saw was puzzling. When commanded to output +10V, I would get +2.5V. Similarly, commanding -10V would result in -2.5V and the voltages in between scaled linearly.

Of course, the one feature I needed from this DAQ was the one that was still broken.

When additional searching turned up nothing useful regarding the mystery chip, I started reverse engineering the schematic for the circuit block in which it lived. Very fortunately for me, just like the 5V and 3.3V regulators from before, there was a doppelganger to this circuit block as well. It too contained an A41AC mystery chip. Here is the partial schematic I came up with:

Q38 and L11 were the components that I had felt getting very hot. Q39 and L13 were cool to the touch. These two circuits look like classic voltage boost converters. To get a better feel for how these circuits worked, I used an oscilloscope to probe the undamaged circuit at the points indicated on the schematic.

Scope trace one pictured here.

Let’s assume the mystery chips Q38/39 are N-channel enhancement mode MOSFETs. Pins 1, 2, 5, and 6 would be the drain, pin 3 would be the gate, and pin 4 would be the source. On the undamaged circuit, the scope shows a ~1MHz square wave with ~80% duty cycle at the gate. When the gate is high, the transistor turns on and pulls the drain to ground. This forces current to increase in L11, allowing it to store energy. When the gate is low, the transistor turns off, forcing the current stored in the inductor to flow through the flyback diode, D23, to the output of the circuit. This operation matches exactly that of a boost converter operating in continuous mode. 

The relevant equation to be aware of here is Duty cycle = 1 – Vin/Vout. Since Vin is 3.3V and Vout is 20V, the duty cycle should be 83.5%. This result matches closely to what I saw being fed to the MOSFET gate. Out of curiosity, I checked what kind of waveform was being fed to the damaged circuit and found a ~1MHz square wave with ~75% duty cycle. With Vin being 5V in that circuit, Vout is predicted to also be 20V. At this point I speculated that the undamaged circuit was used to supply the reference for the DAQ’s +/-10V analog input and the damaged circuit supplies the reference for the analog output. With Q38 removed, the broken boost circuit would simply output the 5V that it was fed. This explains why I could only get the DAQ’s analog output to swing between -2.5V and +2.5V.

Now it’s time to tackle the issue of actually finding a replacement part for Q38. Using calipers, I measured the dimensions of the chip to match the TSOT-23-6 package. Searching for N-channel MOSFETS in this package on DigiKey, I found several pin-compatible parts!

 

Extremely satisfied with myself, I ordered a FDC5661N_F085 which had the highest rated power rating at 1.6W. I also grabbed a BAT540C and LM2673-ADJ to repair the 5V regulator circuit before running around the office to gloat over my victory.

The parts came in the mail the next morning and I eagerly got to work soldering them in their places. I first restored the 5V regulator circuit which fired up without a hitch. After that I dropped a new MOSFET to replace Q38. Giving myself a pat on the back, I powered up the DAQ to run a final test. This time, none of the DAQ’s status LEDs showed any activity. Not five seconds later, I detected a burning smell and saw the dreaded trail of smoke emanating from the new MOSFET.

After cutting the power and staring at the circuit board for a while in bewilderment, I set off to find out what went wrong. I made sure that I installed the MOSFET in the correct orientation and verified that its drain and source were not shorted together. The fact that the new MOSFET was burning up so quickly and taking out the entire power rail with it could mean that electrically it was connected directly across +5V and ground.

I decided it wouldn’t hurt too much to try to see what was going on with the oscilloscope. I hooked it up to the new MOSFET just as I had done previously with the undamaged circuit. I was able to get this trace by briefly toggling power to the board:

Scope trace 2 pictured here.

The strange waveform didn’t reveal much more information than I already knew. At least it was interesting to see the electrical havoc being wreaked.

I checked diode D22 to make sure nothing on the output side of the circuit could interfere with the MOSFET. That leaves us with a single remaining suspect: power inductor L11. Since inductors are simply coils of wire, I was incredulous that it could be damaged. Furthermore, a resistance measurement will reveal that they are indistinguishable from a simple wire.

Lacking an inductance meter, I set about building an inductor test circuit. Inductors resist changes to the current flowing in them, as shown by their characteristic equation: V = L * (di/dt). Applying a voltage V across the inductor will cause current to rise linearly with a slope of (V/L). The test setup I made looked like this:

The inductor under test was connected in series with a 1 ohm resistor. The oscilloscope measured the voltage across the resistor which would indicate how much current was flowing at any given time. The capacitor would be charged to 10V before being discharged through the inductor. Its purpose was to provide a low-impedance voltage source to the inductor under test.

First, I ran my test using a known good 33uH inductor I found in the lab. Here is what the scope trace looked like:

Scope trace 3 pictured here.

The current initially rose linearly for about 10us before jumping up to 10V. The discontinuity happened due to the core of the inductor reaching saturation. The slope of the linear region was slightly under 0.4V/us (which corresponds to 0.4A/us). Since V = 10V, we’d shown, experimentally, that the inductor was around 25-30uH.
I removed L11 from the circuit board and ran the same test. Here is the scope trace:

Scope trace 4 pictured here.

This time, the current jumped up to 10A immediately, showing that the inductor was behaving as a short. When this inductor shorted for an unknown reason, it caused a huge current to flow through Q38 whenever it was switched on. I figured that the 5V regulator would go into current limiting mode, dipping its output voltage to the 1.2V I measured at the beginning of my investigation. After several red herrings, we’d finally found the actual culprit!

The only thing left to do was to find a suitable replacement inductor. I found and ordered a 100uH inductor (Bourns PM3316-101M-RC) that had an almost identical footprint to our shorted inductor. In the meantime, I was impatient to get the DAQ working again. Referring back to the Wikipedia page on boost converters, we could see that as long as they were operating in continuous mode, the output voltage depended only on the switching duty cycle and was completely independent of inductance.

Feeling adventurous, I shoehorned the 33uH power inductor I found lying around into the circuit. I also replaced Q38 with another fresh MOSFET. With the oscilloscope connected, I cautiously turned on the power. Just like that, the DAQ came to life without any drama. I measured a solid 20V output from the repaired boost converter circuit and the scope trace showed a clean waveform:

Scope trace 5 pictured here.

I connected the USB DAQ to my computer and was able to get accurate and precise analog voltage outputs across the entire +/-10V range. Exhausted and relieved, I finally started on the proof-of-concept project for which I need the NI USB-6351 in the first place.

Learn more about DMC’s LabVIEW programming services.

The post Repairing an NI USB-6351 X-Series DAQ appeared first on DMC, Inc..

]]>
Pet Project: Turn A Fan Into A Clock https://www.dmcinfo.com/blog/27643/pet-project-turn-a-fan-into-a-clock/ Tue, 15 Apr 2014 13:03:46 +0000 https://www.dmcinfo.com/blog/27643/pet-project-turn-a-fan-into-a-clock/ For those of you with electronics hobbies, here is an interesting pet project that is not very difficult or expensive. In fact, you can find most of the parts lying around your house. The idea is to make an analog display clock. The finished product will have a rotating circuit board that flashes LEDs at […]

The post Pet Project: Turn A Fan Into A Clock appeared first on DMC, Inc..

]]>
For those of you with electronics hobbies, here is an interesting pet project that is not very difficult or expensive. In fact, you can find most of the parts lying around your house. The idea is to make an analog display clock. The finished product will have a rotating circuit board that flashes LEDs at the correct time in order to make a floating image of an analog clock.

Here is a list of basic materials that you will need:

  • White box fan
  • Perforated board
  • PIC (or any microcontroller)
  • Darlington Chip
  • 2 5 V voltage divider (power microcontroller)
  • LEDs with resistors
  • Emitter/receiver diodes
  • Toggle switch (for power)
  • Battery Pack
  • 12 V power supply (old phone charger)
  • Clay (for inertial balancing)

Here is a list of tools that you will need:

  • Solder Iron
  • Solder
  • High gauge wire
  • Knife (cut fan up)

General Process:

  1. Wire Perf Board: wire LEDs in a parallel line starting at the center of the perf board and going to the edge of the darlington chip. Wire the Darlington to the switched power rail and wire inputs to the PIC. Wire the power out of the battery box to the voltage divider and then through the switch. Mount the battery box in the middle of the perf board for inertial purposes. Wire the receiver diode at the end of the color LED line facing towards the fan body.
  2. Remove fan blades and keep the center plastic part for mounting the perf board. Cut grooves in the hub to fit the perf board securely, and use duct tape if needed to mount securely.
  3. Mount the emitter onto the fan body so that the receiver passes directly in front of it. Use either a breadboard or solder parts of the voltage divider from the 12 V to the emitter. This will be your control aspect of the system.
  4. As far as programming goes, I approached it so that the fan speed was relatively constant, and so there were programmed delays between each LED strobe to display numbers. I treated each number as an LED number display that would flash sequentially as the fan was moving in order to show the “floating” number. Then the receiver was a callback that reset the sequence.

If everything is done right, you can get something like this!

An analog clock is made using LED lights.

Please be careful if you try this project. Use your judgement with the use of PPE and managing voltage lines.

The post Pet Project: Turn A Fan Into A Clock appeared first on DMC, Inc..

]]>
Updating Your Rotary Dial Phone for the Digital Age https://www.dmcinfo.com/blog/28080/updating-your-rotary-dial-phone-for-the-digital-age/ Mon, 23 Sep 2013 14:39:18 +0000 https://www.dmcinfo.com/blog/28080/updating-your-rotary-dial-phone-for-the-digital-age/ Good-old rotary dial phones have been around since forever, and they used to be a part of everyday life, like dragons during medieval period. However, like dragons, suddenly all these marvelous ancient devices just disappeared one day. I was lucky to find one of these dinosaurs at the local flea market. I was eager to […]

The post Updating Your Rotary Dial Phone for the Digital Age appeared first on DMC, Inc..

]]>
Good-old rotary dial phones have been around since forever, and they used to be a part of everyday life, like dragons during medieval period. However, like dragons, suddenly all these marvelous ancient devices just disappeared one day. I was lucky to find one of these dinosaurs at the local flea market.

I was eager to try it out, but unfortunately I don’t have a home phone line anymore. I hooked it up to my Voice Over IP (VoIP) adapter that I haven’t used in years. It almost worked! Well, it rang like it is supposed to – waking up dogs and babies in a two block radius. I could even have a pleasant conversation over it, but I couldn’t dial out. I heard a dial tone, but it ignored the number I was trying to dial.

The problem actually was not the phone – there is nothing could go wrong with it, ever. It’s probably bullet-proof and could easily survive a minor nuclear apocalypse (haven’t tried it, it is in my to-do list). The problem was in my Voice Over IP adapter. It’s not compatible with “ancient” rotary-dial phones, and is designed to work only with (well, also vintage) push-button phones.

Ironically, rotary dial (or pulse-dial) is actually digital protocol, and is supposed to be closer relative to VoIP than “modern” push-buttons phones. The later ones use analog encoding to transmit digits. This process has a fancy name: Dual-Tone Multi-Frequency Signaling (DTMF).

The rotary dial is pure digital – transmitting numbers as a sequence of on/off pulses. One pulse corresponds to digit “1”, two pulses – digit “2”, etc; Ten pulses represent digit “0”.

Of course I could get another VoIP adapter that supports pulse dialing, but this would be too easy. Instead, I decided to make my own pulse-to-DTMF converter.

I had a few microcontrollers lying around and decided using them to generate DTMF signals should be trivial. Obviously, it’s been done before and I found an Atmel application note to do exactly that. There is nothing special there, just using a PWM (the same method I used to play audio on the TI Launchpad) to generate an analog signal. The only difference is that I am not using any external memory here. DTMF consists of just two sinusoidal waves, so we have to store one period of the sin wave and it is small enough to easily fit to the microcontroller’s internal memory.

As I mentioned before, reading pulses from the phone is very simple. It’s already digital, just count them up – and bam you get your digit. Here is a test setup with my adapter still on the breadboard

From left to right:

  • Wi-Fi to Ethernet converter. Just because my VoIP adapter doesn’t have a Wi-Fi and I don’t like having Ethernet cables everywhere
  • VoIP adapter. I had the old Cisco/Linksys PAP2
  • Phone (kinda obvious)
  • Breadboard. Schematic below:

The phone line voltage is in the “on-hook” state. Confusing term? It seems to have originated because you are supposed to keep the earpiece on the hook and “off-hook” it in order to answer the call.

Back to the voltage. So the “on-hook” voltage is quite high, around 48V DC and even higher (around 90V AC) during the ring. I decided to connect my board after the phone switch, so I am getting the power only when the phone is in the “off-hook” state (meaning the handset is not on the phone).

In the “off-hook” state, line voltage is supposed to drop down to around 5V DC, which is perfect for my AVR, but I still added a 5.1V zener diode D1 just in case.

The rotary dial module is disconnected from the phone circuit and connected to my adapter only. The purpose of the connection between pins F and RR is to make phone think that the dial is still connected.

I am generating DTMF/PWM signal on the AVR pin 5 and feeding it to the emitter follower Q1 via the low-pass filter (C1, R3).

If you are curious, you can grab an AVR source code here.

Here is the video testing the adapter

During the test I ran into the interesting issue. I noticed that AVR power consumption at the power-down mode is much higher than I anticipated (~500uA instead of ~10uA). After poking around I traced the issue to the debugWIRE interface. I was using debugWIRE to download and debug code on the AVR. Yet apparently debugWIRE draws a lot of current (~500uA). Disabling debugWIRE via fuses and using ISP instead solved the problem.

The last steps were to wire the adapter on the perforated board.

Then mount it inside the phone (thank you again, hot glue)

Done! Just put the cover on. Obviously it looks exactly the same as before modifications.

Next steps. I guess there is none. Well, maybe to record how this phone rings and use it as a ringtone.

Contact us to get started on your next Embedded Development & Programming project. 

The post Updating Your Rotary Dial Phone for the Digital Age appeared first on DMC, Inc..

]]>
Exploring Altium: Design Rules https://www.dmcinfo.com/blog/28362/exploring-altium-design-rules/ Mon, 17 Jun 2013 14:33:48 +0000 https://www.dmcinfo.com/blog/28362/exploring-altium-design-rules/ Some rules are meant to be broken. Unfortunately, none of them apply to PCB design. Designing and developing printed circuit boards can be an unforgiving process: placing a critical analog line just a few millimeters closer to a noisy clock line might be the difference between a functional widget and an expensive drink coaster. Luckily, […]

The post Exploring Altium: Design Rules appeared first on DMC, Inc..

]]>
Some rules are meant to be broken.

Unfortunately, none of them apply to PCB design.

Designing and developing printed circuit boards can be an unforgiving process: placing a critical analog line just a few millimeters closer to a noisy clock line might be the difference between a functional widget and an expensive drink coaster. Luckily, many modern software tools provide safeguards to catch critical mistakes before they’re sent out to your favorite PCB fabricator. The most fundamental of these safeguards are the Design Rules.

In the context of PCB design, Design Rules are a set of requirements, restrictions, and constraints that the board must meet in order to be considered a valid design. An example rule might be that the minimum distance between two copper board features (like a trace and the annular ring of a via) must not be closer than 5 mils (5 thousandths of an inch). As the designer places and routes components, Altium will check the board against this rule set. Depending on the user’s preferences, errors can either be reported in the background or prevented in real-time. Sounds great! What’s the catch?

The range of possible applications for a printed circuit board is amazingly broad. As a result, tools like Altium are made to be as flexible as possible. The downside is that there isn’t a single set of design rules that can play nicely with every PCB design. The standard rules that have been developed cover a large chunk of the playing field, but the designer of any reasonably complex board will need to refine these default rules to match the application. Luckily this is a straightforward process in Altium, and we’ve developed some best practices that you can use to get going quickly.

Design Rule Editor

To get an idea of the range of design rules available within the Altium PCB Editor, open an existing design or start a new PCB project. Then, open the PCB Rules and Constraints Editor by clicking Design -> Rules…

The editor window will look like the following:

The Design Rules are divided up into several different categories, like Electrical, Routing, Signal Integrity, etc. Expanding a category shows the individual rules that can be modified for each. Let’s go back to the example earlier in this post that defines a minimum separation between copper features. That rule is captured under Electrical -> Clearance. Highlight that rule in the tree view on the left side of the editor to show the details of the constraint.

Altium decides how to apply design rules by evaluating one or more queries. In the case of the electrical clearance rule, two queries are executed: one to pick the first copper feature, and the next to pick the second. By default, the query is simply “All” which means that the design rule is applied to every object in the design. For anyone new to the query system in Altium, I recommend reading this article on the Altium Wiki.

The Constraints are then evaluated for each object returned by the queries. Here, any two items that are on different nets (3.3V and Ground, for example) are required to be no less than 10 mils apart. Most of the rules have associated diagrams that illustrate what is being controlled.

Taking Advantage of Rule Priority

There may be situations in your design where two different constraints of the same design rule might apply for different groups of components or traces. An example that has popped up on a few of my past designs applies to the Short Circuit rule (Electrical -> Short-Circuit). In general, short circuits on a PCB are a bad thing. However, I will sometimes create separate nets for my Ground and Shield connections so that I can apply different rules and routing techniques to each. The tie point on the board (where the shield and ground meet) will usually be a copper region to which both nets will connect.

The default Short-Circuit rule will prevent me from making this connection (or at least give me a warning… more on this distinction later). However, I can modify my design rules so that this connection is allowed by manipulating the rule priority.

Notice in my rule hierarchy that there are now two short circuit rules, listed in descending priority:

1. ShortCircuit_GroundShield

2. ShortCircuit_Default

When there are multiple rules defined for a rule category, Altium applies a priority ranking system to decide which rule will be executed.  First, the query (or queries) for each rule is evaluated. If multiple rules apply to a set of query results, the highest-priority rule will be executed.

In this example, the ShortCircuit_GroundShield rule applies to objects where the first is in the net “GND” and the second object is in the net “SHIELD”. The ShortCircuit_Default rule applies to any two objects. Clearly, there is some overlap in the scope of these rules. If my board had three nets – 3.3V, GND, and SHIELD, no short circuits would be allowed between 3.3V and GND or 3.3V and SHIELD, but would be allowed between GND and SHIELD.

Editing rule priority can also be useful if a small number of components have requirements that differ from the majority of the board. For example if the minimum trace spacing for the board is 5mils, but a noisy net needs to be 10mils from any other, a new clearance rule (with a higher priority than the default rule) can be added that applies only to the noisy net.

Automating Rule Creation

Altium has a built-in tool called the Design Rules Wizard that provides a friendlier interface for adding design rules to the project. I haven’t used it often (I prefer the query system, which is immensely powerful), but I do know that it is very quick to add a new rule without needing to dig far into the Rule Editor window. You can access this tool in Design -> Rule Wizard…

Importing and Exporting Design Rules

“But Ryan, I’m a rebel and can’t be trusted creating rules! What can I do?”

Despite my thoughts on the matter, I understand that some engineers are just edgy by nature. It’s okay, you’re covered. Design rules can be imported and exported within Altium, so you’re free to use rules from a more responsible source. To import or export design rules, first open the PCB Rules and Constraints editor, then right click on any item in the rule hierarchy. Select either “Import Rules…” or “Export Rules…” If you’re exporting, you can pick which rules will be included in the output file by selecting the relevant items.

A handy tip: if you know what manufacturer will be fabricating your design, see if they have design rules available that match their capabilities. Sunstone Circuits (an Oregon-based PCB manufacturer) has a compatible set of design rules for Altium available on their Downloads page.

Design Rule Check

“Okay, my design rules are set up. Now what?”

At any time, you can check your design against the current rule set by clicking Tools -> Design Rule Check…  This will open the Design Rule Checker, which allows you to select which rules will be enabled, as well as how the results will be reported.

Clicking “Run Design Rule Check” will perform the DRC, and will display the results in an HTML report (this is also saved to the project directory for access later). An example report might look like the following:

Each of these violations are linked to the coordinates on the PCB that they were observed (clicking on the violation will take you there), which makes it easy to identify the cause and (hopefully) the remedy.

Online DRC

Seeing the mistakes you’ve made is one thing, but it’s more efficient to avoid mistakes instead of going back to fix them. Altium has a feature called the Online DRC that will prevent you from making mistakes in real-time, or at least warn you if you’re violating a rule. Enable this functionality in the Preferences window (Tools -> Preferences…), under the PCB Editor -> General -> Online DRC.

The default settings for the DRC are acceptable for most designs, but you can change which violations are checked and how they are displayed in real-time by navigating to the DRC Violations Display tab within the preferences window.

Final Thoughts

Congratulations, your safety net is now installed! Altium’s Design Rule functionality is one of the most powerful and important features of the PCB editor, and I recommend that careful attention is paid to setting them up before the design is started. Nothing is more frustrating than getting halfway through a design and then realizing that a critical requirement has been blatantly violated all over the place.

No safety net is perfect and you should always take steps to verify your design beyond the design rule check (whether that is a peer review or a prototype run). That said, I hope you found this tutorial informative and useful. Leave any comments or questions below and don’t forget to check out the other articles in the Exploring Altium series!

Pin Swapping

Document Management

The post Exploring Altium: Design Rules appeared first on DMC, Inc..

]]>