Tim Jager, Author at DMC, Inc. https://www.dmcinfo.com/blog/author/timj/ Tue, 23 Dec 2025 16:08:28 +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 Tim Jager, Author at DMC, Inc. https://www.dmcinfo.com/blog/author/timj/ 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..

]]>
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..

]]>
Low Cost Function Generator Amplifier DIY https://www.dmcinfo.com/blog/24248/low-cost-function-generator-amplifier-diy/ Wed, 07 Jun 2017 15:04:40 +0000 https://www.dmcinfo.com/blog/24248/low-cost-function-generator-amplifier-diy/ Introduction A majority of function generators are only capable of driving a couple of hundred milliamps, which is fine for most applications. If you want more output current, you can shell out $400 dollars for a professional signal generator amplifier, or you can do what I did and hack one together for under $40. A signal […]

The post Low Cost Function Generator Amplifier DIY appeared first on DMC, Inc..

]]>
Introduction

A majority of function generators are only capable of driving a couple of hundred milliamps, which is fine for most applications. If you want more output current, you can shell out $400 dollars for a professional signal generator amplifier, or you can do what I did and hack one together for under $40.

A signal generator is an indispensable tool for developing and testing electronic designs. You may find yourself wishing yours could output more current. You could test your power supply design by feeding in a noisy supply voltage, or you could see how it will handle a specific amount of input ripple. If you do this sort of thing regularly, you may want to invest in professional equipment. But, if you are on a budget, or only need this sort of thing occasionally, then keep reading.

Backstory

When I first started learning electronics in grade school, I had dreams of being able to build anything I wanted. After purchasing components in single quantity from Digi-Key for my first few projects, I learned a disheartening lesson. 

It almost always costs more to make something yourself than to buy a finished product.

It was then I wrote Tim’s Golden Rule of Building Electronics:

“I shall not build what can be bought unless mine shall be better or cheaper.”

So, before embarking on this project, I checked to see if there were any low-cost units on the market. The least expensive option I could find was the Siglent SPA1010 at just under $400. This unit would work for most cases, but only has a max output current of 1.1Amps, which just wasn’t enough for me.

Figure 1 – Siglent SPA1010
 

Signal Generator Amplifier DIY

Unable to find a low-cost option, I resolved myself to designing my own signal generator amplifier.

I hoped that I could design the amplifier around a high-power OP Amp. Searching for the highest output OP Amp on Digi-Key revealed the OPA541 and OPA549.

The OPA541 can handle +/- 35V rails, whereas the OP549 can only handle +/- 30V rails.

Since More Voltage = More Better, I went with OPA541.

I felt good about this selection, and I felt even better when I heard on their podcast that the guys at Macrofab were designing a power supply using this same OP Amp. Now, I just needed to whip up a schematic and layout a PCB (with a monster heatsink) to handle the OPA541.

Wait, Tim! Don’t forget about your golden rule!

Before embarking on my design, I decided to see if there were any breakout boards available for the OPA541 (preferably with a heatsink). I couldn’t find anything from the usual suspects (Adafruit, Sparkfun, etc.), but I did find something on Aliexpress.

Like most things on Aliexpress, it looked too-good-to-be-true. I found an OPA541 breakout board with free shipping for $35. The OPA541 alone costs almost $22 from Digi-Key in single quantity. So, I ordered one plus a few SMA to BNC cables for $3 each.

Figure 2 – The OPA541 cost almost $22 in singles

Figure 3 – Inexpensive SMA to BNC cables

A few weeks later, the unit arrived and looked to be as advertised.

As expected, the amplifier came with zero documentation. The circuit looked simple, so I knew I could reverse engineer it if necessary. Instead, I decided to power it up and see what happened. It was immediately apparent that it used capacitive AC coupling because it only amplified AC signals while ignoring any DC offset applied.

Having nothing to lose, I sent a message to the seller on Aliexpress asking for a schematic. I got back a one-word reply “email.”

I sent him my email address, and he sent me a link and a password to a Chinese file-sharing site which yielded a PDF schematic of the device. Awesome!

Original Chinese schematic of OPA541 module
*Click to enlarge

I noticed values for many components were not correct, so I marked up the schematic to show the actual values. The schematic is a little messy by my standards, but it was easy to see how it works. It is a two-stage amplifier. Both stages are set up as non-inverting with the first having a gain of 3 and the second a gain of 11 for a total gain of 33.

Corrected Chinese schematic of OPA541 module
*Click to enlarge

The most insane thing I discovered was that the first stage OP Amp is an OPA445, a high voltage OP Amp that costs over $10 in single quantity!

This, plus the OP541 (which costs $21), means I got $31 in chips alone for $35. Assuming these parts are legit, that’s a good deal in my book. Even if the OP Amps are counterfeit, the PCB, heatsink, and connectors are still worth $35 when considering that my alternative was to design and make my own from scratch.


Figure 4 – OP Amp for OPA541 Module

Below are side-by-side comparisons of the parts from China and ones purchased directly from Digi-Key. They don’t look identical, so I’m not sure if the parts from China are genuine.

There are two variants of the OPA541AP. One has a G3 suffix. Perhaps this explains the difference between the packages.

If anyone knows more about these ICs, please feel free to write in the comments.

To allow the device to amplify DC, I replaced C4 and C5 with 0 Ohm resistors. See below where I removed C4 enabling me to solder a 0 Ohm resistor in its place.


Other Changes

I changed the overall gain to 10 to simplify the mental math required.

To change the gains, I did the following:

  • R2 changed to 10k. Since R1 was already 10k, this set the first stage gain to 2. [1+10k/10k = 2]
  • R4 changed to 2.55k, and R7 changed to 10.2k which set the second stage gain to 5. [1+10.2k/2.55k = 5]
  • Upgraded the main Sanyo brand capacitors with Panasonic 63V rated caps because the original caps were only rated for 35 volts despite the schematic calling for a 50-volt rating.

 

Final Schematic

Below is the final schematic including all of my modifications.
DIY Function Generator Amplifier Schematic
*Click to enlarge


Testing

With the modifications complete, it was time to test the performance.

I connected the amplifier to our Rigol DP832 and configured the DP832 to provide +/-30 volts as shown in the diagram below.

For the first test, I fed in a constant DC signal voltage of 2.5 volts. As expected, the amplifier output a constant voltage of 25 volts thanks to our 10x gain. We fed the output to our BK Precision 8600 programmable load and set it to pull 2.9 Amps, which is close to the maximum of 3 Amps for our Rigol DP832 Power Supply. We were able to source over 72 Watts to the programmable load! Sweet!

Our power supply was running close to its maximum output of 3 Amps and supplying 87.7 Watts. Since it was providing 87.7 Watts and our load is pulling 72.3 Watts, the amplifier would have been dissipating the difference between those two values, or 15.4 Watts.

The thermal image (and the burn on my hand from touching the OPA541) confirms the amp was getting hot.

Thermal Image of OPA541 temperature increase

It got hot but was still operating below its 125˚C limit as shown in the datasheet snippet below:

To minimize heat dissipation, we have to remember to set our power supply voltage just a few volts above our desired max voltage output from the amplifier. Doing so will reduce the voltage differential and hence reduce the power dissipated by the amp.

Next, I connected two 12v automotive light bulbs in series to act as a load and connect our differential Oscilloscope probe across the load.

I then connected the function generator and set up a 1kHz sine wave set to 2.5 volts peak to peak. 

 

The Oscilloscope shows a ~25-volt peak sine wave at 1kHz as expected.

Below is a video showing the same setup but at 0.5Hz instead.



Conclusion

Overall, I’m quite pleased with my $40 investment. A few weeks of waiting followed by a few minutes of soldering yielded a nice addition to the test bench. It will come in handy for testing future electronic designs.

Learn More About DMC’s Embedded Development and Embedded Programming Services or Contact Us to start developing a solution that works.

The post Low Cost Function Generator Amplifier DIY 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..

]]>
Informational Webinar 11/12: Changing Machinery, Changing Software https://www.dmcinfo.com/blog/27084/informational-webinar-11-12-changing-machinery-changing-software/ Wed, 05 Nov 2014 10:47:56 +0000 https://www.dmcinfo.com/blog/27084/informational-webinar-11-12-changing-machinery-changing-software/ Join John Sullivan in conjunction with Siemens for a complimentary 45-minute educational webinar focused on converting industrial equipment from one vendor’s tools to another. The webinar will be held on Wednesday, November 12 (1 p.m. CDT) and will be targeted toward those interested in software conversions for machinery. A variety of business demands can require a company […]

The post Informational Webinar 11/12: Changing Machinery, Changing Software appeared first on DMC, Inc..

]]>
Join John Sullivan in conjunction with Siemens for a complimentary 45-minute educational webinar focused on converting industrial equipment from one vendor’s tools to another. The webinar will be held on Wednesday, November 12 (1 p.m. CDT) and will be targeted toward those interested in software conversions for machinery.

A variety of business demands can require a company to convert their industrial equipment from one vendor’s gear to another supplier’s tools. The most common reasons for conversion include: improving market position, maintaining and keeping up with corporate standards, pursuing new business opportunities or increasing financial advantages. In any of these instances, software is likely the biggest area of concern during transition. Nonetheless, conversions can be managed effectively when companies plan their conversion strategy well. 

In light of these concerns, John will talk about three different approaches to converting software code for a company that is adapting their industrial equipment from one vendor’s to another’s.

Benefits of Attending:

  • Learn the advantages of converting industrial equipment and software
  • Understand pitfalls and areas of concern in order to ensure a smooth transition 
  • Delve into three strategies for converting software and learn the pros and cons of each approach
  • Explore conversion tools available to help you speed up the conversion process
  • Find out when a systems integrator can bring value to your conversion
  • Discover how to choose the right SI to meet your unique needs

Presenter Bio:

John Sullivan holds a B.S. in Mechanical Engineering from Rose-Hulman Institute of Technology with a certificate in robotics. He is a Licensed Professional Engineer in the State of Illinois, and is a Certified Siemens Solution Partner, LabVIEW Developer, and Microsoft Certified Professional (MCP). John’s previous work experience includes Solar Turbines and General Electric-Aviation. He enjoys athletics of all kinds, including rugby, volleyball, and running, as well as outdoor activities such as backpacking and skiing.

Register for Changing Machinery, Changing Software.

The post Informational Webinar 11/12: Changing Machinery, Changing Software appeared first on DMC, Inc..

]]>
View DMC’s 2014 Siemens Automation Summit Presentations https://www.dmcinfo.com/blog/27442/view-dmcs-2014-siemens-automation-summit-presentations/ Tue, 08 Jul 2014 13:12:15 +0000 https://www.dmcinfo.com/blog/27442/view-dmcs-2014-siemens-automation-summit-presentations/ DMC attended the annual Siemens Automation Summit last month, held June 23 – 26, 2014. We enjoyed four days of learning and networking with new friends at Walt Disney World’s Contemporary Resort in Orlando, FL. The week kicked off with Monday night’s popular Connect Event. This casual cocktail event allowed attendees to build their network using […]

The post View DMC’s 2014 Siemens Automation Summit Presentations appeared first on DMC, Inc..

]]>
DMC attended the annual Siemens Automation Summit last month, held June 23 – 26, 2014. We enjoyed four days of learning and networking with new friends at Walt Disney World’s Contemporary Resort in Orlando, FL.

The week kicked off with Monday night’s popular Connect Event. This casual cocktail event allowed attendees to build their network using a mobile-friendly app or website developed by DMC and Prism Systems to connect and share contact information. Attendees also got a preview of the cool Anki DRIVE racetracks that would be at the Siemens Solution Partner booth for the rest of the event. Attendees could choose to race their friends using conventional iPads or Siemens Mobile Panels developed by DMC to control the Bluetooth racetrack.

The rest of the week involved unique presentations, training classes, technology demonstrations, and finished off with a keynote by Eric Alexander and an after party at the Expedition Everest theme park!

DMC led four presentations throughout the week. Due to the great response, we’ve made the presentation slideshows available. Feel free to contact DMC with any questions regarding this content.

Getting the Most Out of WinCC OA – Kristie Shea
Explore some of the unique benefits of the Siemens Open Architecture SCADA platform and learn about specific projects where these object-oriented tools were used to meet demanding requirements without changing a single line of PLC code. Based on a project’s requirements, learn how to best choose between the three different Siemens SCADA offerings: WinCC OA, WinCC V7 or WinCC TIA Professional.

Best Practices for Selecting and Working with a Solution Partner – Tim Jager 
Get an insider’s view on how to best work with solution partners to maximize your return on investment. Learn when to use an integrator and how to choose the right integrator. 

Utilizing Siemens Best Practices When Leveraging Existing Rockwell Code – John Sullivan
Are you in the process of switching to Siemens hardware from Rockwell, but already have a working Rockwell program? Some people try to copy it over directly and miss out on the great opportunity that Siemens provides to make your code more flexible and reliable.

Extending S7 PLC Capabilities by Leveraging the Unique Strengths of the WinAC Platform 
– Alex Krejcie

Automation applications often have specific hardware and software requirements that pose integration challenges for system designers. The WinAC RTX platform is commonly used to provide deterministic real-time algorithm processing in a PC environment. See how DMC has been able to reduce application costs through hardware simplification and quicker development time by leveraging the unique capabilities of the WinAC platform.

The post View DMC’s 2014 Siemens Automation Summit Presentations appeared first on DMC, Inc..

]]>
DMC Joins Siemens SIMATIC IT Partner Program https://www.dmcinfo.com/blog/27455/dmc-joins-siemens-simatic-it-partner-program/ Mon, 23 Jun 2014 10:37:38 +0000 https://www.dmcinfo.com/blog/27455/dmc-joins-siemens-simatic-it-partner-program/ DMC is proud to announce its affiliation with the Siemens SIMATIC IT Partner Program. SIMATIC IT Partners offer value added services helping customers realize solutions tailored to their unique business environments in order to maximize the efficiency of MES installations. We're excited to join a community of technical experts with industry specific know-how who are recognized […]

The post DMC Joins Siemens SIMATIC IT Partner Program appeared first on DMC, Inc..

]]>
DMC is proud to announce its affiliation with the Siemens SIMATIC IT Partner Program. SIMATIC IT Partners offer value added services helping customers realize solutions tailored to their unique business environments in order to maximize the efficiency of MES installations.

We're excited to join a community of technical experts with industry specific know-how who are recognized as high-level consultants dedicated to helping customers achieve their business goals. SIMATIC IT Partners are proficient in attaining production process transparency, identifying requirements, and developing, maintaining, and implementing leading MES solutions based on SIMATIC IT.

The SIMATIC IT partnership is a strong compliment to DMC’s long-standing position as a Siemens Automation Solution Partner. We have successfully implemented hundreds of project solutions using Siemens PLCs and in all aspects of the SIMATIC development environment. 

“With experience in both Siemens SIMATIC IT and Automation, our engineers and consultants are uniquely qualified to implement effective solutions bridging automation, Manufacturing Execution Systems (MES), and Enterprise Resource Planning (ERP) systems,” said DMC Senior Project Engineer, Kevin Ferrigno.

DMC's SIMATIC IT Partnership status is a formal recognition of our dedication to providing our clients superior MES solutions.

The post DMC Joins Siemens SIMATIC IT Partner Program appeared first on DMC, Inc..

]]>
Siemens S7-1200 Web Server Tutorial – From Getting Started to HTML5 User Defined Pages https://www.dmcinfo.com/blog/28315/siemens-s7-1200-web-server-tutorial-from-getting-started-to-html5-user-defined-pages/ Wed, 03 Jul 2013 13:17:22 +0000 https://www.dmcinfo.com/blog/28315/siemens-s7-1200-web-server-tutorial-from-getting-started-to-html5-user-defined-pages/ This is a brief tutorial on getting started with the Siemens embedded web server in the S7-1200 and S7-1500.  Using the concepts explained below, you can create a simple web page or a fully featured HTML5 web app.  Getting Started Step 1:  Turn on the web server.  To do this, navigate to the web server […]

The post Siemens S7-1200 Web Server Tutorial – From Getting Started to HTML5 User Defined Pages appeared first on DMC, Inc..

]]>
This is a brief tutorial on getting started with the Siemens embedded web server in the S7-1200 and S7-1500.  Using the concepts explained below, you can create a simple web page or a fully featured HTML5 web app. 


Getting Started

Step 1:  Turn on the web server.  To do this, navigate to the web server menu in the device configuration page and check the box to enable the web server.

Step 2: Download your project to your PLC and browse to its IP address using your web browser.  You will see the default Siemens PLC Web server.

You can view the Diagnostic Buffer.  This is really helpful.

 The variable status page allows you to view and modify PLC tags.  This is great for debugging, but be careful.  You will be directly editing PLC values!

If your PLC is configured to save data logs, you can easily download the log files from the Data Logs page and open them in Excel.

The default website is perfect for troubleshooting and looks great on a tablet.

 


User Pages

Before enabling User-defined pages in the PLC, we need to create an HTML file for our user page.  Create a text file called “index.htm” and save it to a folder on your computer (i.e. “C:\UserPages”).

 

The file contents should look like this:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>My Title</title>
    </head>
    <body>
    Hello World
    </body>
</html>

Now we can enable the user pages and use this file we created. To enable user pages, navigate to the device configuration -> Web server -> User-defined Web pages.  Set the HTML Directory to the folder you created and the Default HTML page to the file you created.  Then click Generate Blocks to compile the user page: 

You will notice that the “Generate Blocks” function creates two new data blocks in your project, and you may be wondering what these are for.  

 


Fragments

Fragments are the name given to each file in your user pages folder. Initially, we just created a single “index.htm” file, but let’s suppose you had several files in this folder.  It would look something like this:

When you click the “Generate Blocks” button, the compiler takes all of these files and copies each byte into an array in the element of the Fragment data blocks.  The first Fragment DB starts at DB334. An array is dimensioned for each file.

Below you can see how each byte from the file is packed into the array:

As you add more files to your folder, you may exceed the maximum number of bytes that can be contained in a data block, when this happens, another sequential data block is created. You can include HTML files, JavaScript, CSS Files, and even image files.  They will all get converted into data block fragments:

 


WWW Function

In order for user pages to work, you have to call the WWW Function in your project.  Recall the DBs created by the “Generate Blocks” function. We already know that DB334 stores the fragments.  DB333 is used in conjunction with the WWW Function to control the retrieval and delivery of the fragments:

Insert the WWW Function into your code.  Compile and download your project.

This function process requests from the browser and synchronizes the data in the User Pages.  It handles retrieving the correct fragment from the Fragment data blocks as shown below:

If you browse to the IP Address of your PLC, you will see the main Siemens Web server login page.  There is a link on the left for User Pages.  The name in the hyperlink matches the Application name you specified in the User-defined Pages config screen in TIA Portal:

If you click this link, you will see your Hello World page: 

The format of the User-defined web page URL is as follows. I’m not sure what “awp” means, but it is a required part of the URL:


Reading PLC Data

In order to read PLC data we need to modify our file to include a special reference to the tag we are trying to read.  First create a data block called “webdata” and add define an integer variable called “counter.”  In your PLC, add some code to make this increment around every second:

Download your project and then go online with the PLC to verify that the value is incrementing:

Now modify your “index.htm” as follows:

<!DOCTYPE html>
  <html>     
    <head>
      <meta charset="utf-8">
      <title>My Title</title>
    </head>
  <body>
     :="webdata".counter:
  </body>
</html>

 

Notice the tag name is prefixed with “:=” and suffixed with “:”  This is the key to injecting variables into the user page. When the page is rendered it will replace the token with the actual PLC tag value.

 

Next, click the “Generate Blocks” button in the Webserver config and download the program to the PLC.  When you browse to the user page, you will see the counter value update when the page is refreshed.  Notice how the page flickers when refreshed.  This can be annoying if you are trying to make your web page look and feel like a traditional HMI.

Below is an example of how annoying these page refreshes can be.  If you have an image on your page it will flicker as the page is refreshed.  In the example below, the page is automatically refreshed by adding a specific meta-tag to the HTML header.

 

<head>
    <meta charset="utf-8">
    <meta http-equiv="refresh" content="1" >   <!-- meta tag refreshes page every second -->
    <title>DMC Demo - Auto Refresh</title>
</head>

 


Reading Data Using Javascript

To avoid the annoying page flickering, we need to employ some JavaScript to read the data and refresh the screen in the background.  

To demonstrate this, the first step is to move the PLC tags from our main page to a new page.  The new page will not contain any HTML, it will just be a simple HTML file with a single tag reference.  Create a new file and name it something like “IOCounter.htm” (I am prefixing the name with “IO” to remind myself that this file is used for data Input and Output).  The contents of your original “index.htm” should be modified as shown below.  Notice that we moved the tag reference :=”webdata”.counter: to a new file called “IOCounter.htm” and replaced it with a label with the id=”counter.”  We also included the popular JavaScript library JQuery.  You will need to download JQuery and copy it to your “UserFiles” directory.  My “UserFiles” directory looks like this:

 

IOCounter.htm

:="webdata".counter:

Index.htm:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Javascript Example</title>
    <script src="jquery-2.0.2.min.js"></script>
    </head>
    <body>
      <label id="counter">0</label>
    </body>
   
    <script type="text/javascript">
        $(document).ready(function(){
            $.ajaxSetup({ cache: false });
        setInterval(function() {
            $.get("IOCounter.htm", function(result){
                $('#counter').text(result.trim());
            });
        },1000);
        });
    </script>
 
</html>

The JavaScript function above retrieves the current tag value by requesting the contents of the file “IOCounter.htm” and then using this value to set the text of the Label with id=”counter.”  This code runs automatically every second using the JavaScript setInterval function.  The process is illustrated below:

In the simple example above, we placed a single tag value in the file “IOCounter.htm”.  A more advanced option would be to put several tags in this file and format the text into a JSON structure.  This would allow you to update several tags on the screen using just one external data file.  Be careful though, as you add more tags to an HTML page, the page loading time increases. 

 


Modifying PLC Tags From the Browser

A user web page would not be very helpful without allowing the user to modify PLC values. The following HTML page illustrates the simplest way of editing PLC tag values.  The special comment field (AWP_In_Variable) at the top tells the PLC which tags are allowed to be modified.  You will not be able to edit the tag values unless you include this comment for each tag.

First create a new variable in the “webdata” DB:

Then modify “index.htm” as follows:

<!-- AWP_In_Variable Name='"webdata".myInt' -->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>My Title</title>
    </head>
    <body>
     :="webdata".myInt:
     <form method="post">
       <input name='"webdata".myInt' type="text" />
       <button type="submit">Save</button>
     </form>
   </body>
</html>

The PLC will not allow you to modify values unless you are logged in.  Make sure to log in before navigating to the editor page you just created.  The default user name is admin and the default password is blank so you can leave that field empty.

After you have logged-in, browse to the page and go online with the PLC.  You should be able to edit the tag value using the web page you just created.  Notice how the page flickers when the save button is pressed. This is because a post-back is occurring and the page gets refreshed.

 

In order to update PLC tags without experiencing the post-back, we can use some more JavaScript to update the value in the background.  First, we need to create another HTML file and move our tag reference to it.

In order to illustrate this, create a new variable in the “webdata” DB called triangleWave.  Then write some code to make this value count up to 100 and then back down to -100, or whatever logic you like.  Next create a new file called “IOtriangleWave.htm” that looks like this:

“IOtriangleWave.htm”

<!-- AWP_In_Variable Name='"webdata".triangleWave' -->:="webdata".triangleWave:

The comment field tells the PLC that the triangleWave variable is editable and the :="webdata".triangleWave:  allows us to query the current value of the variable by requesting the contents of "IOtriangleWave.htm".

Now modify “index.htm” as follows:

<!-- AWP_In_Variable Name='"webdata".triangleWave' -->
 
<!DOCTYPE html>
<html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Javascript Example</title>
      <script src="jquery-2.0.2.min.js"></script>
    </head>
    <body>
      <!--This label value is being updated in the background using JavaScript-->
      <label id="triangleWave" name="triangleWave">:="webdata".triangleWave:</label>
      </br>
      <input id='setvar' type="text" />
      <!--This button modifies the value in the background using JavaScript without a postback-->
      <button>Modify</button>
     <p><img src="logo-DMC.png" alt="DMC Logo"><p/>
    </body>
 
    <script type="text/javascript">
    $(document).ready(function(){
        //query the trianglewave variable every second
        $.ajaxSetup({ cache: false });
        setInterval(function() {
            $.get("IOtriangleWave.htm", function(result){
                $('#triangleWave').text(result);
                });
        },1000);
         
        //modify the triangleWave value
                $("button").click(function(){
                    url="IOtriangleWave.htm";
                    name='"webdata".triangleWave';
                    val=$('input[id=setvar]').val();
                    sdata=escape(name)+'='+val;
                    $.post(url,sdata,function(result){});
                });
 
    });
    </script>
 
</html>

 

We also added an image to the file to show that the data is being read and written without any flickering or page refreshes:


Server Side Logic – String Variables

Full-featured web servers have powerful server-side engines that can dynamically generate HTML pages. The Siemens PLC has a small embedded server, but there are still a few server-side things that can be done.

Up to this point, we have been experimenting with integer tag values. If you embed a string tag into your page and include some HTML formatting in the string value, it will render as HTML.  Notice below that the string value is not displaying the exact values typed, but rather rendering as HTML:

 

Below are the HTML values that were assigned to the string tag above:

<font size="30" color="green">GREEN </font>
 
<font size="40" color="red">RED </font>
 
<ol>
  <li>Message 1</li>
  <li>Message 2</li>
  <li>Message 3</li>
</ol>
 
<ol>
  <li><font color="blue">Information</font></li>
  <li><font color="orange">Warning</font></li>
  <li><font color="red">Error</font></li>
</ol>

Server Side Logic – Delayed Delivery

Another technique that is very powerful for performing server-side logic is Delayed Delivery.  This is a technique that uses the WWW Function (in conjunction with DB333) to make the web-server wait before returning a requested page to the user. This allows the PLC to ensure that tag values are properly updated before being rendered on the web page.  A typical example would be a recipe editor web page.  The user selects a recipe from a dropdown box (which will cause a post-back and a page refresh).  We must ensure that the new recipe values have been loaded into the PLC tags before refreshing the page.  Normally the compiler automatically assigns a fragment number for each user-generated file.  In order to control the delivery of pages (i.e. fragments), we must specify a fragment number in the HTML file as shown below: 

<!-- AWP_Start_Fragment Name="Control" Type="manual" ID="2" -->

Adding this special comment to the top of your HTML file tells the compiler to use fragment #2 for this file.  You can specify the fragment number by setting the ID field to the desired number. 

Now that we know our file will be fragment #2, we can control the delivery of the page to the browser.  Below is a typical rung of ladder logic for implementing the delayed delivery of the page.  In my example, the “continue” bit does not become true until the recipe loading is complete.  In my case, the loading of a recipe required several PLC scans, so I needed to delay the page delivery until the recipe was loaded.  Note that the PLC can support several simultaneous connections.  If your application will support several simultaneous browser connections, you will have to replicate the code below for each index of the arrays shown.  Currently only index 1 is handled in the code below.  

Below is an example showing the recipe loading screen.  The user selects a recipe from the drop-down which causes a PLC tag to be changed and the browser waits for a post-back from the web server. The PLC detects this change and starts loading the recipe (which takes several PLC scans).  The web-server waits for the continue bit to be set before returning the page (fragment) is delayed until the recipe is loaded.  This ensures that the tag values injected into the HTML page will be updated with the correct values before being sent to the browser.  Below is a demonstration of this in action:

 


Conclusion

Knowing the basics and a few advanced tricks will enable you to create fully featured web pages served from a Siemens PLC. If you are comfortable with JavaScript, you can do some pretty amazing things and make a web page that looks and feels as good as a traditional HMI.   Below is a simple example showing graphing, gauges, user input, and pop-up alerts. This looks and feels like a native app when running on my iPad or Android tablet. Click on the image below to see it in action.  Happy coding!

 

EDIT: Below is a simple example of how to use the gauges shown in the demo above.  The gauge JavaScript library is from HTTP://justgage.com. The example below references the IOTriangleWave.htm that we created above. 

 

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>DMC Gage Demo</title>
    <script src="js/jquery-2.0.2.min.js"></script>
    <script src="js/raphael.2.1.0.min.js"></script>
    <script src="js/justgage.1.0.1.min.js"></script>
</head>
 
<body>
<div id="g1"></div>
<div id="g2"></div>
     
<script type="text/javascript">
    $(document).ready(function(){
        var g1, g2;
        var g1 = new JustGage({
          id: "g1",
          value: getRandomInt(-100, 100),
          min: -100,
          max: 100,
          title: "Triangle Wave",
          label: "Value"
        });
         
        var g2 = new JustGage({
          id: "g2",
          value: getRandomInt(0, 100),
          min: 0,
          max: 100,
          title: "random data",
          label: ""
        });
 
        $.ajaxSetup({ cache: false });
            setInterval(function() {
                g2.refresh(getRandomInt(50, 100));
                $.get("IOtriangleWave.htm", function(result){
                    g1.refresh(parseInt(result));
                    g2.refresh(getRandomInt(50, 100));
                });
            },1500);
    });
</script>
 
</body>
</html>
 

 

 

Also, here is a link to a zip file of the project examples. Enjoy!

Learn more about DMC’s Siemens S7 PLC programming expertise. Contact us to get started on your next PLC programming project.

The post Siemens S7-1200 Web Server Tutorial – From Getting Started to HTML5 User Defined Pages appeared first on DMC, Inc..

]]> Farewell Kingsbury https://www.dmcinfo.com/blog/29544/farewell-kingsbury/ Sun, 01 May 2011 13:02:04 +0000 https://www.dmcinfo.com/blog/29544/farewell-kingsbury/ This past Friday (April 29th), we started and……several hours later….finished our move from 1333 Kingsbury to 2222 Elston. It was pretty crazy as we (and a team of movers) dismantled the place and hauled everything to the new building. I took a video of the aftermath. Even though the place looks totally trashed, It was […]

The post Farewell Kingsbury appeared first on DMC, Inc..

]]>
This past Friday (April 29th), we started and……several hours later….finished our move from 1333 Kingsbury to 2222 Elston. It was pretty crazy as we (and a team of movers) dismantled the place and hauled everything to the new building. I took a video of the aftermath. Even though the place looks totally trashed, It was a really good space for DMC over the past 7 years. Kingsbury was definitely the Millennium Falcon of offices: “She may not look like much, but she’s got it where it counts..” A lot of really smart, dedicated, and talented people worked some truly amazing projects in there. Farewell 1333.

The post Farewell Kingsbury appeared first on DMC, Inc..

]]>
The DMC vCard & MeCARD QR Code Generator (i.e. Business Cards for Geeks) https://www.dmcinfo.com/blog/29580/the-dmc-vcard-mecard-qr-code-generator-i-e-business-cards-for-geeks/ Tue, 22 Mar 2011 20:32:53 +0000 https://www.dmcinfo.com/blog/29580/the-dmc-vcard-mecard-qr-code-generator-i-e-business-cards-for-geeks/ We are all getting new business cards at DMC, so we thought it would be fun to put QR codes on them to make it easier for our smartphone-enabled customers to scan our info and add us to their contact database. Thanks to Google, it’s pretty easy to make your own QR codes using their […]

The post The DMC vCard & MeCARD QR Code Generator (i.e. Business Cards for Geeks) appeared first on DMC, Inc..

]]>
We are all getting new business cards at DMC, so we thought it would be fun to put QR codes on them to make it easier for our smartphone-enabled customers to scan our info and add us to their contact database.

Thanks to Google, it’s pretty easy to make your own QR codes using their QR chart API. The only issue is that you have to properly format the data before sending it to Google, especially if you want to include all of your contact info in the proper vCard or MeCARD format. A little JavaScript and some googling were all it took to create the tool below. You can use it to create your own QR code business card. Just fill out the info and click the generate button.

Item Value Example
Prefix Mr.
First name John
Middle name T.
Last name Smith
Name suffix PHD
Job Title Project Manager
Organization: DMC Inc.
Division / Department: Engineering
Building / Suite / Suite 101
Street: 1333 N. Kingsbury
City: Chicago
State / Region: IL
Zip Code: 60642
Country: USA
Phone work: 312-255-8757
Fax work: 312-255-8758
Phone mobile: 312-255-8757
Email info@dmcinfo.com
Website URL: dmcinfo.com

Clicking this will populate the box below with properly formatted vCard text from the input boxes above.

Clicking this will populate the box below with properly formatted MeCARD text from the input boxes above.

Click on the Generate vCard or MeCARD button above, or just type whatever you like into the text area below. You don’t have to create a vCard. The QR code will be generated for whatever text is typed into the box below. If you want to create a QR code for a website address (like: http://www.google.com ), just type it in below and click the Generate QR Code button. Feel free to experiment with different sizes and error correction levels.

Error Correction Level

Image Pixel Size (width x height)

This uses Google’s QR chart API to generate the QR codes. The vCard generator is all done on the client side in your browser using JavaScript, in case you were wondering if we were logging your information. We are definitely not. I’m not sure about Google, though. Since the QR codes are created using a Google chart function, the data gets sent to Google and returns as an image of a QR code. I suppose they are storing the data, but let’s face it, they probably already have your info anyway.

If you want to test your newly created QR code, you can right-click on the image that was generated above and copy the image URL to the clipboard, and then go to this page: http://zxing.org/w/decode.jspx and paste it into their online QR Code reader. It will show you the raw and parsed text encoded in the QR code image.

Enjoy!

Learn more about DMC’s company culture.

The post The DMC vCard & MeCARD QR Code Generator (i.e. Business Cards for Geeks) appeared first on DMC, Inc..

]]>