Recently this was posted in a C for Embedded programming Linkedin group.
Attention C programmers!
Here’s a quick trick that can make your code more efficient and save you time. Did you know that you can use the ternary operator to simplify if-else statements?
For example, instead of writing:
if(x > 0){
y = 1;
}
else{
y = 0;
}
You can simplify it to:
y = (x > 0) ? 1 : 0;
This is particularly useful when you have multiple if-else statements within a loop. By using the ternary operator, you can make your code more readable and reduce the number of lines, leading to improved performance.
Give it a try and let me know what you think!
Before you get all enthusiastic about this it is important to note that it is unlikely that the compiler will produce different or better machine executable code in the suggested case. It is really worth every software engineer spending time looking at the assembly code to see how little effect code shortcuts have. And this ternary construct is not allowed in some code standards. This paragraph was what I posted to the discussion.
The linkedin thread continued.
One person commented
“A neat trick, although I doubt that better performance would be a benefit. One should beware of premature optimization and overusing this technique. Code readability is king!”
Another added
“In my opinion, the use of ternary operator is often used and abused in places where it actually makes the code less readable. Some coding rules actually prohibit the use of the ternary operator altogether.”
One other person said politely
“sorry to give you this information, but even without any optimization the compiler will produce the same assembly, you can try by yourself using one of the different tools online such as https://godbolt.org/.”
It looks like godbolt.org might be a fun tool to allow software people to look at assembler for different compilers.
It is always good to look at the compiled output assembler code. It shows you what you have actually done.
I was traveling before Christmas to get to a couple of meetings. A software guy in one of the meetings had to step out because there was a pressing issue with a serial communications system. He was back in about 20 minutes because he had “fixed it”. Turns out an IDE/Compiler/ToolChain code library had been updated automatically and this had broken the serial comms.
So how are you controlling how you version the toolchain libraries? Do you version the toolchain?
Do you just roll the automatic updates in? Do you do anything? #software #communications #versioncontrol
How do you version control the code tools for high quality software?
One option to control the version of toolchain libraries is to freeze the version used in a project by specifying a specific version number in the project’s build system. This can prevent unexpected changes and breakage caused by automatic updates. Another option is to have a dedicated team responsible for testing and controlling updates to the toolchain libraries, and only roll out updates that have been thoroughly tested and deemed stable. Additionally, organizations could also consider setting up their own internal repository for the toolchain libraries, with version control and a process for testing and releasing updates.
Having clear control and visibility into the toolchain libraries used in a project can greatly increase the stability and reliability of the system. It can also minimize downtime and improve the efficiency of debugging and fixing issues. Overall, having a well-defined version control strategy for the toolchain libraries can lead to a better software development process and improved product quality.
More often than not the silicon vendor-provided code is not available in a repository but comes as some self-installing executable. that checks for updates and installs said updates them without telling you what they are, This is such a problematic low-quality approach. So it was so cool to see this SDK from NXP that is delivered in it’s GitHub repo. Such a good way to do it. Well done NXP.
The link to the SDK information is https://spsdk.readthedocs.io/en/latest/spsdk.html#delivery
The GitHub link is https://github.com/nxp-mcuxpresso/spsdk.
Truly well done to NXP and whoever was in charge of setting this up.
Hopefully the other vendors will take the same approach.
We are super pleased that we just got news in an e-mail from the AMD Xilinx Partner Program that we have been accepted back into the Partner Program for another year until March 31 2024.
This means that our customers get the best of AMD Xilinx product and development tools to solve their challenges. ELMG Digital Power is unique among Xilinx Partners as we focus on using Xilinx FPGA, SoC and tools to control power electronics converters.
Our first experience with Xilinx FPGA in power electronics control was even before ELMG Digital Power started in 2001. Back in 1997 we used an Xilinx part to add high speed capability to a Ti DSP and implemented the ADC control, PWM and three phase hysteretic current control for a shunt active filter.
ELMG Digital Power CTO recalls. “The expensive 1997 part was in a quad flat pack (QFP) package. It worked really well. I remember having to deal with simultaneous pin transitions causing ground bounce by skewing the edges. All of this is now standard in Xiinx FPGA fabric. We stopped using FPGA for some time as they did not meet our price point but when the reducing price of FPGAs allowed us to move into using them we were really pleased to see how fantastic the Xilinx Spartan 3 and Spartan 6 were. The continued Xilinx development and great support has meant that we are always pleased to use them.”
So even though we stopped using FPGA for a while due to their cost, we were pleased to return to using Xilinx FPGA when their prices became more affordable. The continued development and great support provided by Xilinx have made it a pleasure to use their products, including the Spartan 3, Spartan 6 FPGAs, Zynq 7000 System on Chip (SoC) and 7 series FPGA.
We have taken our expertise in FPGA power electronics and embodied it into our Power Core IP library, which we use to solve our customers’ power control challenges. Our renewed membership in the Xilinx Partner Program will allow us to stay up-to-date on the latest Xilinx products and technologies, and better serve our customers.
As a member of the Xilinx Partner Program, we have access to a wide range of resources and benefits that will help us to continue providing our customers with the best possible solutions for their power control needs. These resources include access to the latest Xilinx technologies and tools, as well as training and technical support from Xilinx experts.
We are also excited to be able to take advantage of the marketing resources provided by the Xilinx Partner Program. These resources will allow us to promote our expertise in using Xilinx FPGA, SoC and tools to control power electronics converters to a wider audience and attract new customers.
Overall, our renewed membership in the Xilinx Partner Program is a great opportunity for us to continue providing our customers with the best possible solutions for their power control needs and to grow our business. We look forward to working closely with Xilinx in the coming years to develop innovative and effective power control solutions.Regenerate response
AMD Xilinx is a leading provider of programmable logic devices (PLDs), including field-programmable gate arrays (FPGAs) and system-on-a-chip (SoC) devices. The company’s products are used in a wide range of applications, including aerospace and defense, automotive, broadcast and pro-AV, data center and enterprise, industrial, and wireless communications.
Xilinx’s FPGAs and SoCs are known for their high performance, low power consumption, and flexibility. They can be programmed to perform a wide range of functions, from simple logic gates to complex digital signal processing (DSP) algorithms. This flexibility allows customers to adapt their systems to changing requirements and to reduce their time-to-market.
Xilinx’s FPGA and SoC products are supported by a comprehensive suite of development tools and software, including the Xilinx Vivado Design Suite and the Xilinx SDK. These tools and software allow customers to design, implement, and debug their systems quickly and easily. Additionally, Xilinx’s partner ecosystem provides access to a wide range of IP cores, reference designs, and other resources to support customers’ design needs.
Xilinx also offers a wide range of support and training resources, including online resources, technical support, and training courses. This support and training helps customers to quickly get up to speed with Xilinx’s products and technologies and to develop their designs efficiently.
All of these features and resources make Xilinx a popular choice among engineers and designers in a wide range of industries, and ELMG Digital Power is proud to be a member of the Xilinx Partner Program, which helps to provide our customers with the best possible solutions for their power control needs.
ELMG Digital Power is a company that uniquely specializes in using Xilinx FPGA, SoC and tools to control power electronics converters. Founded in 2001, the company has a long history of experience in this field, dating back to 1997 when they first used a Xilinx part to add high-speed capability to a Ti DSP.
The company’s expertise in using FPGA’s for power electronics control is embodied in their Power Core IP library, which they use to solve their customers’ power control challenges. With this library, they are able to offer a wide range of solutions for various power electronics applications, such as motor control, renewable energy, and electric vehicles.
The company’s team of experienced engineers and designers are dedicated to providing their customers with the best possible solutions for their power control needs. They work closely with their customers to understand their unique requirements and to develop custom solutions that meet their specific needs.
ELMG Digital Power is committed to staying at the forefront of power control technology and is a proud member of the Xilinx Partner Program. This membership gives the company access to the latest Xilinx technologies and tools, as well as training and technical support from Xilinx experts.
Overall, ELMG Digital Power is dedicated to providing their customers with the best possible solutions for their power control needs and are proud to be a member of the Xilinx Partner Program.
ELMG Digital Power CTO Dr. Hamish Laird has completed ELMG Digital Power AMD Xilinx Alliance partner technical recertification. AMD-Xilinx Partner technical recertification for ELMG Digital Power’s ongoing membership in the AMD-Xilinx partner program. Congratulations to Dr. Laird on the achievement.
The three-way commitment to capability building, continuous learning, and keeping up-to-date with Xilinx technology is an investment that enables our customers’ success. Using Xilinx-AMD FPGA and SoCs with ELMG Digital Power’s FPGA RTL library is a truly cutting-edge solution for digitally controlled power electronic systems.
This re-certification covered the PCI express system on the Versal ACAP.
As Dr. Laird says “This Versal ACAP is an extended SoC device that is powerful to the point of being daunting. Having a PCIe subsystem on the Versal chip is truly impressive. Initially, I was suspicious of the suitability of the super powerful ACAP as a device for power control but I can now see how this device is suitable for almost every application we could ever consider.”
This power control component library is designed for use with Field-Programmable Gate Arrays (FPGAs) and Register-Transfer Level (RTL) designs. This includes grid-connected embedded power generation and storage, high-performance computing, telecommunications power, traction, and industrial automation and control. ELMG Digital Power’s high-performance digital power controllers make use of the FPGA RTL components. This allows robust, reliable, and reusable power electronics control systems. The component library use with Xilinx AMD parts is the main reason for ELMG Digital Power AMD Xilinx Alliance partner technical recertification
Xilinx is now part of AMD. AMD now has the industry’s broadest product portfolio and a highly complementary set of technologies, reaching customers in a diverse set of markets. Together, AMD and Xilinx leverage the right engine for the right workload to address the compute needs for our customers.
ELMG Digital Power’s Mission is to provide technology, know-how, and products for our customers to control, manipulate and measure electrical power. We aim to design and build the best digital controlled power electronic systems and by doing that we believe we can together change the world for the better.
The thorn in the side of the supercapacitor is its limited lifetime.
Supercapacitors can do many things in the field of energy storage and have be touted as being the future batteries.
However any supercapacitor if not lifetime-engineered properly can fail prematurely. This leaves your company with potentially large warranty costs.
Supercapacitor lifetime stems from chemical reactions in the capacitor causing the capacitance to decrease. These reactions happen more often when it is hotter and thus lifetime can vary significantally with temperature. These reactions are governed by the Arhennius equation and appear on the datasheet as a lifetime. A typical lifetime for a supercapacitor is 1000 hours at 70C. This means that if your supercapacitor is at 70C it burns through a lifetime in 42 days! At only 83C some electrolytes can even boil causing your supercapacitor to rupture! However, if the temperature is decreased a supercapacitor’s lifetime can be increased greatly. It is all governed by this equation:
where t is lifetime, Tn is the nominal temperature, tn is the lifetime at the nominal temperature, Ea is the activation energy, T is temperature and kB is Boltzmann’s constant. In most cases this can be approximated by “halving the temperature doubles the lifetime”. If you are not using this equation in designing your supercapacitor systems then you better start using it fast! Note that this equation is for any electrolytic capacitor not just supercapacitors.
From the prior equation it can be seen that managing the temperature of supercapacitors can do wonders in increasing their lifetime. It is a lesser known fact that running them at voltages below the rated voltage also increases their lifetime.
Once you have your product in the field, re-engineering can become costly, so verification of your design and predicting failure rates becomes very important. This is done by measurement of the capacitors and then statistically analysing the results.
Measurement of supercapacitors relies on the use of a simple capacitor model with just capacitance and ESR. This allows measurement by using the fact that the voltage response to a constant current source is a straight line. From this straight line you can thus measure the capacitance. When a constant current is applied there is also a small offset due to the ESR, which can be used to measure the ESR.
Once you made the measurements of a random group of supercapacitors you can begin to analyse the results. First of all you calculate the lifetimes that the supercapacitors have experienced up to the measurements based on their capacitance. Then these lifetime results typically fit a Weibull distribution. Using this fact, you can curve-fit your sampled data to a distribution with certain parameters and calculate the confidence of your fit. You now have a range of distributions that fit your data. From this range you simply find the worst case and use it to predict worst-case future failure rates. This information can be passed on to the accountant in the form of warranty liability.
ELMG Ltd have designed a system which can use this measurement technique to measure supercapacitor’s capacitance during both charging and discharging. This is done using a controlled constant current source. This system is highly scalable meaning that it can be used on capacitors ranging from a few farads to hundreds of farads. Once the measurements are made ELMG can then perform the statistical analysis and come up the results to tell your finance people what you warranty liability is.
ELMG Digital Power is an AMD-Xilinx Partner. As part of this we keep up to date with Xilinx parts, tools and technology with training. Consequently ELMG can provide the best digital control solutions for digital power electronics.
We started digital control of power electronics with Xilinx in 1997 so as a result ELMG Digital Power’s long history with Xilinx means that we have exceptional experience and expertise.
ELMG Digital Power for Digital Power Electronics Control expertise.