Tesla Model 3 Charge Port Controller Standalone Development

Development and discussion of fast charging systems eg Chademo , CCS etc
Post Reply
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

gleb wrote: Fri Nov 27, 2020 2:33 pm
mdrobnak wrote: Mon Nov 23, 2020 10:44 pm http://www.setec-power.com/ccs-adapter/

Apparently 200 A (so 50A higher than the CHAdeMO adapter) to US Tesla...
Hi. kudos on your project.

Sorry for the layman's question, but what does a charge port controller do?

From the videos that @Jack Bauer posted I understood that ECU box does the talking between the battery and the charging station, where does charge port controller sits in this scheme, and how is CCS 2 Tesla adapter affects this?
I will update the first post to give an overview, but the CP ECU (Charge Port Electronic? Control Unit) is responsible for:
* Talking to the EVSE, which can be (not necessarily a complete list):
- J1772 or EU Equivalent
- CHAdeMO via adapter
- CCS on EU units
- Chinese GB standards
- Tesla Superchargers
* Talking to the Battery Management System
* Talking to the Charger (PCS)
* Talking to the car gateway for things like VIN for Superchargers

It allows the power to get from the charge port, to the battery, either directly in the case of fast charging, or via the charger for AC charging.

We are not involved with the CCS type 2 adapter - that is for Model S and X. My link was for _US_ cars for CCS type 1. Those of us who are Tesla owners were hoping for an official adapter, but looks like this 3rd party has done it.

I hope that answers your question.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Took some time to start unwinding the 'get it done' mess. All of the CAN transmit calls are suffixed with .ok(); which basically throws away the result and assumes it's all good. I've refactored the code to return the result, and if there is something in the Error frame, it will be appended to the activity list so that you can see it.

Looks like this didn't go as well as planned...looks like the time taken manipulating strings and putting them onto the activity array is breaking other things. I'll see about how I can profile the code to see exactly what's happening.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

I pushed the changes to handle_can_receive branch for now, so if someone is interested in reviewing it they can.
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

I had read somewhere that string formatting was quite expensive, so I changed my error reporting method for 10/100ms to do the number based method I was doing previously. Even in that scenario, I was still hitting timeouts.

Two possibilities:
1. The 'timeout' detection method being used by the CAN implementation is bogus
2. It's time to move to RTIC (https://ritc.rs/) which is a minimal-overhead RTOS completely in rust.
3. 1 & 2. :D

I'll be exploring various things here with the goal of getting the Error states handled correctly, and frames on the wire as they should be. I'll also be working on cleaning up my office / lab as it sorely needs attention.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

So it is a high likelihood that polling both Serial and CAN RX, while sending a decent amount on both, is causing my issues here. If I don't turn on the verbose serial output, things work fine. When I hit rainbow mode, due to the flurry of activity going on, its quite unhappy. However, turn on rainbow mode when it is _not_ in verbose mode and all works fine.

Need to re-test string manipulation as that didn't seem to have as much effect as I thought it would.

Given what I think the causes are:
1. Implement RTIC
2. Switch to a better CAN driver that we can hopefully do interrupt-driven receive.
3. Switch to DMA for serial (maybe).

Working on 1&2 now.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Ugh thought I hit the button to post this.

I spent most of my time today going through a lot of papers that have needed my attention, and my office is now set up for development:


I'm learning RTIC now, and it's a little confusing at first, but I think I'm making headway rather quickly.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

About 75% ported over to RTIC.

Frames send on time, yay!
"Uptime" timer no longer available for the moment.
Some weirdness geting it to conditionally configure things (for the F4 vs F7 for instance).

* Serial console is working
* Serial input is working
* 10 ms loop is working
* 100 ms loop is working
* RTC is working
* CAN still does stupid stuff if debugging isn't enabled.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

OK!

I've figured out that if I leave overflow checking enabled, optimized code still happens well, and it still sends multiple CAN frames. So yay for now. I have another driver that I will be moving to sometime in the future.

For now:
* Every 0.5 ms the CAN Rx FIFOs are checked (yikes I need interrupt-based Rx)
* Every 1 ms an uptime counter is set
* 10, 50, 100, 250, 500, 1000 ms loops run right
* Serial I/O is set on the 'idle' context so it's good enough but doesn't suck up processing time.

There is decidedly poor support for devices with varying IO such as USART2 vs USART3, etc. So I'll be doing 100% development on the Nucleo R4 board for now (which I pretty much was, but now it's just more of a pain to not do that) until I can figure out another option.

So, at this point in time, we are are where we were with my demo video, except it runs correctly this time. :D

Next step is to get the CHAdeMO EVSE side going, which I'll update that thread with info.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

I'm working on CHAdeMO...Just that there's definitely more that has to go right in order to make it work. :)

With the timeout reverted back to 1 second, still getting some weirdness at times with the CHAdeMO testing. But it's not happening often enough for that to be the issue. No, there's some fundamental weird things going on.

Fun fact: The Tesla CHAdeMO adapter advertises version 0.9, not 1.0 as I would have expected. It also just sets the max time available for charge time estimate.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

So I missed something the first time around - some of the messages that I thought were related to contactor control were..related..but not it. :D

There's deicdedly a much more intricate dance going on here, which includes a temporary disconnect of the HV battery to do the insulation test. This makes sense as to why I haven't gotten as far as I would have expected - the car is reporting the contactors closed, which is not where it should be at this point...Hopefully I get a bit further by end of day.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

I've looked over quite a bit of a log.
I have ~1600 messages to go through remaining. Looked through about 27,000.
Definitely a lot of stuff going on.
Noted that the contactors don't do anything for AC charge, only DC fast charge, which is interesting to me...and not how I designed my board. Maybe DC voltage shows up at AC input terminals on PCS as well? Unclear of the routing in the HV penthouse.

I'll finish this up tomorrow and then figure out how to work this in. :D

-Matt
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: Tesla Model 3 Charge Port Controller Standalone Development

Post by muehlpower »

I have the penthouse here, and I can tell you that only 2 HV lines go into at the US model. These are always cnnectet to the AC side of the PCS and additionally switched for DC charging via 2 extra relays. The normal main relays have to be switched on for driving and AC or DC charging. Pre charging in managed by the PCS by convertig 12V to 350V, no Pre Charge relays!
M3 Bat.png
I'm not sure about the EU version because I don't have one. But I know that it has an extra plug for AC!
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Interesting. Not sure I want to hit the input of my charger with that much DC voltage. :D That does explain some of the behavior I see in the log of the CHAdeMO session (and presumably my supercharging session though I'm not sure I logged the right bus when I did that, and, eh whatever).

Did you do that diagram yourself?

-Matt
User avatar
muehlpower
Posts: 570
Joined: Fri Oct 11, 2019 10:51 am
Location: Germany Fürstenfeldbruck
Has thanked: 12 times
Been thanked: 96 times

Re: Tesla Model 3 Charge Port Controller Standalone Development

Post by muehlpower »

That's what I found while disassembling the battery. 400V is not much, in Europe the phases have 400V to each other!
The DC link capacitors in the PCS are specified at 500V.
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Finished looking through the log, but I'm a bit tired. I need to figure out some changes to the state machine to deal with what goes on, and then I can get a rough version that hopefully gets further.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Got further today. Need to go over the log, but getting closer...
PXL_20201209_041254231.jpg
-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Went over the public charge log yesterday, it is kicking my butt. Trying to figure out how to control the current / voltage targets, and while I think I have a lead, the scaling isn't as straightforward as I'd expect.

SavvyCAN doesn't seem to graph Little Endian values in a way that I'd expect, so I ended up using the Data Analysis portion of Vehicle Spy...which I had to filter data because it ran out of RAM...I was just fighting all of my tooling last night.

So today I'll take my best guess, see what gets put over to the EVSE and work from there (as we know the scaling of the car side data from our Chademo controller projects...).

-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: Tesla Model 3 Charge Port Controller Standalone Development

Post by Jack Bauer »

I need to get back to this.....if its any consolation the Jag inverter kicked my ass all day today:)
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Jack Bauer wrote: Thu Dec 10, 2020 7:13 pm I need to get back to this.....if its any consolation the Jag inverter kicked my ass all day today:)
:D

Yeah, not sure what I'm doing wrong - I have a target voltage being sent, but not a target current, and that's what is supposed to start the charge cycle...
More tomorrow. Vacation from day job after 2:30 PM local :)

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Looks like there are at least two extra IDs that need to be sent, and now I'm sending them...but still no go.

I've short-cutted a little bit of contactor dance that I thought for sure wasn't needed...but maybe it is?

Or...I'm doing something wrong on the charger side. This is the problem of trying to engineer both sides at the same time :D

I'm sure that I'm slowly getting closer, just...not at the pace I'd like.

-Matt
collin80
Posts: 110
Joined: Sun Aug 30, 2020 3:28 pm
Location: United States, Michigan
Been thanked: 4 times
Contact:

Re: Tesla Model 3 Charge Port Controller Standalone Development

Post by collin80 »

mdrobnak wrote: Sat Dec 12, 2020 6:50 am Or...I'm doing something wrong on the charger side. This is the problem of trying to engineer both sides at the same time :D
Absolutely! The toughest is trying to engineer both sides at once. You might be better off trying to do one side at at a time and get it working well. Say, connect a Tesla or Leaf to your CHAdeMO and keep going until it works. Then when that's reliable switch and use an existing commercial CHAdeMO station and try to connect to it with your car side stuff. Then try the two at the same time. I can tell you this much - with EVTV we partnered with Damien for the JLD505 CHAdeMO and it was a long process of him going to charge stations and failing. Different stations implement the standard slightly differently so it's a real nightmare to make it reliable across all stations and all cars. They've all got quirks. So, don't feel bad, these problems you're having are unfortunately part of the "experience."
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

collin80 wrote: Sat Dec 12, 2020 5:00 pm
mdrobnak wrote: Sat Dec 12, 2020 6:50 am Or...I'm doing something wrong on the charger side. This is the problem of trying to engineer both sides at the same time :D
Absolutely! The toughest is trying to engineer both sides at once. You might be better off trying to do one side at at a time and get it working well. Say, connect a Tesla or Leaf to your CHAdeMO and keep going until it works. Then when that's reliable switch and use an existing commercial CHAdeMO station and try to connect to it with your car side stuff. Then try the two at the same time. I can tell you this much - with EVTV we partnered with Damien for the JLD505 CHAdeMO and it was a long process of him going to charge stations and failing. Different stations implement the standard slightly differently so it's a real nightmare to make it reliable across all stations and all cars. They've all got quirks. So, don't feel bad, these problems you're having are unfortunately part of the "experience."
Yeah I was thinking of that last night as well...Just don't want to connect more to my Model 3 than I have to - I'm probably generating enough log data with my missing CP ECU every so often. :D But at least this will just look like a broken CHAdeMO station, because, well, it probably is. :D :D :D

It'd be a fun experiment to try:
Tesla home charger -> my controller + port -> Coda (Lear) charger + CHAdeMO EVSE software -> Telsa adapter -> Model 3 :D --- But definitely not today.

I'll go and put in some abort code if any fault states show up or car says stop charging, and give it a shot on the car.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

I was going to say bad news: It doesn't work, good news: It doesn't work in the same way..but upon reviewing the photo I took, the car _did_ ask for 2 Amps of current.
laptop_chademo_evse.png

I missed a log message noting the state change into "Charge Loop".

Feel free to follow along with my code at https://github.com/mdrobnak/can-dc-fc-rs (this is open source).

Now to fix that log message, and figure out what the car did vs what I'm doing.

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Actually the car asked for more than 2 amps. Silly poorly structured code :D

I think the fact that it doesn't see any HV is what is stopping me. I may also be able to make the EVSE side lie and it will take that. More testing...

If I don't make any breakthrough here tonight, I think I need to buy some light bulbs, sockets, and start on the charger + ISA stuff...so I can actually show some voltage :D

-Matt
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: Tesla Model 3 Charge Port Controller Standalone Development

Post by mdrobnak »

Well, I went to Home Depot, picked up two sockets, two bulbs, an extension cord for connecting AC, and wired up the DC output side. And I then I did something dumb.
The control side of the charger had 4 pins - 2 CAN, 12V and ground. I...de-pinned them before seeing which was which :D
PXL_20201214_211842387.jpg
I did find out later what CAN H/L were, but it seems the charger only comes alive with AC input? I lack wire nuts or something to crimp the wall voltage correctly, so that stopped that part for the night. Instead, I tried to get the right CAN message to send - I need to put in a PR for the SimpBMS Chevy code as Tom added the Coda stuff a little _too_ quickly and had some copy paste errors. :) Happens to the best of us though. So I tried to get the EVCC controller I have to spit out messages...which was fun. I did get it to do it, but I had +12V, ground, and some extras :D
PXL_20201215_071746584.jpg
You need to give it power, then tell it ignition is on, then tell it the EVSE proximity is grounded noting it's locked, _then_ it will start charging. Also fought with some weird settings to get the terminal program going.

So now I have a messy desk, and am a bit stalled..but I think that tomorrow I'll get the AC side wired up, and I think I'll have CHAdeMO working. At least that's the plan. :D

-Matt
Post Reply