Supercharge Embedded Development with 3 AI/ML Techniques

Embedded developers are working through a time in history where how embedded products will dramatically change in just a few short years. To date, embedded products have been designed, implemented, and tested by hand. Sure, the occasional tool and technology has allowed for some of this to be automated, but even then, it requires substantial human interaction to be successful.

While still in their infancy, artificial intelligence and machine learning technologies enable a revolution that is already changing how embedded software is developed. Complex coding activities that once took weeks or months to implement can be completed in hours with the right AI/ML tools. However, it’s easy to think that AI/ML is just hype and won’t impact how embedded systems will be designed and built. To help you along, here are three AI/ML techniques and technologies that I have found to help boost my productivity.

Technique #1 – Leveraging AI to generate code

Have you ever used a tool that automagically generates code for you? I have. They are often notoriously horrible. They are illegible; only God knows if a bug is hidden in the code. Your first instinct when hearing that you can use AI to generate code is undoubtedly along the lines of “Great! Can we really trust the machine to generate our code?”. I know that was my response. In fact, I jumped into an AI tool and tried to get it to generate some code for me. I immediately said, “Aha! I knew it would generate junk code!” However, it turned out that I was inexperienced in working with AI. I gave it junk input, which generated junk output for me (honestly, the junk was a little impressive).

There are a few simple tips that you can follow to help improve your output results:

  • Be specific. Don’t generically ask for something or tell it to generate something. For example, if you want the generated code to be limited to 80 characters, tell it!
  • Use examples that give the AI context to get better results. You can give an example and tell it to match the style and formatting.
  • Use a tool that removes the need to access a prompt and will allow you to fine-tune your needs through an interface. (I’ve seen some cool tools in progress).
  • Use a tool like Co-pilot that will suggest code as you write it

These tools are just in the early stages, but I’ve seen some intriguing results that can help developers move faster!

Technique #2 – Leverage AI to write better code

One test I’ve been playing with the various AI tools is to give them code I’ve written and ask for suggestions to improve the code. I’ll write code I know is incorrect and test it to see if it can improve and spot the issues. So far, I’ve found that AI engines often have good suggestions on improving interfaces, code, and makefiles and even solving some programming problems. Don’t get me wrong, these tools and experiments have not produced 100% successful results. I often will get some feedback from the AI that makes me laugh and say no! However, there are a surprising number of times when I would say no, but it sparks ideas in my mind that I then use to make a code improvement.

The AI tools available today won’t give you 100% correct results, but you can use them to get ideas and improve your code. In fact, I’ve started to look at AI as a type of pair programming between humans and machines. The pair programming has several levels that a developer can use:

  • The Human says what it wants, the machine generates the code, human tweaks and adjusts
  • Human generates code, machine reviews and states what it does while offering improvements, human tweaks and adjusts

Pair programming can be expensive when you sit two developers down, even though the overall costs are probably not as bad as developer times two. However, management can sometimes overlook this fact. When you have a human and a machine, the cost differential is much larger, so it becomes a new practical way to get feedback and make improvements.

Note: You probably don’t want to put secret sauce or proprietary code into a public AI tool because someone may review and take your code.

Technique #3 – Use Machine Learning tools for on-target inferencing

There have been times when I was working with a customer on a project, and we spent weeks or months analyzing sensor data and crafting an algorithm that would successfully get the desired result. In the end, they worked great. However, had machine learning technologies been available, we could have solved the problem that took us weeks or months in a matter of hours to days. While this seems unrealistic, I did go back for fun to a decades-old project and found using machine learning tools; I could train and deploy a model in a day and a half that worked as well or better than the original algorithm.

There are many use cases for machine learning on-target. For example, you’ve probably seen that keyword spotting and object detection. These are two highly visible use cases for running machine learning inferences on-target. However, there is a nearly unlimited number of use cases. For example, I’ve used machine learning for applications such as gesture recognition, predictive maintenance, etc.


AI and ML techniques and tools are just coming to fruition. In the next few years, we’ll see a lot of churn as companies and teams sort through what works and what doesn’t. However, I know that the teams working with AI/ML sooner will have a leg up on their competition. While some techniques may not currently work for a production system, you can still learn the techniques and find ways to improve your processes and code. In addition, I suspect you’ll find that as the tools fully mature, you’ll better understand the underlying technology.

If you want to learn more about AI/ML in embedded systems and how these techniques apply, register for the free DesignNews  CEC course “Machine Learning in Microcontrollers,” June 26 – 30th.

Share >

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.