Gen 2 Charger V5 Software Development Thread
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Gen 2 Charger V5 Software Development Thread
Setting up a new thread for development of software for the new STM32F103C8T6 based logic board for the Tesla Gen 2 10kw charger.
Design files (with my screwups fixed) for the boards released on Github :
https://github.com/damienmaguire/Tesla- ... /master/V5
New boards ordered from JLC and will start proper work once they arrive.
Here is my pathetic attempt to flash an LED and pump out some CAN messages.
https://github.com/damienmaguire/Tesla- ... 5/Software
The plan :
1) Ripoff as much of Johannes's code as possible.
2) Download this book into my brain : https://www.amazon.co.uk/Beginning-STM3 ... 274&sr=8-1
3) Offer free boards to people who want to help develop the code then ripoff their hard work for my own benefit.
4)Retire to Lanzarote.
Design files (with my screwups fixed) for the boards released on Github :
https://github.com/damienmaguire/Tesla- ... /master/V5
New boards ordered from JLC and will start proper work once they arrive.
Here is my pathetic attempt to flash an LED and pump out some CAN messages.
https://github.com/damienmaguire/Tesla- ... 5/Software
The plan :
1) Ripoff as much of Johannes's code as possible.
2) Download this book into my brain : https://www.amazon.co.uk/Beginning-STM3 ... 274&sr=8-1
3) Offer free boards to people who want to help develop the code then ripoff their hard work for my own benefit.
4)Retire to Lanzarote.
I'm going to need a hacksaw
- johu
- Site Admin
- Posts: 6633
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 346 times
- Been thanked: 1493 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
One little hint: thou shall use libraries. Try to use as much files from libopeninv unchanged. Check out the "git submodule" command on how to link a copy to your project. You don't have to compile all files, just what you need.
That way you are compatible with the Wifi code as is.
That way you are compatible with the Wifi code as is.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
-
- Posts: 260
- Joined: Sat Jan 12, 2019 12:39 am
- Location: UK
- Been thanked: 1 time
Re: Gen 2 Charger V5 Software Development Thread
I spotted a flaw in your plan - you missed out the "???" step before you got to "profit".Jack Bauer wrote: ↑Tue Jan 21, 2020 11:49 am The plan :
1) Ripoff as much of Johannes's code as possible.
2) Download this book into my brain : https://www.amazon.co.uk/Beginning-STM3 ... 274&sr=8-1
3) Offer free boards to people who want to help develop the code then ripoff their hard work for my own benefit.
4)Retire to Lanzarote.
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Oh yeah wasn't it something like :
1)Collect underpants
2)????
3)Profit
1)Collect underpants
2)????
3)Profit
I'm going to need a hacksaw
-
- Posts: 260
- Joined: Sat Jan 12, 2019 12:39 am
- Location: UK
- Been thanked: 1 time
Re: Gen 2 Charger V5 Software Development Thread
I pass on offering to get you started on your new ventureJack Bauer wrote: ↑Tue Jan 21, 2020 6:50 pm Oh yeah wasn't it something like :
1)Collect underpants
2)????
3)Profit

Re: Gen 2 Charger V5 Software Development Thread
I'm interested to help with development.
I have both a master and a slave unit.
And I have done some work on embedded units in the past.
Even with FreeRtos. But not on the Stm however.
send me a pm so we can discuss if I qualify....
Regards
/Per
I have both a master and a slave unit.
And I have done some work on embedded units in the past.
Even with FreeRtos. But not on the Stm however.
send me a pm so we can discuss if I qualify....
Regards
/Per
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Thanks will take you up on that once I have some new boards into stock early Feb. I really screwed up the first design:)
I'm going to need a hacksaw
Re: Gen 2 Charger V5 Software Development Thread
on the new schematic V5, I'm missing the pats and the connection for CAN_EXTH/L and CANH3/L3
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
These are not implemented on the V5. Please let's keep this thread for software development and post support questions on the charger board support thread.
I'm going to need a hacksaw
Re: Gen 2 Charger V5 Software Development Thread
Hi,
Similarly interested in testing/developing for the V5 board.
This ST part new to me too, but I've worked a lot with similar TI ARM based MCUs, TI-RTOS/FreeRTOS and CANBus etc.
Similarly interested in testing/developing for the V5 board.
This ST part new to me too, but I've worked a lot with similar TI ARM based MCUs, TI-RTOS/FreeRTOS and CANBus etc.
- Kevin Sharpe
- Posts: 1345
- Joined: Fri Dec 14, 2018 9:24 pm
- Location: Ireland and US
- Been thanked: 8 times
Re: Gen 2 Charger V5 Software Development Thread
The firmware is currently in development but I'm sure you'll find plenty to do once the code is released to GitHub

viewtopic.php?f=10&t=78&p=6663#p6663
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Beta firmware for the V5 :
https://github.com/damienmaguire/Tesla- ... er_Gen2_V5
Note this is untested as delays at JLC due to corona virus. Will see if I can cobble something together with a bluepill.
https://github.com/damienmaguire/Tesla- ... er_Gen2_V5
Note this is untested as delays at JLC due to corona virus. Will see if I can cobble something together with a bluepill.
I'm going to need a hacksaw
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
This firmware also support wifi via the unversal interface with the following parameters being available :
The information will be provided over serial to the esp8266 at 19200 baud 8n1 on uart3 in the form :
vaxxx,vbxxx,vcxxx,iaxxx,ibxxx,icxxx,uaxxx,ubxxx,ucxxx,aaxxx,abxxx,acxxx* where :
va=AC volts Module 1
vb=AC volts Module 2
vc=AC volts Module 3
ia=AC Current Module 1
ib=AC Current Module 2
ic=AC Current Module 3
ua=DC Volts Module 1
ub=DC Volts Module 2
uc=DC Volts Module 3
aa=DC Current Module 1
ab=DC Current Module 1
ac=DC Current Module 1
*=end of string
xxx=three digit integer for each parameter eg va230 = 230volts.
updates will be every 100ms approx.
The information will be provided over serial to the esp8266 at 19200 baud 8n1 on uart3 in the form :
vaxxx,vbxxx,vcxxx,iaxxx,ibxxx,icxxx,uaxxx,ubxxx,ucxxx,aaxxx,abxxx,acxxx* where :
va=AC volts Module 1
vb=AC volts Module 2
vc=AC volts Module 3
ia=AC Current Module 1
ib=AC Current Module 2
ic=AC Current Module 3
ua=DC Volts Module 1
ub=DC Volts Module 2
uc=DC Volts Module 3
aa=DC Current Module 1
ab=DC Current Module 1
ac=DC Current Module 1
*=end of string
xxx=three digit integer for each parameter eg va230 = 230volts.
updates will be every 100ms approx.
I'm going to need a hacksaw
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
First test of the new STM32 based software is looking good. Tom's menu system working as it should:)
I'm going to need a hacksaw
- tom91
- Posts: 2300
- Joined: Fri Mar 01, 2019 9:15 pm
- Location: Bristol
- Has thanked: 200 times
- Been thanked: 527 times
Re: Gen 2 Charger V5 Software Development Thread
Wait something I code actually works. 
Has the Settings menu now been transformed into something more user friendly? ( I have not dug into the settings menu of the opensource version recently)
I quite like what I achieved with my SimpBMS code, a frozen settings screen that you can just send the corresponding identifier 'number or letter' and value and it 'automatically' refreshes the settings overview.

Has the Settings menu now been transformed into something more user friendly? ( I have not dug into the settings menu of the opensource version recently)
I quite like what I achieved with my SimpBMS code, a frozen settings screen that you can just send the corresponding identifier 'number or letter' and value and it 'automatically' refreshes the settings overview.
Re: Gen 2 Charger V5 Software Development Thread
Sorry for the noob question, but what tools are you using to compile and link the code base.
ST's website shows at least 4 tool options tho TrueSTUDIO (Eclipse/CDT) by Attolic seems to be the default 'free' tool chain.
https://www.st.com/content/st_com/en/su ... -step.html
With TrueSTUDIO, I can open the eclipse project in Charger_Gen2_V5, but build fails as there is no 'make' in the installation. Seems the project is not setup to use the Eclipse/CDT internal builder.
Now I could fix this a few different ways, and happy to use the right make tool from a command line.
Would like to setup my environment the same way you guys do to get started.
ST's website shows at least 4 tool options tho TrueSTUDIO (Eclipse/CDT) by Attolic seems to be the default 'free' tool chain.
https://www.st.com/content/st_com/en/su ... -step.html
With TrueSTUDIO, I can open the eclipse project in Charger_Gen2_V5, but build fails as there is no 'make' in the installation. Seems the project is not setup to use the Eclipse/CDT internal builder.
Now I could fix this a few different ways, and happy to use the right make tool from a command line.
Would like to setup my environment the same way you guys do to get started.
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Wow, Gen 2 chargers have really come down in price lately. I think it's time to upgrade from this Lear deal. Ill be happy to do some testing once I get some hardware on order.
Formerly 92 E30 BMW Cabrio with Tesla power
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Thanks for the tip - no problem now building the V5 code base from github!Jack Bauer wrote: ↑Thu Feb 20, 2020 8:15 am Uses the CubeIDE:
https://www.st.com/en/development-tools ... beide.html
Can't wait to get testing - ready to get a board when ready.
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Pleased to announce the new charger boards are working well on the bench. Next up testing under actual charge conditions in the Panzer. I'll make boards available in the shop soon for beta testers.
I'm going to need a hacksaw
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
So we have our first bug. The proximity pin is used to detect the presence of the charge plug and also to determine the current carrying capability of the cable by means of a resistor divider. In the original arduino code it looks like this :
if ( parameters.type == 2)
{
if ( val > 950)
{
Proximity = Unconnected;
}
else
{
Proximity = Connected;
if ( val < 950 && val > 800)
{
cablelim = 13000;
}
if ( val < 800 && val > 700)
{
cablelim = 20000;
}
if ( val < 600 && val > 450)
{
cablelim = 32000;
}
if ( val < 400 && val > 250)
{
cablelim = 63000;
}
}
}
the arduino uses 10bit adc but I'm guessing the stm32 uses a higher resolution as it reports connected even with 3.3v on the adc pin.
if ( parameters.type == 2)
{
if ( val > 950)
{
Proximity = Unconnected;
}
else
{
Proximity = Connected;
if ( val < 950 && val > 800)
{
cablelim = 13000;
}
if ( val < 800 && val > 700)
{
cablelim = 20000;
}
if ( val < 600 && val > 450)
{
cablelim = 32000;
}
if ( val < 400 && val > 250)
{
cablelim = 63000;
}
}
}
the arduino uses 10bit adc but I'm guessing the stm32 uses a higher resolution as it reports connected even with 3.3v on the adc pin.
I'm going to need a hacksaw
- Jack Bauer
- Posts: 3641
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 9 times
- Been thanked: 282 times
- Contact:
Re: Gen 2 Charger V5 Software Development Thread
Yes. Still no luck with this bug. Have confirmed no hardware problems.
I'm going to need a hacksaw
- Kevin Sharpe
- Posts: 1345
- Joined: Fri Dec 14, 2018 9:24 pm
- Location: Ireland and US
- Been thanked: 8 times
Re: Gen 2 Charger V5 Software Development Thread
It's a long time since I played with this but iirc it's the EVSE that does the cable current measurement and limits its Pilot PWM accordingly. The car only uses Proximity to see whether a cable is connected. In this post you can see more details when using a J1772 connector;Jack Bauer wrote: ↑Fri Mar 13, 2020 1:46 pm The proximity pin is used to detect the presence of the charge plug and also to determine the current carrying capability of the cable by means of a resistor divider.
viewtopic.php?f=10&t=78&start=290#p8424
Edit: I've attached the diagram from the 61851 standard. Note the resistors defining the cable current capacity, "RC".
Edit2: I've had a chat with one of my colleagues and they reminded me that it was only in later versions of the standard that resistor "RC" was included in connectors at *both* ends of the cable (in early versions of the standard it was at the EVSE end only). When we get access to the workshop i'll check some cables and see whether we can safely assume "RC" is installed in both connectors.
Edit3: I'll open a bug report on GitHub just to capture the potential issue.
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.