Low-Power Embedded Design Archives | DMC, Inc. https://www.dmcinfo.com/blog/category/embedded-development-programming/low-power-embedded-design/ Tue, 23 Dec 2025 16:03:49 +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 Low-Power Embedded Design Archives | DMC, Inc. https://www.dmcinfo.com/blog/category/embedded-development-programming/low-power-embedded-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..

]]>
Creating a GATT Server With ESP-IDF’s Latest Bluetooth LE Stack: NimBLE https://www.dmcinfo.com/blog/19377/creating-a-gatt-server-with-esp-idfs-latest-bluetooth-le-stack-nimble/ Mon, 19 Apr 2021 15:41:01 +0000 https://www.dmcinfo.com/blog/19377/creating-a-gatt-server-with-esp-idfs-latest-bluetooth-le-stack-nimble/ At the end of 2019, the ESP32 became Bluetooth LE 5.0-certified. This certification demonstrates Espressif’s commitment to staying compatible with the latest devices on the market. Luckily for us, this makes it easy for new and existing products to use the 5.0 standard. Another way Espressif is improving their Bluetooth capabilities is by porting a new […]

The post Creating a GATT Server With ESP-IDF’s Latest Bluetooth LE Stack: NimBLE appeared first on DMC, Inc..

]]>
At the end of 2019, the ESP32 became Bluetooth LE 5.0-certified. This certification demonstrates Espressif’s commitment to staying compatible with the latest devices on the market. Luckily for us, this makes it easy for new and existing products to use the 5.0 standard.

Another way Espressif is improving their Bluetooth capabilities is by porting a new BLE-only stack called NimBLE into their ESP-IDF. ESP-IDF is Espressif’s software development kit (SDK) for the ESP32. Previously, the only option for Bluetooth on the ESP was BlueDroid, which implemented classic Bluetooth and Bluetooth LE. BlueDroid is large in terms of both code size and runtime memory—even if the application only uses Bluetooth LE. I recently implemented a GATT server using NimBLE on the ESP32 and in this blog, I’ll share some of the things I learned.

NimBLE Functionalities 

NimBLE is the BLE stack used for Mynewt OS, a cross-platform OS targeted at IoT devices. Mynewt contains a variety of lower-level functions and structures that are used across their higher-level communication protocol stacks (NimBLE included). Espressif therefore had to port over some of these lower-level functions and structures along with the NimBLE stack, such as the ble_hs_mbuf_to_flat() function.

Data in NimBLE is passed around via memory buffers named mbufs. Mbufs are a linked list containing data needed for any type of packet in Mynewt OS. Data coming to my application from the NimBLE stack would be in an mbuf, and the data I want to send to the NimBLE stack needed to be in an mbuf. There are a few functions ported into ESP-IDF to encode or decode mbufs to a Uint8Array, but the ones I primarily used were:

ble_hs_mbuf_to_flat()

ble_hs_mbuf_from_flat()

I used these when I needed to create an mbuf to be passed into NimBLE, or when I needed to access the raw data from an mbuf passed to my application from NimBLE.

Customization

With NimBLE, creating custom services and characteristics is surprisingly easy. For background, all BLE services and characteristics have universally unique identifiers (UUIDs). Some generic UUIDs are reserved by the Bluetooth SIG and should only be used by specific metrics. For example, the device name should always be at UUID 00002A00-0000-1000-8000-00805F9B34FB. Some applications require data to be sent that does not fall into any of these generic UUIDs, and therefore require a custom service or characteristic. Doing so is as easy as passing a ble_gatt_svc_def structure to the NimBLE stack. Part of the ble_gatt_svc_def structure requires a user callback. This user callback will be called to handle BLE events like writes or reads of any characteristic. I found this easy to set up and clean if you need to expand and customize BLE services or characteristics.

You can check out some examples of the NimBLE port inside ESP-IDF. There are examples showing GATT servers/clients, and one for creating a BLE mesh. I hope this can help in creating your next BLE project with the ESP32!

Read more about DMC’s embedded development and programming expertise and contact us to get started on your next project. 
 

The post Creating a GATT Server With ESP-IDF’s Latest Bluetooth LE Stack: NimBLE appeared first on DMC, Inc..

]]>
Unveiling the Power of the Nordic nRF9160 SiP https://www.dmcinfo.com/blog/20419/unveiling-the-power-of-the-nordic-nrf9160-sip/ Tue, 07 Jan 2020 13:22:13 +0000 https://www.dmcinfo.com/blog/20419/unveiling-the-power-of-the-nordic-nrf9160-sip/ The nRF9160 is one of the latest product releases from Nordic. I have been having a lot of fun creating user applications with this chip, and wanted to share my experience with this new tool. A Chip That Packs a Punch The nRF9160 is a system-in-Package (SiP) that includes an LTE modem with an Arm Cortex-M33 processor […]

The post Unveiling the Power of the Nordic nRF9160 SiP appeared first on DMC, Inc..

]]>
The nRF9160 is one of the latest product releases from Nordic. I have been having a lot of fun creating user applications with this chip, and wanted to share my experience with this new tool.

A Chip That Packs a Punch

The nRF9160 is a system-in-Package (SiP) that includes an LTE modem with an Arm Cortex-M33 processor for user applications. The modem can support either LTE-M or NB-IoT, but it can also be updated dependent on the application. The processor has 1MB of flash, 256 KB of RAM, and 32 GPIO. The SiP also has a built-in GPS receiver. I think one of the most impressive things about this chip is that its only 16mm X 10mm X 1mm. It’s tiny, but it really packs a punch! I couldn’t wait to get my hands on this development kit.

Nordic nrf9160 chip
The nRF9160 Development Kit

Development Environment

Nordic’s documentation for setting up the development environment made it easy to get to the point where I could flash sample programs. The desktop app, called nRF Connect for Desktop, is their suite where they house their apps for nRF devices. The app called Getting Started Assistant walked me through setting up their toolchain, SDK, and development environment. 

Nordic nrf9160 documentation
nRF Connect for Desktop application

The IDE of choice for the nRF modules is SEGGER Embedded Studio (SES). Nordic has their own edition of SES that is used to open their nRF Connect SDK Projects. Installing this edition of SES is covered in the Getting Started Assistant application. You can open one of their SDK projects through File -> Open nRF Connect SDK Project… This will autogenerate some files necessary to open your project through SES, as well as create some configuration files. 

Their samples are combinations of solutions that consist of smaller projects that compile to C libraries. You can configure what projects are included in your solution by selecting Project -> Configure nRF Connect SDK Project. This menu is also used to enable the options of Zephyr, the RTOS used with their SDK. This menu then updates a configuration file for Zephyr and other projects in your build directory. The initial values of these configuration files are set through the prj.conf file in your project folder. 

Configure Nordic nrf9160nRF Connect SDK configuration menu

Create an Application

To begin creating your own application, you’ll probably want to start with one of the sample projects. You can use the project named libapp.a to store your application files. You can open your applications CMakeList by right-clicking your project and choosing Open CMakeLists.txt in Editor. This lets you choose all include directories and source files needed by your application. When you are ready to test, you can go to Build -> Build and Run or Build -> Build and Debug

I hope this helps you have as much fun creating user applications with this chip as I did! One thing to note is that, since this chip is still fairly new, there are some kinks to be worked out in the SDK. Luckily, Nordic has been very responsive to issues in their forums and are continuously releasing bug fixes and features to their SDK. Stay tuned for the some of the amazing applications that will come out of this chip!

Learn more about DMC's embedded development expertise.

The post Unveiling the Power of the Nordic nRF9160 SiP appeared first on DMC, Inc..

]]>
4 Tips for Launching a Product on Emerging Cellular Networks https://www.dmcinfo.com/blog/20846/4-tips-for-launching-a-product-on-emerging-cellular-networks/ Fri, 04 Oct 2019 14:51:46 +0000 https://www.dmcinfo.com/blog/20846/4-tips-for-launching-a-product-on-emerging-cellular-networks/ The major cellular network providers (AT&T, Verizon, T-Mobile) have launched or are in the process of launching upgrades to their LTE networks that will enable the deployment of millions of new, previously impractical IoT solutions. LTE-M (aka CAT-M1) and NB-IoT networks are designed specifically for low-power, low-cost, low-bandwidth devices. By reducing the bandwidth, carriers can offer connectivity at increasingly lower monthly costs. Devices […]

The post 4 Tips for Launching a Product on Emerging Cellular Networks appeared first on DMC, Inc..

]]>
The major cellular network providers (AT&T, Verizon, T-Mobile) have launched or are in the process of launching upgrades to their LTE networks that will enable the deployment of millions of new, previously impractical IoT solutions. LTE-M (aka CAT-M1) and NB-IoT networks are designed specifically for low-power, low-cost, low-bandwidth devices. By reducing the bandwidth, carriers can offer connectivity at increasingly lower monthly costs. Devices using cellular modules may cost as little as $1 monthly.

These new networks are the future of IoT. However, as this writing, many of these networks still have a lot of kinks to work out. Cellular module vendors are rapidly developing and lunching modules for these networks. These modules are all new and so is the network, so challenges launching a product on one of these networks are to be expected.

What to Do

1. Know your Module Vendor
When selecting a cellular module vendor make sure they have a good support network. With new network deployments, there will be a LOT of updates happening in the background. The cell providers will be making adjustments and so will the module vendors. It’s important to understand the level of support you will get from the module vendor if your device happens to uncover a bug or incompatibility between the module and the network, or worse, between the module and a specific cell tower.

SARA-R4 by ublox SIM7000X by Simcon nRF9160 by Nordic
ublox SARA-R4 series, SIMCom SIM7000X, and Nordic nRF9160

2. Understand the Module Power Requirements
Most of these cellular module vendors provide a lot of marketing material about the low power requirements of their modules. These low power modules promise battery-powered cellular connectivity with years of battery life. It’s true, these modules have very low average currents while operating. The important thing to understand is that they also have relatively high peak current demands, which means you need to select your battery and design your power circuitry carefully. You won’t see any cellular IoT devices running on coin cells anytime soon.

Lithium Thionyl Chloride is popular cell chemistry for super long-life Wi-Fi or Bluetooth IoT devices, but most of the batteries made with this chemistry fail to provide the high peak current required by the cellular modules. Spiral wound Lithium Thionyl Chloride batteries use the same chemistry but provide higher peak current (by increasing the electrode surface area), however these batteries may still not meet the peak current demands.

Spiral bound lithium battery diagram
Spiral wound Lithium Thionyl Chloride batteries

Instead, you may need to consider hybrid batteries like these from Xeno Energy which consist of a Lithium Thionyl Chloride cell and a parallel supercapacitor. The supercapacitor can provide high peak currents while exhibiting very low leakage.  Although the cost is higher for this battery topology, it provides the performance needed for long life cellular IoT devices. 

Hybrid battery graphic
Hybrid battery

3. Test Your Module in a Wide Variety of Conditions
These modules contain closed-source vendor-supplied firmware. The operation of the module may not be fully documented. Part of your testing protocol should include adding attenuators to the cellular antenna (to simulate poor cellular reception) and observing how the module functions with reduced signal strength.

Modules draw significantly more average current when operating at this reduced signal level. Not knowing this ahead of time can be problematic, especially if your product advertises a minimum battery life expectancy. The actual battery life will largely depend on your connection to the cellular network. The total energy required to transmit a message from your device to the backend server can vary significantly depending on your signal strength and the number of retries required. 

Add attenuators to the cellular antenna for testing
Add attenuators to the cellular antenna to test at a reduced signal strength

4. Expect and Plan Time for Network Issues
These networks are going to be great, but until they are fully stable your product launch is going to go slower than you hoped. Add extra time in your launch schedule to account for these unknowns and extend your engineering budget to account for the time required to work through these issues. 

Keep in mind that different cell towers may contain different vendor hardware. Each of these vendors may be interpreting the CAT-M1/LTE-M specification differently and you may encounter situations where the firmware in your device performs better on some towers than others. If you encounter issues like this, move your device to a different location to see if it picks up a different tower and starts working. Eventually, these issues will be worked out by the carriers and module providers, but you should initially be prepared to work through these situations during your testing and product rollout.           

Two cell towers
The firmware in your device may perform better on some cell towers than others due to hardware differences

Learn more about DMC’s IoT solutions

The post 4 Tips for Launching a Product on Emerging Cellular Networks appeared first on DMC, Inc..

]]>
Getting Started with the ESP32 & ESP8266: 8 Tips and Tricks https://www.dmcinfo.com/blog/21298/getting-started-with-the-esp32-esp8266-8-tips-and-tricks/ Wed, 03 Jul 2019 09:31:58 +0000 https://www.dmcinfo.com/blog/21298/getting-started-with-the-esp32-esp8266-8-tips-and-tricks/ Espressif makes two of the most common modules used for Wi-Fi integration in embedded systems, the ESP8266 and ESP32. The ESP8266 was huge for IoT development. It contains a high-performance CPU with an antenna etched into the PCB to allow Wi-Fi connectivity. If you are left wanting more, the ESP32 packs another CPU and includes […]

The post Getting Started with the ESP32 & ESP8266: 8 Tips and Tricks appeared first on DMC, Inc..

]]>
Espressif makes two of the most common modules used for Wi-Fi integration in embedded systems, the ESP8266 and ESP32. The ESP8266 was huge for IoT development. It contains a high-performance CPU with an antenna etched into the PCB to allow Wi-Fi connectivity. If you are left wanting more, the ESP32 packs another CPU and includes BLE and classic Bluetooth.

Espressif developed the Espressif Internet Development Framework (ESP-IDF) as their SDK for developing with the ESP32. There is a very good guide to getting their toolchain and SDK setup on Espressif’s website. The ESP-IDF has components for almost anything you’d like to do with the ESP32. There are drivers for GPIO, Wi-Fi, IoT communication standards, and so much more. Espressif recently began modifying their SDK for the ESP8266 to be similar to the ESP-IDF.

The ESP-IDF uses a menuconfig to enable sections of the ESP-IDF API, configure peripherals, etc. This is nice for finding all the components that are available through ESP-IDF and their options. Some of these options can also be changed on the fly through API calls, but I’d argue that I’d rather have these configured before runtime.

esp microcontrollers

The ESP32 and ESP8266 are both great modules to work with, but each of them has their quirks. Below, I’ve compiled a list of tips for getting started with the Espressif modules:

  1. The sdkconfig file saves all the changes made in the menuconfig
    • The menuconfig saves all configurations in a file called sdkconfig. Sdkconfig shows all options available to be set through menuconfig. If you are searching for a specific option, it can be quicker to ctrl = f through sdkconfig and backtrack to find the location through menuconfig.
    • Menuconfig does read and write from sdkconfig, so changes you make in sdkconfig will be reflected in menuconfig. If you have a lot of trouble finding a parameter through menuconfig, this can be a backup option (though it is not recommended by Espressif so be warned!)
  2. Run make with parallel jobs
    • Building a project using ESP-IDF can take a while because they do not automatically run parallel jobs. This causes long compile times when rebuilding from scratch. Since every change in menuconfig requires a complete rebuild, this can start to eat a significant amount of development time.
    • To build with parallel jobs, you need to add the -j option to your make commands. A command of make -j4 will run make with 4 parallel jobs. Espressif recommends running with option -j(number of CPUs +1)
  3. Not all GPIO pins have full functionality
    • The ESP32 has 4 pins that are labeled as input only. These pins are GPIO 34, 35, 36, and 39.
    • The ESP32 also has 18 ADC pins, however, 10 of these cannot be used while Wi-Fi is being used! The pins that cannot be used as ADC with Wi-Fi are GPIO 0, 2, 4, 12, 13, 14, 15, 25, 26, 27.
    • Since the ESP32 and ESP8266 have external flash, the modules have a SPI interface. On some development boards, these pins are exposed, so it is recommended to not use these pins in your projects. On both boards, these pins are GPIO 6-11.
  4. Default FreeRTOS tick is 10ms
    • The default tick rate for FreeRTOS in ESP-IDF is 100. This can be updated up to 1000 with no issues, but anymore than that I’ve heard is unreliable. If you need timing more precise than 1ms, you may need to implement RTC timers with interrupts.
  5. OTA updates for ESP32
    • ESP-IDF gives the user control over how the external flash is utilized through a partition table. Setting up the flash partitions correctly is essential for OTA updates. OTA updates require at least 3 entries, otadata, ota_0, and ota_1.
      OTA updates
    • On first boot, the bootloader jumps to ota_0 partition (if the factory partition is not specified) and begin running the firmware. When the firmware activates a firmware update, it then updates the ota_1 partition. The device then runs the firmware in ota_1 and updates otadata to mark ota_1 as the active partition, so that on bootup, ota_1 is run.
    • One of the cool features included in this method of updating firmware is that it allows for firmware verification on every update. This way, if you push code to your device that doesn’t pass your user-defined tests, the device can roll back to the previous ota partition and continue running. This is a nice feature to be rolled into the ESP-IDF as it can save.
  6. Add more RAM
    • Both the ESP32 and ESP8266 support adding additional RAM. Espressif has even developed an SRAM device for the ESP32, called the ESP-PSRAM32. The external RAM is connected in parallel with the external flash chip, allowing the new RAM to be accessed the same as internal RAM.
    • Espressif also has the ESP32-WROVER module, which contains an external 4MB SPI Flash and 8MB external PSRAM, in case you don’t want to add these yourself.
  7. Security
    • Both modules support signed firmware updates. This can help guarantee that any code updates are only applied by you (or anyone who gets a hold of your private key). Additionally, the ESP32 supports secure boot and flash encryption. Secure boot is another method of ensuring only your code can run on your device. Flash encryption protects your firmware from being accessible to anyone with physical access to your device.
  8. Low-Power Mode
    • Both the ESP8266 and ESP32 can enter either light sleep or deep sleep.
    • In light sleep, clock pulses are powered off and RAM is retained. When exiting light sleep, and the program continues from wherever light sleep mode was entered from. There is also the ability to enable automatic light sleep, which can retain Wi-Fi connection by cycling between active mode and light sleep mode.
    • In deep sleep, the CPU and memory are powered off. The RTC module is still powered in this mode, which is responsible for periodic wakeups and can store a small amount of memory. The ESP32 also has an ultra-low power processor that can be enabled in deep sleep!

Contact Us Today to Speak With Our Embedded Development Solutions Experts and We Can Get Started on Your Next Project!

The post Getting Started with the ESP32 & ESP8266: 8 Tips and Tricks appeared first on DMC, Inc..

]]>
Oxidizing Bare Metal: Rust Programming for ARM Microcontrollers https://www.dmcinfo.com/blog/21750/oxidizing-bare-metal-rust-programming-for-arm-microcontrollers/ Fri, 19 Apr 2019 12:33:02 +0000 https://www.dmcinfo.com/blog/21750/oxidizing-bare-metal-rust-programming-for-arm-microcontrollers-4/ Being an embedded systems developer is always an exciting challenge. One of the downsides though is that in general, programming and development tools are somewhat limited. Developers are almost always restricted to C/C++ and often can’t rely on more extensive open source libraries. However, recently there have been many efforts to expand high-level language support […]

The post Oxidizing Bare Metal: Rust Programming for ARM Microcontrollers appeared first on DMC, Inc..

]]>
Being an embedded systems developer is always an exciting challenge. One of the downsides though is that in general, programming and development tools are somewhat limited. Developers are almost always restricted to C/C++ and often can’t rely on more extensive open source libraries. However, recently there have been many efforts to expand high-level language support to ARM-based bare metal targets.

Projects using MicroPython and JerryScript attempt to provide a means to write Python and JavaScript code and provide frameworks for “compiling” and running scripts on a variety of bare-metal targets. However, these types of frameworks have some inherent drawbacks. JavaScript and Python are both interpreted languages with garbage collection and weak typing. Running these languages requires relying on a run time or more complex cross compiler.

A New Language for Embedded Systems

More recently, Rust has emerged as an appealing language for applications that require memory safety and efficiency. Both of these features are often critical for embedded devices. Manual memory management often creates bugs which are hard to isolate and are not always easily remedied due to the resource constraints of embedded devices.

Additionally, C/C++, even given all of its faults, remains a highly efficient language due to the control it provides developers and because it can use many target-specific optimizations at compile time. C/C++ sets a high benchmark for speed that is difficult for interpreted languages to match.

Rust, fortunately, solves both problems in ways that are particularly well suited to microcontrollers. Rust does not require any run-time engine for garbage collection or memory management. Rust instead chooses to enforce memory safety at compile time. Furthermore, because Rust compiles to LLVM, target optimizations rivaling those achievable with C/C++ are possible. Recently, the Rust core team has made support for new target architectures a priority, and there are already many open source projects aimed at expanding support for embedded devices in Rust.

Nucleo PCB Running on Rust

Getting Started with Rust

The Embedded Rust Book provides many details regarding getting started with Rust on embedded devices. For this blog, I’ll highlight a few key components that make up the Rust embedded landscape. Specifically, I’ll be discussing support for ARM Cortex M based microcontrollers.

The Rust ecosystem is built on an extensive library of packages called “Crates.” A few specific crates, “cortex-m” and “cortex-m-rt”, make up the core support for ARM targets. These packages provide the bare minimum of code to get a basic program up and running. It allows access and control of the core ARM registers.

Below is an example of setting up the systick peripheral taken from the Rust Embedded Book.

Rust
use cortex_m::peripheral::{syst, Peripherals};
use cortex_m_rt::entry;

#[entry]
fn main() -> ! {
    let mut peripherals = Peripherals::take().unwrap();
    let mut systick = peripherals.SYST;
    systick.set_clock_source(syst::SystClkSource::Core);
    systick.set_reload(1_000);
    systick.clear_current();
    systick.enable_counter();
    while !systick.has_wrapped() {
        // Loop
    }

    loop {}
}

To implement something more interesting than a simple timer, we’ll need a Peripheral Access crate. These crates are typically specific to a vendor and family of microcontrollers. For example, the STM32F4 crate provides an API for accessing various peripherals such as GPIO, UART, and I2C for the STM32F4 family of devices.

Pulling in a Peripheral Access crate, we can build a program for toggling an LED:

Rust
fn main() -> ! {
    let mut peripherals = stm32f429::Peripherals::take().unwrap();

    //Enable gpio b clock
    let rcc = &peripherals.RCC;
    rcc.ahb1enr.write(|w| w.gpioben().bit(true));

    //set pin 14 to output
    let gpio = &peripherals.GPIOB;
    gpio.moder.write(|w| w.moder14().bits(1));

    //Turn on led
    gpio.odr.write(|w| w.odr14().set_bit());

    loop {

        delay(10000);
        if  gpio.odr.read().odr14().bit()
        {
            gpio.odr.write(|w| w.odr14().clear_bit());
        }
        else {
            gpio.odr.write(|w| w.odr14().set_bit());
        }
        
    }
}

fn delay(count: u32) {
     for _ in 0..count { cortex_m::asm::nop() }
}

Although Rust is an exciting new option for embedded development, it will take some time for it to supplant C/C++ as the standard. A lack of official support from major silicon vendors like ST, NXP, and Silicon Labs means that adding support for new microcontrollers can be a tedious process. Additionally, C/C++ frameworks like ARM’s mbed offer large, general purpose libraries and drivers that can be used across a variety of ARM targets with little to no modification.

Learn more about DMC’s Embedded Product Development Services and Embedded Systems Platforms expertise.

The post Oxidizing Bare Metal: Rust Programming for ARM Microcontrollers appeared first on DMC, Inc..

]]>
Recovering Missing Library Components in Altium Designer https://www.dmcinfo.com/blog/25888/recovering-missing-library-components-in-altium-designer/ Tue, 09 Feb 2016 13:51:36 +0000 https://www.dmcinfo.com/blog/25888/recovering-missing-library-components-in-altium-designer/ Have you ever opened an Altium project only to discover that a Footprint or Schematic Library file is missing? Maybe your coworker forgot to commit the files to version control, or forgot to include them in the .zip file before leaving for vacation. If so, have no fear: you can recover the footprints easily and […]

The post Recovering Missing Library Components in Altium Designer appeared first on DMC, Inc..

]]>
Have you ever opened an Altium project only to discover that a Footprint or Schematic Library file is missing? Maybe your coworker forgot to commit the files to version control, or forgot to include them in the .zip file before leaving for vacation. If so, have no fear: you can recover the footprints easily and automatically.

Schematic Library

From the Schematic Editor, select Design -> Make Schematic Library.

Altium will convert each component on your schematic into a library component and will use the Library Reference parameter to name each component. However, if you use part parameters to store information like part numbers, vendor links, etc. (which you should be!), Altium will flag components with the same Library Reference but different parameters. An example of this is shown below. Two of the capacitors in my schematic use the same symbol but have different part number fields ("different internal structure" in Altium-speak).

Duplicated components interface in Altium Designer

There's no need to have several different capacitor (or inductor, resistor, etc) symbols in your symbol library – you just need to make sure you edit/verify the component parameters when you add the component to your schematic. But you do that anyway, right?

If you select "Process only the first instance and ignore the rest" and then click "Remember the answer and don't ask again", it will only create one schematic symbol per Library Reference.

When finished, the new symbol library will be added to your project and opened in Altium. By default, the library filename is set to whatever your project file is named.

Footprint Library

To generate a footprint library, go to your PCB Editor and select Design -> Make PCB Library. As before, Altium will create a new library component for each footprint in your design and then open the library for your perusal when complete.

Library Trimming

This functionality is useful in a few other cases as well. The main case is useful for handing off the finalized design to a client or manufacturer. In large embedded projects, it's common to make changes to the component selection in order to drive cost down, improve functionality, decrease power consumption, etc. As a result, there will be extra library components hanging around. Using the procedures described above, you can create libraries that contain only the parts in your design, rather than manually searching for and deleting the extras.

Happy PCB designing!

Learn more about DMC's embedded development and programming services.

The post Recovering Missing Library Components in Altium Designer appeared first on DMC, Inc..

]]>
Improving Battery Life in Low Power Embedded Applications Part 2: Case Study https://www.dmcinfo.com/blog/28457/improving-battery-life-in-low-power-embedded-applications-part-2-case-study/ Wed, 24 Apr 2013 14:25:35 +0000 https://www.dmcinfo.com/blog/28457/improving-battery-life-in-low-power-embedded-applications-part-2-case-study/ In Part 1, I talked about how battery capacity is rated and how certain conditions can affect relative battery capacity. This case study will specifically focus on a solution DMC provided for a low-power embedded application designed around user interaction with a high base current draw. Many of its principles can be applied to all […]

The post Improving Battery Life in Low Power Embedded Applications Part 2: Case Study appeared first on DMC, Inc..

]]>
In Part 1, I talked about how battery capacity is rated and how certain conditions can affect relative battery capacity. This case study will specifically focus on a solution DMC provided for a low-power embedded application designed around user interaction with a high base current draw. Many of its principles can be applied to all embedded applications.

Active/Sleep Programming

One of the first steps DMC took to help improve battery life was to use an active/sleep architecture for running the program. In this design, the microcontroller and any other high-current devices are shut down/put to sleep when they are not needed. This inherently created a variable current draw for the device, but ended up being much more efficient than having the hardware idly chewing up current without accomplishing anything (idle operations).

This was accomplished with a microcontroller by using hardware interrupts to bring the microcontroller out of a sleep state to process new data or actions. Specifically, DMC used a TI MSP430 that sat in an ultra-low power state that was interrupted by a couple of conditions: a timer set to update the user display, a button action, or new data from an external chip. Once interrupted, the microcontroller did all the necessary calculations and then went back to sleep. The microcontroller was also limited in how often it could be awoken, even when being constantly interacted with, to guarantee a certain duty cycle of sleep vs. active. Using this in place of code that actively waited for those conditions reduced the microcontroller’s average current draw by orders of magnitude. 

DMC further increased battery life by optimizing the active/sleep timing and behavior for the customer’s exact application, increasing the battery life of an inactive device from 160 to 240 hours. This was done by running all communications in parallel with processing using interrupts, and by reducing the display update frequency while keeping the user experience intact. Both of these allowed the microcontroller to get to sleep quicker and stay asleep longer.

Clockspeed Adjustments

The next step DMC took was to optimize the clock speed at which the microcontroller was operating. Almost all microcontrollers have the ability to change their clock speed, and some even dynamically while running code. If running off of an external power source, it is typical to just run the device at the highest clock speed, and with a sleep/active architecture, some may argue that the active clock speed is not important since a faster clock speed allows you to run your calculations quicker and get back to a sleep state.

However, remembering the conditions from the first post, a higher current draw has a bigger impact than a low current draw, even if they average to be the same. Therefore, DMC optimized the clock so that it only ran as fast as necessary to complete our code in the allotted amount of time. In this application, DMC used an oscilloscope to time the processing of certain functions under specific conditions, allowing the clock speed to be changed for each case while still maintaining responsiveness and accuracy.

In the image above, you can see the change in current draw when the clock speed in our application was reduced. In both cases, the amount of computation is the same, as is the average current draw over time, but the higher clock rate has a much greater peak current draw. The results of decreasing this peak were an increase in idle battery life from 260 to 300 hours and dynamic life from 150 to 180 hours.

Capacitor smoothing

In addition to reducing the clock speed when actively processing data, DMC also added capacitance to the battery supply to further reduce the peak current draws seen by the battery. By placing a fairly large capacitor in parallel with the battery, the capacitor can act as a power source when high currents are required. The result is that the battery does not have to supply all of this current, and the capacitor can be recharged during periods of low current draw. In the end, the battery sees a much smoother current profile and gets closer to our ideal situation of constant low current draw.

In the image below, the addition of a 100 mfd capacitor dramatically reduced the peak current draw seen by the battery. This resulted in an increase in dynamic battery life from 180 to 210 hours.

Conclusion

By leveraging DMC’s knowledge in embedded software and hardware development, DMC was able to improve the customer’s battery life by almost 90% when inactive and 40% when active. This, in the end, will provide a better selling point for the device and reduce battery costs and downtime for the end user.

The post Improving Battery Life in Low Power Embedded Applications Part 2: Case Study appeared first on DMC, Inc..

]]>
Improving Battery Life in Low Power Embedded Applications, Part 1: Basics https://www.dmcinfo.com/blog/28460/improving-battery-life-in-low-power-embedded-applications-part-1-basics/ Wed, 24 Apr 2013 14:05:58 +0000 https://www.dmcinfo.com/blog/28460/improving-battery-life-in-low-power-embedded-applications-part-1-basics/ As portable devices become more capable, powerful and smaller, people expect them to have more features, perform better, and replace the functionality of multiple devices. However, while embedded performance has skyrocketed, battery performance has stayed relatively the same. This has forced developers and engineers to be much more conscious of power consumption.   The Simple […]

The post Improving Battery Life in Low Power Embedded Applications, Part 1: Basics appeared first on DMC, Inc..

]]>
As portable devices become more capable, powerful and smaller, people expect them to have more features, perform better, and replace the functionality of multiple devices. However, while embedded performance has skyrocketed, battery performance has stayed relatively the same. This has forced developers and engineers to be much more conscious of power consumption.

 

The Simple Case
When discussing battery life and power consumption, average current draw is king. If certain electronics in a device draw a large amount of current, battery life can only be improved to a certain extent. There is no way to magically get more energy. The best case scenario is that a device’s battery life will follow this formula (Battery Life = Battery Capacity / Average Current Draw). This looks something like Battery Life = 300mAh / 1.2 mA  = 250 hours. However, this assumes that the current draw is around the same level that the battery was rated for and that the current draw is constant. In almost all situations, this will not be the case.

In an ideal world this formula would always hold true, however the focus of this article will be all the cases in which this isn’t true and how to get as close as we can to this ideal state. 

 

Battery Ratings and Battery Life Calculations
Any battery can be thought of as a voltage source in line with a resistor. This resistor is referred to as the internal resistance of the battery. At the beginning of its life, a battery has a small internal resistance and can supply large amounts of current with little drop in voltage. However, as the battery is depleted, this internal resistance increases to the point where drawing current from the battery reduces its voltage below a devices operating voltage. This means the battery is unable to power the device and is considered “dead”. The internal resistance of a battery tends to stay relatively constant for the beginning of its life and then increases rapidly. Therefore, measuring the behavior of a battery’s internal resistance over time is fundamental to the study a battery’s life or “relative capacity”.

When looking at a typical datasheet for a battery, there will some key points of information.  The first will simply be the voltage and rated capacity of the battery. This is typically how people will reference the battery (e.g. 3 .0V 240mAh). It is important to note that this capacity should also have a resistance and end of life voltage listed with it to specify the conditions it was tested under (e.g. 240 mAh to 2.0 volts, Rated at 15K ohms at 21°C). A typical drain current may also be used in place of the resistance (0.19mA). Additionally, there may be one or more charts detailing the battery test showing a plot of battery voltage versus time under specific draw down conditions.

If there was a device with the same current draw characteristics as one of these tests, calculating its battery life would be as simple as looking at which point on the graph the voltage drops below the devices minimum operating voltage.

Example: 

Using the battery sheet referenced earlier if we had a CR2032 battery powering a device with a constant resistance of 15K ohms and a minimum operating voltage of 2.4 V, it would have a battery life of 1200 hours.

In an ideal world one would know the exact current profile of a device and there would be a draw down graph for that profile and the devices battery. However, both are unlikely for anything beyond a very simple device. Therefore, it is important to be able to estimate battery life based on a standard graph or capacity rating, as well as know how different conditions affect battery life.

 

Effects on the Relative Capacity of a Battery
We now know that fundamental to the calculation of a device’s battery life is the change in the battery’s internal resistance over time. So in order for us to estimate the device’s battery life or the relative capacity of our battery, we need to know how different current draws affect our batteries internal resistance.

We will start with our best case scenario and go from there. In the best case we are drawing a very small constant current similar to the conditions the battery is rated under.  Under these conditions we will get the entire capacity rated by the battery. So now let’s change some things.

 

 

Operating Voltage
This is the simplest case. If a device operates at a different minimum voltage than the standard rating we simply shift our end point along the rating curve (Lower voltage = longer life, higher voltage = shorter life). It’s also important to remember the quick decay in the battery voltage curve.  o a change between 2V end of life and 2.1V end of life on a 3V battery will have very little effect on battery life since the resistance at this point is drastically increasing. However, if a device has an end of life voltage of 2.9 V on a 3V battery its battery life will be much shorter since it is not taking advantage of a large portion of the battery curve.

 

Higher Current
In this case the device is still drawing a constant current, but at a different level from the rated conditions. One might think that there is a purely linear relationship between current draw and battery life (e.g. Life = capacity/current), but this is NOT the case. The higher the current draw from the battery the quicker the internal resistance increases. So a 300mAh battery supplying 1 mA may last 300 hours, but when supplying 5mA will only last 50 hours which is less than expected (300/5 = 60 hours).

 

Variable Current
The last case would be if a device did not draw a constant current, but rather changed based on its active state. For example it may draw 9 mA for 1 second and then 1mA for 9 seconds. In this case, the average current draw will end up being 2mA over any extended period of time. However, this device will have a shorter battery life than a device drawing a constant 2mA. This is because the short period of time during which there is a high current (9mA) has a lasting impact on the resistance of the battery.

In any complex design it is likely for all of these conditions to apply. It is important to note that each has a compound effect on the final battery life and needs to be considered individually. So if a higher voltage decreases your batteries relative capacity by 5%, and a different current draw decreases it by 10%, and a variable current decreases it by 20%, our resulting device will only have a battery capacity equal to (.95x.9x.8 = .68) 68% of the rated capacity.

 

Summary
In summary, batteries are fairly complex things and behave differently in all sorts of conditions. Therefore, calculating battery life is not a matter of simply dividing the battery capacity by a devices average current draw. In this article we talked generally about how batteries are rated and the effects of different conditions on the battery. If you’re interested, there are tons of other great resources and studies on this topic that can be found through a simple Google search. Specifically DMC used the two studies below on the CR2032 coin cell detailing behavior under high pulse draw conditions.

Coin cells and peak current draw

High pulse drain impact on CR2032 coin cell battery capacity

 

In part 2 we will take a look at how this all applies to a specific device.

Learn more about DMC’s embedded development and embedded programming services.

The post Improving Battery Life in Low Power Embedded Applications, Part 1: Basics appeared first on DMC, Inc..

]]>