Back To Basics: Class X & Y Capacitors

I recently had to interact with a client specifically regarding Class X and Class Y capacitors, and I thought it will be a good refresher for the community as well.

These 2 caps are mostly used in the AC circuits. Class X sits across Line and Neutral and helps remove differential mode noise. Class Y connects from Line or Neutral to protective earth, or across the isolation barrier, to drain common mode noise safely. “X” and “Y” names are got from the international capacitor safety standard IEC 60384-14 for capacitors.

An across-the-line failure can cause fire, so X capacitors are built to be self-healing, pass surge and flammability tests. A line-to-earth failure could make exposed metal live and cause electric shock, so Y capacitors must fail open and are limited in capacitance to keep leakage current small.

There are subclasses. X parts are X1 and X2. X2 is the common choice for normal mains surges, X1 is for harsher industrial projects. Y parts are Y1 and Y2. Y2 goes from Line or Neutral to earth in Class I gear. Y1 is used when you bridge reinforced insulation across the isolation barrier. Pick only parts with safety marks like UL on the datasheet and body. Keep Y values small and check leakage current with I ≈ 2πfVC so the total stays within your power budget.

Think about tradeoffs. X caps can be larger and cut more differential noise, but they need discharge parts and space. A bleeder resistor is needed across the X capacitor to make sure you don’t get a shock after unplugging the AC. Typically, in 1-5MΩ range. Y caps keep users safe by failing open and by being small, but they add leakage, so values are limited.

Remember that many Y MLCCs lose capacitance with DC bias so leave margin or pick C0G or film. In humid regions, choose parts that pass 85C and 85% RH tests. Never replace safety capacitors with general purpose parts on the mains(I can’t stress this enough!).

If you liked the post, Share it with your friends!

Back To Basics: MISRA Guidelines

I recently learned about the MISRA guideline and I am digging in. Thought I will share what I learned about it.

MISRA (Motor Industry Software Reliability Association) is a consortium formed in the UK automotive sector to publish best-practice coding guidelines for safety/security-critical software. It publishes coding rules that define a safe subset of the language so code behaves the same on every build and is easier to review and test.

It’s applicable for functional safety systems. Functional safety means a system stays safe even when parts fail. We design software so a single fault does not create danger. In cars, this aligns with ISO 26262. Other domains use similar safety norms.

MISRA helps by cutting out parts of the C or C++ language that are risky. These tricky parts can cause hidden bugs, memory problems, or code that’s hard to understand and test. This is a good fit for embedded systems that run for years. It makes reviews and tests sharper and gives auditors solid evidence.

It contains things for example, things like Use nullptr, not 0 or NULL. Avoid tricky casts like reinterpret_cast. Prefer smart pointers and RAII over new and delete. Do not return a pointer or reference to a local variable. Make destructors noexcept. Keep macros and globals small and controlled etc. Some 200 odd guidelines.

Current state for C++is MISRA C++ 2023 based on C++17 and influenced by AUTOSAR C++14. MISRA C 2025 exists for C. Official guideline is paid and for purchase(but cheap). The process guide MISRA Compliance 2020 is free and explains how to claim compliance, deviations, and reports. Also, AUTOSAR C++14 is free and still worth a read. Search around, you will find links talking about the guidelines in detail if you are tight on budget and not buying.

From what I understood, MISRA is not about creating zero violations. It is more about defining a clear coding process with justified deviations. I think I will start to use this more in firmware development from now on.

If you liked the post, Share it with your friends!
1 12 13 14 15 16 134