Python for Electrical Engineers

3 minute read

As an Electrical Engineer, there are so many uses for Python. I like to think of Python as the go to tool for what is essentially the Electrical Engineering equivalent of DevOps. Here are a few ways Python can help Electrical Engineers.

Device Interfacing

Serial interfaces (RS-232, MODBUS), CAN buses and others can be so much easier to get up and going compared to writing something in native C/C++ for the specific operating system you are using. Network interfacing is also very easy to use if you need to open up a socket and talk to a device over a network.

Programming Bench Tools

Programmable tools like power supplies, DMMs, O-Scopes, Function Generators, and others are dead simple to get up and running for various setups. There are already a ton of libraries out there provided either open-source or by the vendors themselves to allow you to automate the data capture or device configurations allowing you to do some really neat things such as…

Automated Testing

It is so much cheaper and faster to automate testing with Python than something expensive and inflexible like Labview or ATEasy or so many of the other systems out there. With a simple serial interface to change data on the controller and some programmable test equipment and a creative harness with feedbacks or another sensing device you can do a lot to verify the integrity of your hardware. Most production test system arguably don’t need the in-depth verification levels that you can get with a Labview setup. You can easily get 80-90% of the test coverage for about 5-10% of the cost. Of course if you really need that extra 10%, then that extra cost might be justified.

Embedded Data

The embedded data itself is also something that is often overlooked and requires some serious tools to parse and visualize at millisecond resolution from hundreds or thousands of sources. Some data sampling can easily rival the amount of data generated by “Big Data” companies/apps. Dumping data for quick access into a SQLite database can make data manipulation so easy and opens up so many possibilities for what you can pull from your data captures. If you want to get really ambitious you could send that data up to a Time Series Database (TSDB). There are tons of them out there now and they can be a very useful tool in analyzing and visualizing large sets of real-time data.

Analytics

Libraries like SciPy, Numpy, Pandas and other are very useful when you need crunch on large data sets and pull information out of them. You can look to the Big Data world for more details on this, but Python has certainly carved out it’s place in the world of data science.

Visualization

Matplotlib works great for quick static plots of moderate data and go along nicely with the analytics tools. PyQtGraph works great for high resolution or real-time plotting. Or you can use tools that DevOps tend use like Grafana and others if you want to get a time-series database up and running.

Day to Day tasks

There are also plenty of other day to day uses for Python such as code generation, automating builds, and pulling data from Excel. Using a Python templating library like Jinja or others makes automating code generation for repetitive or dynamically configured code section very simple. Most engineer’s tool of choice whether you like it or not is Excel, and Python makes it very easy to pull data out of these sheets (although I would like to see something better to put data back, the stuff out there now is rather lacking…). Not every engineer is going to be a programmer, so Excel becomes a very important part of some organization’s workflow even if it isn’t always the most optimal tool. Unless you want to make a better front end, this is how most engineers will be giving you data…

Putting all of this together can give some very powerful potential in the right hands! While there are plenty of other languages that can do some of these things better or faster or maybe easier, I’d challenge someone to find a language that can do all of these things as well as Python.