Page 1 of 6

Gen 2 Charger V5 Software Development Thread

Posted: Tue Jan 21, 2020 11:49 am
by Jack Bauer
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Tue Jan 21, 2020 1:04 pm
by johu
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Tue Jan 21, 2020 6:18 pm
by doobedoobedo
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.
I spotted a flaw in your plan - you missed out the "???" step before you got to "profit".

Re: Gen 2 Charger V5 Software Development Thread

Posted: Tue Jan 21, 2020 6:50 pm
by Jack Bauer
Oh yeah wasn't it something like :
1)Collect underpants
2)????
3)Profit

Re: Gen 2 Charger V5 Software Development Thread

Posted: Tue Jan 21, 2020 8:19 pm
by doobedoobedo
Jack Bauer wrote: Tue Jan 21, 2020 6:50 pm Oh yeah wasn't it something like :
1)Collect underpants
2)????
3)Profit
I pass on offering to get you started on your new venture :)

Re: Gen 2 Charger V5 Software Development Thread

Posted: Wed Jan 22, 2020 9:39 am
by pm_dawn
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

Re: Gen 2 Charger V5 Software Development Thread

Posted: Wed Jan 22, 2020 7:25 pm
by Jack Bauer
Thanks will take you up on that once I have some new boards into stock early Feb. I really screwed up the first design:)

Re: Gen 2 Charger V5 Software Development Thread

Posted: Fri Jan 31, 2020 11:19 pm
by kendo
on the new schematic V5, I'm missing the pats and the connection for CAN_EXTH/L and CANH3/L3

Re: Gen 2 Charger V5 Software Development Thread

Posted: Sat Feb 01, 2020 9:05 am
by Jack Bauer
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Sun Feb 16, 2020 5:52 pm
by rgjones
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Sun Feb 16, 2020 7:42 pm
by Kevin Sharpe
rgjones wrote: Sun Feb 16, 2020 5:52 pm Similarly interested in testing/developing for the V5 board.
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

Re: Gen 2 Charger V5 Software Development Thread

Posted: Tue Feb 18, 2020 5:57 pm
by Jack Bauer
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Tue Feb 18, 2020 6:34 pm
by Jack Bauer
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Wed Feb 19, 2020 4:37 pm
by Jack Bauer
First test of the new STM32 based software is looking good. Tom's menu system working as it should:)

Re: Gen 2 Charger V5 Software Development Thread

Posted: Wed Feb 19, 2020 6:16 pm
by tom91
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Wed Feb 19, 2020 7:06 pm
by rgjones
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Thu Feb 20, 2020 8:15 am
by Jack Bauer

Re: Gen 2 Charger V5 Software Development Thread

Posted: Fri Feb 21, 2020 6:57 pm
by jon volk
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Fri Feb 21, 2020 7:18 pm
by Jack Bauer
Thanks Jon

Re: Gen 2 Charger V5 Software Development Thread

Posted: Sat Feb 22, 2020 6:39 pm
by rgjones
Jack Bauer wrote: Thu Feb 20, 2020 8:15 am Uses the CubeIDE:

https://www.st.com/en/development-tools ... beide.html
Thanks for the tip - no problem now building the V5 code base from github!
Can't wait to get testing - ready to get a board when ready.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Fri Mar 13, 2020 1:11 pm
by Jack Bauer
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Fri Mar 13, 2020 1:46 pm
by Jack Bauer
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.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Fri Apr 03, 2020 11:15 pm
by cloudy
Think the stm32 has a 12bit ADC?

Re: Gen 2 Charger V5 Software Development Thread

Posted: Sat Apr 04, 2020 6:09 am
by Jack Bauer
Yes. Still no luck with this bug. Have confirmed no hardware problems.

Re: Gen 2 Charger V5 Software Development Thread

Posted: Sat Apr 04, 2020 9:50 am
by Kevin Sharpe
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.
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;

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".
61851_B5.png
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.