The ZombieVerter VCU Project

Locked
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

The ZombieVerter VCU Project

Post by Jack Bauer »

So as most of you will know I have been selling two "vcu" products. One for the Nissan leaf inverter and one for the Lexus GS450H. Thanks to the SAM3X8E microcontroller no longer being stocked by JLCPCB this lead me to a redesign based on an STM32F105 micro. While doing the hardware design for this I implemented the possibility of using it for either of these two inverters. I'm happy to say there has a been a great response to my request for software support on the GS450H side of things so I decided to take the plunge and am now coding away on what I'm calling the ZombieVerterVCU.

It's basically a rip off of other people's hard work (my favorite modus operandi) in the shape of the STM32-CAR project :
https://github.com/jsphuebner/stm32-car
Openinvertrer:
https://github.com/jsphuebner/stm32-sine
ISA library:
https://github.com/Isaac96/SimpleISA
Leaf inverter driver by Celeron55,

So over the past few days I've been mashing together a project from these and other code and learning fun stuff like : Whats a static and when (not) to use it:) , How to hard crash an STM32 and other fun things. But yeah this is addictive. I'm loving the edit in a text editor and compile from the command line approach.

So what we have as of now is the openinverter wrapper with things like :
Throttle cal and mapping,
Precharge and contactor control,
Temp derating,
BMS limits,
for/rev/neutral control,
Graphing and monitoring,
Firmware updates via the web interface,
Cruise control,
Fuel gauge driver,
etc , etc

BUT, rather then driving an inverter powerstage this version sends CAN for the Leaf inverter or Sync serial for the GS450H and of course can be expanded to any number of others. This will be the default firmware for all vcu products from now on and future hardware will support future fun packed stuff like FLEXRAY!!!

As of now its a bench queen but its pumping out can that may or may not spin a leaf motor and talking to an isa shunt. Hardware should arrive next week and Dilbert is working away on the GS450H part. So that's all for now......where was i....oh yeah

uint16_t crashme = crashme*123.12;

UPDATE 10/05/21:
Anyone who intends purchasing a board will also need this kit of enclosure and header :
https://www.aliexpress.com/item/3285777 ... 4c4dWOmGPE

A full kit of enclosure,header and pre wired harness is also available:
https://www.aliexpress.com/item/4001213 ... hBvGO&mp=1

Update 26/06/21 : Now available on the EVBMW Webshop:
https://www.evbmw.com/index.php/evbmw-w ... vcu-boards

I will not be supplying these as getting them even in small volumes drives me into costly shipping,import charges,keeping stock etc. At the end of the day it will be cheaper and easier for customers to just buy one or two as needed via Aliexpress.

Explanation video :



Update 29/06/22 :
Following some collaboration with Johannes we now have a first official binary release for the vcu : https://github.com/damienmaguire/Stm32- ... ses/latest

Modules tested in this release :

Basic functionality e.g. contactor control, precharge ,throttle,brake etc
External charger control
CAN1,CAN2 and CAN3.
Native Chademo fast charging utilising CAN3
Timed AC charging
BMW E39 module
BMW E46 module
Nissan Leaf inverter module
OpenInverter module
ISA shunt module

NOT tested in this release:
GS450h module. Will be done in coming week or two once GS450h system arrives.
Prius module. As above.
PWM and DAC fuel gauge modules.
Other vehicle modules.
Attachments
2020-12-17 15.39.33.jpg
I'm going to need a hacksaw
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: The ZombieVerter VCU Project

Post by johu »

Good to see the inverter framework repurposed!
I think I will make a github template project with a stripped down inverter code base in case people want to build their projects upon it.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
P.S.Mangelsdorf
Posts: 753
Joined: Tue Sep 17, 2019 8:33 pm
Location: Raleigh, NC, USA
Has thanked: 89 times
Been thanked: 92 times

Re: The ZombieVerter VCU Project

Post by P.S.Mangelsdorf »

This looks exciting!

I've got a dumb/uniformed question:

Would it be possible/practical/make sense for some drive units to still create a new logic board for inside the unit, but all it does is connect to an external VCU either over CAN or otherwise?

Would that end up as the same as the current boards, but just controlled over CAN?

I'm thinking about the Tesla drive units, since we know Elon's board doesn't like to listen to CAN unless you ask nicely.

Like I said, very dumb and uninformed question.
If at first you don't succeed, buy a bigger hammer.

1940 Chevrolet w/ Tesla LDU - "Shocking Chevy" - Completed 2023 Hot Rod Drag Week
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: The ZombieVerter VCU Project

Post by mdrobnak »

I do like this idea and I must say libopencm3 is pretty nice. I may have gotten a biased review of things when I was trying to figure out how the rich man's charger worked as the CAN syntax was unintuitive to me. But upon poking at it later with the GS450h stuff briefly, it looks like a very nice lightweight alternative to Arduino that makes things easy enough to do, but doesn't add on things you don't need.

If I might make a suggestion: I *highly* recommend reading at least the first few chapters here - http://git-scm.com/book/en/v2 - on using git effectively. It is _extremely_ powerful and lets you keep track of changes easily. git branch and git stash are super useful. :) Especially for those that like to multitask (like nobody here, riiight??)...

Working from a single codebase for 99% of the stuff just being CAN driven will be great. The Toyota stuff complicates things, that's for certain. But having:
Path A - CAN
Path B - Sync Serial Fun
Path C - FlexRay

and being able to copy and edit...that'll be really good.

I can't wait to see where this lands. :)

-Matt
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: The ZombieVerter VCU Project

Post by jon volk »

P.S.Mangelsdorf wrote: Thu Dec 17, 2020 5:37 pm
Would that end up as the same as the current boards, but just controlled over CAN?

That’s basically what would happen. You still need the existing logic board for all the PWM generation. You can pretty much offload all other inputs to CAN as it currently exists. I’m doing just that on my next VCU.

This new project is interesting. I’ve been devoting the last month or two to working with ST’s HAL drivers. I’m at a bit of a crossroads as to continue down that or spend time on libopen.
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

Yeah I played with the HAL quite a bit. V5 tesla charger firmware is done that way. It's nice but I have just fallen into libopencm3. Especially as Johannes has done so much work it's easy to find an example of something if you get stuck. I will do the github thing soon as I have a few basic tests done. I have pumped this full of comments so should help beginers (and annoy Johannes!).
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

Ok so we are up and running on a 105:) Just using a spare bms master board as still waiting on the vcu hardware. Due tomorrow now according to good old DHL.... Now on to porting Dilbert's GS450H code over to libopencm3.

Pro tip : writing or reading IO pins you haven't defined really annoys the STM32. It just sits there and mocks me like Nelson from the Simpsons....
I'm going to need a hacksaw
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: The ZombieVerter VCU Project

Post by mdrobnak »

Jack Bauer wrote: Sun Dec 20, 2020 2:11 pm Ok so we are up and running on a 105:) Just using a spare bms master board as still waiting on the vcu hardware. Due tomorrow now according to good old DHL.... Now on to porting Dilbert's GS450H code over to libopencm3.
Nice work. :)
Jack Bauer wrote: Sun Dec 20, 2020 2:11 pm Pro tip : writing or reading IO pins you haven't defined really annoys the STM32. It just sits there and mocks me like Nelson from the Simpsons....
:D
See, that's one thing that's nice about Rust's compiler. GPIOA.PA0? What are you talking about??? :D

-Matt
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

Good news : boards arrived. Better news : they power up and program:)

Full kit on the way to Dilbert today to assist with the GS450H module development.
Attachments
2020-12-20 17.44.45.jpg
I'm going to need a hacksaw
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: The ZombieVerter VCU Project

Post by johu »

Beauty!
And I know who to blame when JLC runs out of CAN transceivers ;)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

This was a Tour De Force :
gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON,AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP);//remap usart 3 to PC10 and PC11 for VCU HW

Moron here had decided when designing the hardware that it would be a good idea to have the option of using Uart4 for the wifi. As the Uart4 pins are capabale of hosting Usart3 it was win win.........Yeah right. All day yesterday I struggled with trying to remap USART3 onto PC10 and PC11. OF course I made the usual mistakes like not enabling the AFIO clock etc but would they work? HELL NO. Got up this morning and decided to do it in assembler. And it worked! So not a hardware issue but libopencm3 just kept laughing at my attempts.

What am I doing wrong? I had been using AFIO_MAPR_USART3_REMAP_FULL_REMAP because that makes sense right? We want to remap the pins.... I'm sitting back in my office chair looking at my good old Commodore 64 which I still get a kick out of using connected by RS232 to my pc as a terminal. Ah the good old days, just rx,tx,cts,rts,dsr,ri.dtr..........wait........oh you are F%^King kidding me!!! change to AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP and everything starts working. Because of course a FULL REMAP moves ALL the USART pins!

So yay. Bootloader and firmware now running on the V3 vcu.
I'm going to need a hacksaw
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Yea that's why i've been using cubemx for configuration as it knows about little things like that. Looking forward to getting the board, I'll test my initial firmware on it and make sure we are still clocking at the correct rates and get the MTH data back correctly.

I'm probably going to have to put a fly-wire on the USART2_CLK line to bring it on to PA0, as the current pin PA4 will not allow me to generate the pseudo clock line.

I wonder for the next build would it be worth stuffing the 32KHz oscillator, as this would allow us to do charge timers etc, from the web interface.
User avatar
johu
Site Admin
Posts: 5684
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: The ZombieVerter VCU Project

Post by johu »

Ah yes, remap is quite an exercise. None of that easy to use IO matrix rubbish, as Dave Jones would say.

The 32 kHz is mostly helpful when you want to keep the RTC running while the STM32 runs off V_bat.

If you just want to use the RTC for relative timing you can just clock it from the 8 Mhz crystal, the prescaler is sufficient to divide it down.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
addvalue
Posts: 29
Joined: Fri Dec 04, 2020 3:27 am
Has thanked: 7 times
Been thanked: 3 times

Re: The ZombieVerter VCU Project

Post by addvalue »

Today I received a late 2014 em57 nissan leaf motor inverter and charger unit with external fire damage so no useable cables. If a little lucky not to have misjudged the damage, the electronics will be fine, I did make sure it wasn't an electrical fire in the first place.

After reading up on the many openinverter developments, I settled to buy this unit specifically to dust off my rusty coding skills, while hoping to upgrade my 30ft canalboat project from 3-phase ups and hvac tech to automotive ev gear. Preferably before next season starts as good motivator.

If deemed useful for the openinverter zombieverter vcu project, I'd like to jump straight in by working the nissan leaf vcu, documenting my progress in a dedicated topic that I will start after first h/w inspection tomorrow. If not complete roasted inside, to be continued.

Looking forward to stop just lurking, Quillaume
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Jack Bauer wrote: Mon Dec 21, 2020 9:14 am Good news : boards arrived. Better news : they power up and program:)

Full kit on the way to Dilbert today to assist with the GS450H module development.
The board arrived today, thanks to JB :)

One small issue i have is that i wasn't able to generate a pseudo clock off PA4, so i've had to tap onto PA0 which is mapped to a timer i can use.

I was seeing data coming in and out on the scope, which is a good sign. But i seem to have locked myself out of the CPU (cubemx doesn't have swd interface enabled by default). So i've tried resetting lots of different things but can't get back in with the ST-link.

I've pulled the Boot 0 pin high to start the internal boot loader (which is working as my code doesn't run), but i can't get in via the FTDI interface. I've also tried the ST-link after pulling the boot pin high, as this sometimes works too. I've had similar situations before, but usually one of these approaches should fix it.

Anyone any ideas?
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

What I have done in these circumstances is hold reset low, connect via stlink then release reset. Erase device and good to go.
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

Today's pro tip : Using unsigned integers to hold signed values is a bad idea. With programming skills like this I should get a job working on Cyberpunk 2077:)
I'm going to need a hacksaw
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Jack Bauer wrote: Wed Dec 23, 2020 8:01 am What I have done in these circumstances is hold reset low, connect via stlink then release reset. Erase device and good to go.
Yep that was my first port of call, but no luck. I'm going to check my connections again.

It's strange I can invoke the boot loader and my application stops but I still can't connect. I've tried the unified cubemx loader which does at link and uart connections. I've also soldered a pin onto the vcc and reset pin to allow for a 5 wire connection.

The only problem with the code on the chip (other than disabling debug) is I forgot, to enable the rx int for usart 2.
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

Have you tried with cube prog?
I'm going to need a hacksaw
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Yep installed cube prog, all I can think of is that the other option byte that controls the boot1 signal is in some funny mode.

Cpu is running fine and running my code. There's always the jtag option, but that would be a second last resort.
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

I'll get another board off to you.
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: The ZombieVerter VCU Project

Post by Jack Bauer »

So little update. Fought off a bunch of bugs with getting the ISA shunt integrated. Some of my making , some of the original Arduino setup library. Working perfectly now. All standard openinverter functions like precharge, direction control, voltage limits, temp derating etc etc are more or less running on the bench with the leaf can module. Moving on now to defining vehicle specific can modules for the BMW E46 and E65 obviously more can be added in the future. So I guess in theory if this pans out you can buy a vcu kit, get a know drivetrain eg GS450H and a known vehicle eg E46 and your all set. All setup done over the webinterface no programming. Code is nowhere ready for release as yet. Still a few things fighting me like the throttle ramp function is just laughing at my pitiful attempts to make it return anything except zero :)
Attachments
2020-12-23 14.17.55.jpg
2020-12-23 14.17.45.jpg
I'm going to need a hacksaw
User avatar
mackoffgrid
Posts: 93
Joined: Thu Jan 02, 2020 10:18 am
Location: Brisbane Australia
Has thanked: 4 times

Re: The ZombieVerter VCU Project

Post by mackoffgrid »

Jack Bauer wrote: Thu Dec 17, 2020 4:02 pm Thanks to the SAM3X8E microcontroller no longer being stocked by JLCPCB
Are you sure?

I've been tangentially involved in a project which uses the SAM3X8e, boards received just a few weeks ago.
https://jlcpcb.com/parts/componentSearc ... hTxt=sam3x
LCSC # C79305 plenty of stock.

Still I appreciate more people getting into the stm32F105 (107) .
I'm using the STM32F107 because they are a "basic" stock item (LCSC # C8315)
https://github.com/mackelec/SolarUte
meFDCAN Arduino Library 3 FDCAN port stm32G4xx
meCAN Arduino Library 2023 version 2/3 CAN port stm32F0xx, stm32F1xx, stm32F4xx, stm32L4xx
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: The ZombieVerter VCU Project

Post by mdrobnak »

Jack Bauer wrote: Wed Dec 23, 2020 10:49 am Today's pro tip : Using unsigned integers to hold signed values is a bad idea. With programming skills like this I should get a job working on Cyberpunk 2077:)
Ouch. :D
Jack Bauer wrote: Wed Dec 23, 2020 2:25 pm So I guess in theory if this pans out you can buy a vcu kit, get a know drivetrain eg GS450H and a known vehicle eg E46 and your all set. All setup done over the webinterface no programming. Code is nowhere ready for release as yet. Still a few things fighting me like the throttle ramp function is just laughing at my pitiful attempts to make it return anything except zero :)
Very nice. One thing to note here is the throttle function really needs to be non-linear. A linear throttle is pretty crap at the low end. I'll dig out the stock BMW M3 curves.

Any ideas how to implement tables with interpolation? I'm pretty useless there. I look at the assembly and cry. :D

-Matt
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: The ZombieVerter VCU Project

Post by jon volk »

mdrobnak wrote: Wed Dec 23, 2020 6:02 pm
One thing to note here is the throttle function really needs to be non-linear. A linear throttle is pretty crap at the low end..

Any ideas how to implement tables with interpolation? I'm pretty useless there. I look at the assembly and cry. :D

-Matt
Agreed on the linear throttle comment. I did a shitty hacky version in my LDU CAN stuff by using the map function with slip and only allowing a limited increase over the first 30% or so of throttle and then a second map for the remaining slip/throttle values from 31%-100%.

A table with interpolation would be way nicer, but my head started to spin when looking at implementation.
Formerly 92 E30 BMW Cabrio with Tesla power
Locked