There have been a few main themes this week:
- Battery Management System, programming and cables
- Inverter Faults
- Inverter Programming Cable
- Inverter Programming
- Test Runner Script
Battery Management System

A quick recap:
I’d been running my test bench with a desktop power supply unit (PSU), which made it easy to set voltages and current limits, and to turn the supply off when I wasn’t using it.
But my PSU didn’t have enough oomph! It was current limited.
So I needed to bite the bullet and connect up at least one of the VW MEB ID3 battery modules that I bought last year.
Each module delivers about 44V and stores 6.8kWh of energy. They can also deliver over 600A of current – that’s a lot!
But what does that mean… well… 6.8kWh of energy would recharge a phone hundreds of times! That’s a lot!
The critical thing here though, is the current. I don’t need anywhere near 600A (10 would do) but that’s more than the 3A my PSU could deliver.
So with all that energy in a module I need to be really careful with them. I have the modules in my office sat on a trolley – which will allow me to yank them out of the office if they show even a sniff of over-temperature.
And that being careful also requires you to know whether you do actually have a temperature problem in the first place. It would also be nice to know what level of charge the modules had, also known as their State of Charge (SoC) and their State of Health (You guessed it.. SoH).
Which means I really needed to get the Battery Management System (BMS) that I bought with the batteries, up and running.
I’d tested the batteries and BMS when I first got them, but never connected them to my bench power train, and had not integrated the BMS into the Vehicle Control Unit (VCU) software.
And that was where this week’s work really sat. I needed to get the software written that would talk to the BMS and check everything is ok.
My VCU code is complicated now, and that brought a diversion…
Flash and RAM Diversion
I was running out of Flash and RAM.
These AI coding agents are really cool. But they can be a bit verbose. Both in terms of lines of code they write and in terms of the RAM they need to store the variables for all the calculations.
My VCU code is rather fully featured. It keeps track of all the data it sucks out of the power train (voltages, currents, RPM, temperatures etc etc), but it also tracks when that data got sucked (timestamps) and also whether it was valid (within range etc). The timestamps then get used to assess whether each data item is fresh—i.e. it’s not too old.
Then, once the data, freshness and validity are known, the VCU can decide what to do next. It does some of that using what are called “permissions”—the conditions that must be met before the car is allowed to drive or charge.
I mention this because one of the key things the BMS does is give permission. It gives permission (at least one of the permissions) for the power train to enter drive mode, but it also gives permission for the vehicle to be charged. You can imagine that if the batteries are too hot then permission to drive might be revoked and/or the permission to charge might also be revoked.
And all this complexity was clogging up the Flash (code storage) and RAM (variable storage).
I’d tried a few times to look at “code-bloat” – asking ChatGPT Codex to look at the code and suggest Flash and RAM savings. But until this week there were only limited savings it was making.
But things had got critical. I didn’t have enough Flash storage left to take the code I needed to run a proper BMS.
But then ChatGPT Astra 6.2 came out. The frontline AI companies are releasing new “models” all the time, some are better than others at one or other task. And Astra 6.2 was getting a bad rap for being too pedantic and detail oriented.
But that was exactly what I needed.
So I spent a couple of days this week working with Astra 6.2 to streamline my code. After doing enough of this embedded software game you get a sense of whether too many lines of code are being spent on certain areas. And also how much CPU time is being spent working on a bit of what the VCU needs to do every second. Both of those seemed high in some areas.
Which turned into a few hours with Codex Astra 6.2, looking at message passing in the system, startup data handling and a bunch of other areas.
Eventually we saved 10% of the Flash being used and 10% of the RAM.
And that was plenty to get the BMS code into the mix. Thank you Astra 6.2.
Back to the BMS
Up until now, the VCU software was working with what Softies know as a Fake-Device… and in this case a fake battery management system. And this Fake-BMS was basically just giving permanent permission for whatever the rest of the vehicle wanted to do.
In the final vehicle the permission would be based on real data, but I hadn’t got there yet for the Fake-BMS.
But now was the time to sort that fake permission out. With a real battery in the system I wanted a real algorithm in place to properly revoke drive and charging permission if the batteries weren’t happy.
I could absolutely have ignored all of this.. I’m taking a very small amount of energy from these batteries, with very little danger of overheating anything, or running out of charge.
But there’s a constant in embedded software… the more miles/hours you can get your code working the more issues you may find, or the more confident you can become that your code is going to do what you want.
So now was a good time to implement the BMS permission software and over the next months it will show its colours and hopefully it’ll be good to go in the final vehicle.
With enough space in the Flash and RAM and a need to get it running, I set Codex off in creating the BMS module.
About an afternoon’s back and forth with me and it was working.
BMS Problems
With the BMS connected to the batteries and plugged into the powertrain, I was ready to try it. I did have to model and 3D print a new shelf for my Contactor Box so it didn’t keep falling off the table.
First the CAD version…

And then the real thing. One printed shelf later, the Contactor Box has somewhere to sit.

But the BMS wasn’t playing ball.
Inside the VW battery modules I’m using, they have 12 x 3.7V cells, in series, and then two sets of those in parallel – known as 12S2P.
The BMS modules I’m using come in banks of 16 voltage connections, or “taps”. I use 12 of those taps to connect across the 12 cells in the battery modules and the BMS reports those voltages to the VCU. It also adds them all up and tells me what the total pack voltage is.
But the BMS wasn’t adding things up properly. It reported 12 good cells, each of 3.7V, but it added them up to 36V, not 44V.
It would occasionally flick to 44V but mainly it was 36V.
And my BMS code I’d got written didn’t like the discrepancy – and rightly so… discrepancies are bad, bad, bad!
But I couldn’t figure out why there was this mismatch.
I sent a few emails to the guys at SecondLifeEVBatteries, where I bought the modules and BMS from. And they were very helpful, but didn’t really fix the problem.
Eventually, the penny dropped.
The BMS is managed by a PC app (Grrr… no Mac app). And in most of the app you change a configuration value that’s then sent straight away to the BMS… whenever you make a change.
But the BMS does something different when setting up the voltage tap modules (EMUS calls them CCGM).
You have to hit a commit button.
And that commit button was hidden off the bottom of my laptop screen. Eventually I realised the settings I was trying to make weren’t being “sticky” across restarts. Which led me to see if there was a save or commit function/button somewhere.
Bingo. There was a commit button scrolled off the bottom of my screen. But that took me three days, on and off, and a bunch of emails that led nowhere.

It’s amazing how often that sort of stuff gets overlooked. Grr!
But my BMS tap and pack voltages now line up… yay!
Here’s what the voltage display looks like now. Much more like it.

BMS working and BMS code working.
BMS to Battery Cable
Oh, and because I didn’t know whether the voltage mismatch was just a cabling problem, I made up a new cable—which takes about two hours.
That was another AI big help this week. When making up these cables, I had the pin connections of the battery connector. And the pin connections of the BMS connector. But they weren’t on the same page and shown in the same way.
In a commercial world we would always make a drawing / diagram of the cable to be made. And you’d use that diagram to make the cable – removing any ambiguity and increasing the chance of being able to make the cable up without any mistakes.
So I got ChatGPT to make me the diagram. Awesome! This diagram would have taken me a couple of hours and I wouldn’t have got half the useful comments added either. This was a big help making the cable.

And I got the cable right first time!

I need to make another 4 of these cables now!
Inverter Faults
In the last posts about the inverter, I think I was saying that I was about ready to make the motor turn.
With the higher current capable battery modules now connected and the BMS permissions all set up, I could try and get the motor to turn.
But it didn’t.
I was trying very small, 1 or 2 Nm torque commands. But nothing was happening.
After a few days of dorking around, I finally realised that as soon as I asked the inverter to enter “TorqueControl” mode—where my VCU maps throttle position to a torque request—it went into a sort of safe shutdown mode (open circuit).
It was also throwing a System Fault.
I played around with this for a few days. I just couldn’t figure out what was causing the System Fault.
There were also a few Derates that were active.
Derates
The idea of a derate is that you can still operate the motor through the inverter but it won’t deliver full power, speed etc.
I thought that perhaps some of the derates were combining to create a system fault….
And so I spent a day or so trying to remove the derates that I could affect – DC Link Voltage, DC Link Current, Temperature etc.
I’d been configuring up the inverter with some very conservative settings – walk before you run. But I’d not set the validity correctly on some settings and not set them high enough on others.
That cleared a few of the derates, but it didn’t fix the system fault.
Which made me think my High Side (HS) DC voltage from my Traction DC to DC converter (TDCDC) was too low.
Here’s the block diagram of the bench with the battery module connected, to put the low and high sides in context.

Again, I was walking (crawling) not running. So I was only setting the HS voltage to 350V. That had cleared some problems in the past, so I’d left it at that level. Higher voltages on the bench would potentially increase risk / danger… So I didn’t want to rush to higher voltages too quickly.
High Side DC Link Voltage
But it was time to bite this bullet… and over an afternoon I gradually increased the HS voltage in 50V steps.
With me wearing full PPE, in case something went wrong – arcing, smoke from something, etc.
The inverter says it works at anything from 450V upwards. But its DC Link Voltage Derate didn’t drop until I got to 600V. And even then, if the voltage dropped to 599V then the derate would come back. So I settled on 610V for the HS voltage.
(it’s at times like this that I’m glad I spent all that time making up the high voltage Amphenol connectors properly – no arcing, no drama (yet!)).
But things are getting a bit spicy on the bench now. 610V is no slouch.
Danger Will Robinson!
That’s most of the derates gone but I was still getting a system fault.
Here’s a plot from a zero-torque test run at 610V. The left-hand plots show the whole cycle, from precharge to discharge; the right-hand plots zoom in on the TorqueControl part. Getting the voltage up was one thing. Getting the motor to turn was clearly another.

I’d sent support requests off to the inverter supplier but I’d got nothing back.
I ran out of things to do.
But one thing I had left in my pocket, was a new firmware for the inverter.
New Inverter Firmware
I’d been holding off doing the update, because I didn’t want to change anything while I was still walking/crawling. I knew I’d need the new firmware to fix a torque ripple problem, but that shouldn’t stop the motor turning.
But I got to thinking… many embedded systems will do a full internal reset when you flash their firmware.
And that might clear my system fault.
So I had to make up the cable I needed to go from the Peak System CANbus adapter (PC only… Grrr) to the inverter. The various bits of documentation were confusing, which meant I didn’t get the cable pin connections right first time… or second… or third. But after breaking out the logic analyser to see what was going on, I figured it out and got the cable made.

I usually have some 9-way d-type connectors lying around but I could only find the wrong gender, so I had to butcher a 9 way serial lead!
And once the cable was all hooked up, the PC flasher app worked without a problem and it flashed the new inverter code.
Derates Again
But it didn’t fix the system fault… and what was worse, I got a whole bunch of new derates.
And that’s where I’m at – waiting for a response to my support request. 🙁
Updated Test Runner
While I was working through all the BMS and Inverter changes this week, I was getting frustrated with the number of times I was having to run a test cycle and how long it was taking.
I’d created a Python “test runner” script last week – taking the responsibility of running the test steps away from the AI: capturing CANbus packets off three CANbusses, grabbing voltages and waveforms from my scope and pulling captures from the logic analyser. All that was now being orchestrated by a Python script running on my Mac.
But it wasn’t telling me what I wanted to know about what was happening, electrically and in software, on the bench.
So it got an overhaul. Lots more data about the bench setup, while it ran me through turning on the ignition, pressing the brake pedal, selecting “forward drive” and pressing the throttle when needed.
Here’s what the final screen now looks like. More will get added, but it does tell me what I need to see more of now.

That’s the Week
So, that’s my week.
- Battery Connected
- BMS physically connected
- New BMS to Battery Cable made
- BMS VCU software module written
- Inverter programming cable made up
- Inverter flashed / programmed
- Bench now running at 610V
And nobody got electrocuted.
TTFN



Leave a Comment