Page 1 of 1

Tesla charger programming/source code

Posted: Mon May 11, 2020 8:04 am
by joromy
Programming question, can you help Tom, or anyone....

I want to be able to close a relay to short phase 1.2.3, when I charge at 1 phase outlet. Relay is connected to DIG_out_3.

Is there a safe way to activate the relay in software?
I was thinking to read ACpres or acvolt.
If AC is only present on phase 1 chargermodule, then it should close the relay, and change charger mode from 3 phase to 1 phase, and stay in this mode until disconnect of EVSE.

All chargermodules will get AC, and can charge with higher amp.

Re: Tesla charger programming/source code

Posted: Mon May 11, 2020 8:26 am
by tom91
You can do this, however it requires some clever timing.

The charger phases need to see AC voltage within 'x' amount of seconds of being enabled.

I would be very careful of doing this, as any relay failure will cause huge consequences. Quite a lot testing and validation would be required before I would use it on an EVSE.

Re: Tesla charger programming/source code

Posted: Mon May 11, 2020 9:43 am
by joromy
The OEM setup on the Tesla can do this.
The charger will always be in 3 phase mode, and only shift to 1 phase if missing AC on phase 2 and 3.

If relay should close when on 3 phase, then AC fuse in car and grid will blow, and relay would probably go bad...
No harm to charger or EVSE, as I can think of.

I was thinking of making a seperate module to close the "1 phase" relay, but the charger already has the circuitry to measure AC.

Re: Tesla charger programming/source code

Posted: Mon May 11, 2020 2:37 pm
by Kevin Sharpe
joromy wrote: Mon May 11, 2020 9:43 am The OEM setup on the Tesla can do this.
Tesla have a module for this that connects to the Gen 2 charger AC. It's a stand alone unit that is not directly controlled by the charger. I posted some information on DIY Electric (here).

It may not work with the open source controller.

Re: Tesla charger programming/source code

Posted: Mon May 11, 2020 6:30 pm
by joromy
Kevin Sharpe wrote: Mon May 11, 2020 2:37 pm
joromy wrote: Mon May 11, 2020 9:43 am The OEM setup on the Tesla can do this.
Tesla have a module for this that connects to the Gen 2 charger AC. It's a stand alone unit that is not directly controlled by the charger. I posted some information on DIY Electric (here).

It may not work with the open source controller.
Thank you, will first try to use the relay and the charger board, have it already connected.
If I do like this I don't have to do timing of the startup/relay sequence.

I was thinking, to always start in 3 phase mode.
If connected to 3 phase, it will start in 3 phase mode and start all modules, and charge like normal.

If connected to 1 phase, it will start in same mode, but will only see voltage (AC) on phase 1.
Then it can restart, set the mode to 1 phase, close the relay on DIG_out_3, start all modules, and charge like normal.
If EVSE is disconnected it will start in 3 phase mode, when connected again.
Capture_1phase.JPG
Capture_1phase_x3.JPG
If anyone want to help with some programming example, I will be very happy. Will probably manage to do it myself, with many long nights and struggles, I'm a not a good programmer!!

Re: Tesla charger programming/source code

Posted: Mon May 11, 2020 6:34 pm
by tom91
That sounds like it would work yes. all you have to change/over ride is the variable for the phase wiring type.

Re: Tesla charger programming/source code

Posted: Mon May 11, 2020 6:47 pm
by joromy
tom91 wrote: Mon May 11, 2020 6:34 pm That sounds like it would work yes. all you have to change/over ride is the variable for the phase wiring type.
Here is the code I use now, if you have nothing to do, please feel free to help :D
This could be a nice feature to have in the official version to.....

https://github.com/jomy-tech/My_Tesla_Charger

Re: Tesla charger programming/source code

Posted: Thu May 14, 2020 1:45 pm
by joromy
I think I found a simpler way to do this. Do you think it will work? :?
At least, this way it will not go boom, if contactor fails or get welded!!

The charger will be in 1Phase mode all time, N-L1 connected to all modules.
When there is 400VAC on L2-L3, contactor will close and connect phase123 to module 123, and set IN2 high.

It will still need some program changes, to tell the charger to switch to 3phase mode, when IN2 is high.
1phase_3phase.JPG
Can not find a contactor/relay with 3PDT and 400VAC coil, but it should be possible to use something like this from RS:
https://uk.rs-online.com/web/p/contactors/7447184/

Re: Tesla charger programming/source code

Posted: Tue May 19, 2020 1:08 pm
by joromy
Here is the code that need to be changed:

Code: Select all

// Find this: (line 390 or something, depending on version)
    evseread();
    autoShutdown();
    watchdogReset();
    manualMode();

// Add the following:
    if (digitalRead(DIG_IN_2) == HIGH)
      parameters.phaseconfig = Threephase;
    else
      parameters.phaseconfig = Singlephase;
You could also edit the setup description: pinMode(DIG_IN_2, INPUT); // High in 3phase mode.
You will not be able to change between 1ph and 3ph in the menu, so you might as well remove it.

Re: Tesla charger programming/source code

Posted: Thu Jul 02, 2020 1:23 pm
by Chad B
What is the function of the termination voltage setting?

Re: Tesla charger programming/source code

Posted: Fri Jul 03, 2020 6:48 am
by joromy
Charger stop charging at that voltage, set it a little higher than the BMS shut off voltage.
Remember to test it, because the charger don't measure accurately.

Re: Tesla charger programming/source code

Posted: Wed May 05, 2021 6:58 pm
by EV_Builder
The safest implementation of this is by hooking 2 extra 230VAC relais (small ones) parallel on each incomeing phase.
The contacts of them are then in series. And those are in the A1 or A2 side of your switch over relais.
Then the software detects there are missing phases and command the change over relais to bundle the phases and if the hardware detects otherwise it won't happen.... (You do need to make up your mind if you are willing to power the socket back to the charger with extra phases)...

I think this would be a Safe, level one, solution. In order to get into higher safety levels you need to read back contacts of the relais and use 'safety relais'. But i don't think that would be needed in this situation since i suspect there are electronic fuses in the charger which will detect some anomalies.