Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Tesla Wall Connector load sharing protocol

This site may earn commission on affiliate links.
Until you measure the actual pilot signal you don't know how many amps the HPWC is telling the car to pull. You may send a message to the TWC for 7.1A but you don't know what pilot signal is being sent to the car.

I've already said I agree with you so I'm not sure why you're repeating this point. If I could easily measure the pilot signal, I would, but since I can't do it without wasting a lot of time on being absolutely sure I'm doing it safely and measuring the correct points, I choose not to.

@CDragon: Maybe these little hardware gizmo's (by Nick Sayer) can help in troubleshooting


Thanks, M_VdM. I'll keep that hardware list in mind if I ever need to measure the pilot signal. Although it looks like none of those products are simply plug-and-play with the TWC's proprietary charger plug. I'd have to figure out where to connect wires within the TWC and if I have to go that far I may as well use the oscilloscope I already own.

But as I've said, I already found a workaround to the 6A limit problem, so doing tests to 100% prove the problem is the TWC or the car strikes me as a waste of time. This fix has worked in all tests for two days, so I'm satisfied. Even if the fault is in the TWC (which seems astronomically improbable now that basvk has reported the same glitchy behavior with a non-TWC charger), my fix wouldn't change.

If people are simply offended that I'm saying Tesla has almost certainly broken a feature in the car's firmware yet again without 100% incontrovertible evidence, I guess those people will just have to deal.

Anyway, the problem with the UI getting limited to 21A max has not returned after leaving the car charging at 5A all night and under normal solar output tracking today, so I don't know what caused it. Note that 5A is under the 6A minimum of the J1772 spec but the car did not error as it can with lower amp values. I figure 5A is safe because you can actually choose that as the lowest max on the car's UI.

I've updated the git repository with my latest fixes and will report back if I discover anything further.
 
Fastastic job CDragon!!

I will start playing with this later this week. I have two twcs and cars. also have solar panels so I am planning to do similar logic and also try to use cheap early morning hours of low kwh tariffs more efficiently.

There have been some reports about car randomly dropping to 6a per phase in our Finnish tesla user group lately. All of these owners have the latest firmware in the car (.44) and standard type2 chargers (without any charging rate changing logic). So it is probably an issue with car fw itself.
 
Got it working with one TWC. But I had to modify your code a little bit because it did not identify my TWC at all.

Just got this repeatedly:

21:47:06: ***UNKNOWN MESSAGE from slave: c0 fd e2 01 c9 8d 0c 80 00 00 00 00 00 00 c5 c0
21:47:07: ***UNKNOWN MESSAGE from slave: c0 fd e2 01 c9 8d 0c 80 00 00 00 00 00 00 c5 c0

the problem was in this regex:
if($msg =~ /\xc0\xfd\xe2(..)(.)\x1f\x40\x00\x00\x00\x00\x00\x00.\xc0/s) {
# Handle linkready message from slave.

Changed it to if($msg =~ /\xc0\xfd\xe2(..)(.)/s) { and it worked.


Maybe european twc has different identification string?
 
So, Digikey sent me a replacement for the bad FTDI rs485 cable, except the replacement had the same problem. That made me suspect none of the cables was bad so I did more research. I found that adding a 680ohm "bias" resistor between the orange D+ wire and red +5V wire, and another 680ohm between yellow D- and black ground fixed the problem and allowed me to receive the final fe byte even on the "bad" cable. The problem is that without bias resistors, noise in the wire between transmissions can generate false characters or apparently corrupt the last character of the message.

The TWC seems to expect noise from missing resistors (not sure if TWCs even have resistors when set to master mode) and tests show it doesn't care what you transmit after the final c0 byte. I tried ending messages with c0 fe, c0 00, c0 fd, c0 c0, or just c0 and TWC recognizes them all. So I updated my code to use the same rules.

I also found the TWC can get into a state where you tell it to stop charging, it turns off, then a second later it turns on again. TWCMaster sees it turn on and turns it off again and this cycle repeats for a long time, causing the relay in the TWC to click on and off every second. I fixed this by just sending the message to stay at 0 amps every second instead of only when TWC suggests a non-zero amp value.

Updates here.

I let my car charge to its target 70% today and everything seems good.

2017-11-16 Tracked till target charge.jpg


Fastastic job CDragon!!

I will start playing with this later this week. I have two twcs and cars. also have solar panels so I am planning to do similar logic and also try to use cheap early morning hours of low kwh tariffs more efficiently.

There have been some reports about car randomly dropping to 6a per phase in our Finnish tesla user group lately. All of these owners have the latest firmware in the car (.44) and standard type2 chargers (without any charging rate changing logic). So it is probably an issue with car fw itself.

Thanks! Please PM me some logs showing how it works with two TWCs if you get a chance.

I'm actually glad to hear the firmware bug may be affecting standard chargers rather than just the rare, intentionally-variable chargers. That should mean Tesla is more likely to fix the problem quicker.
 
  • Like
Reactions: spottyq
Thanks! Please PM me some logs showing how it works with two TWCs if you get a chance.

Yes, I will do that tomorrow. Have to connect some wires to link them together. My second twc is in outside, and the first one is in garage. But I already have CAT6 wires between the chargers so it will be easy.

By the way, I am using this Raspberry Pi addon: RS485 Shield V3 - Raspberry Pi - DEV-13706 - SparkFun Electronics
Works as expected, but had to change some kernel boot parameters to allow it to use /dev/serial0 (as raspi uses it for some console output by default)
 
  • Informative
Reactions: WinterDragoness
21:47:06: ***UNKNOWN MESSAGE from slave: c0 fd e2 01 c9 8d 0c 80 00 00 00 00 00 00 c5 c0

It looks like your TWC is reporting 0c80 = 3200 decimal = 32 amps. This makes sense because that's the max amps of an EU charger on 3-phase power. I'll update it to work with that.

That affects some other things as well. What is the minimum amps you can set in the car's UI? Here, it's 5A but I'm guessing it might be more like 2A or 3A there?

Also, I spike the charger to 21A for 5 seconds to get it out of its 6A limit here, but I suspect a lower spike would be necessary for EU chargers. If you create a file called overrideMaxAmps.txt in the same folder as the TWCMaster.pl script, you can put a number of hundredths of amps in it. Try 900, then raise to 1000, 1100, 1200, etc. At some point the car should start using the value you put here instead of being limited to 6A. Here, I have to reach 2100 (21A) before the car will increase power use beyond 6A.

In the TWCManager output, it will show something like S 01c9 5.14/12.00A: when the car is stuck at 6A and S 01c9 11.14/12.00A: when the car is using the desired 12A in this case.

overrideMaxAmps.txt is only checked once per minute so you have to be patient or modify the code to check more often.
 
  • Like
Reactions: spottyq
Minimum is still the same, 5A. That means the minimum charging power is 3x 5A x 230V = about 3,5 kW.
Your 21A workaround seems to be fine for Euro chargers as well, I tried to switch rates randomly between 5A-24A successfully.
If lower than 5A it will just shut down.
Older dual charger equipped cars can charge up to 3x 32A, newer (facelift) models only 3x 16A or 3x24A if equipped with High power charger update (my both cars do have that)
 
  • Informative
Reactions: Ulmo
Minimum is still the same, 5A. That means the minimum charging power is 3x 5A x 230V = about 3,5 kW.
Your 21A workaround seems to be fine for Euro chargers as well, I tried to switch rates randomly between 5A-24A successfully.
If lower than 5A it will just shut down.
Older dual charger equipped cars can charge up to 3x 32A, newer (facelift) models only 3x 16A or 3x24A if equipped with High power charger update (my both cars do have that)

That's odd the minimum charge rate on EU Tesla is 5A * 230V * 3 = 3.4kW vs here it's 5A * 240V = 1.2kW.

You say you tried 5A to 24A, but does say, 20A or other lower values get it out of the 6A limit mode? I'd rather not spike EU chargers to 21A if I don't have to go that high since 21A might be beyond the size of installed wiring to some chargers.
 
Got the Raspberry Pi Zero W today. Running TWCManager with VNC connected via wifi it's only drawing 0.12 to 0.15A (with a rare spike to 0.17A) at 5.02V. That strikes me as maybe low enough power to vampire off a power source inside the TWC? Can anyone with electrical engineering knowledge help me figure that out?

I found you can remove the inner cover within the TWC by prying out three snaps which doesn't take much force:

Remove first snap.jpg

Snap closeup:
Snap closeup.jpg

Under the cover:
Under cover overview.jpg

The ribbon cable near the bottom has 10 pins and supplies power to the LED array on the front of the unit. I tried testing voltage between some random pins and got 14V and 13.5V.

The bundle of 3 black plus a red wire that goes from mid left to top left looks like they could supply power but my volt meter read no voltage between red and black wires. I may have been too ginger with pushing pin-sized probes in the backs of the wires, though I don't think so.

Serious 24VDC to 400VAC transformers which I think supply the car with power:
24VDC transformers.jpg Beneath 24VDC transformers.jpg

And a bunch of closeups of everything:
20171116_215844.jpg 20171116_215849.jpg 20171116_220028.jpg

In the bottom right are four wires (purple, blue, black, and orange) screwed into terminal blocks. Those wires enter the charger cable for the car. If I'm reading this correctly, Tesla tends to use purple for the pilot wire, so maybe I'll give that a test sometime.

Does anyone see any points I might be able to draw power from?

Also, there is at least one more layer of PCBs beneath the one I'm able to take pictures of.
 
  • Like
Reactions: Dave EV
That's odd the minimum charge rate on EU Tesla is 5A * 230V * 3 = 3.4kW vs here it's 5A * 240V = 1.2kW.

Yes, that's true. Type2 signalling protocol is identical to Type1. Only the connector is different, and it has three phases instead of one. Many of EVs (and all hybrid vehicles as of now) charge using only one phase, even when used with Type2 sockets. They do not have three-phase internal chargers. You can even charge Type1 cars with type2 charger by using cable with type1 connector on the other end. That's why the signaling protocol is and has to be the same.


You say you tried 5A to 24A, but does say, 20A or other lower values get it out of the 6A limit mode? I'd rather not spike EU chargers to 21A if I don't have to go that high since 21A might be beyond the size of installed wiring to some chargers.

I did not try to disable your 21A code yet. I will take a look at it later today or during weekend. But at least with the code currently on Github it works (by going to 21A for a while)

Smaller homes have only three-phase 25A main breakers. At least here in northern Europe the choices for home installation main breakers are usually 25A, 35A, 50A, and 63A - and three phases, of course. And because we need a lot of energy to heat our buildings, home chargers are usually connected with 3x16A breakers. Some users limit their charging current to let's say 10A per phase.

My installation has 32A breakers for both twcs so it is safe to do testing with this. But you are right, for European installations 21A is usually too much and will cause problems.
 
  • Like
  • Informative
Reactions: Ulmo and spottyq
dlt was kind enough to let me remote control his two EU TWCs. I found and fixed some bugs in the code that made it fail with more than one TWC slave on the network. I also moved the various slave hash variables into one TWCSlave object which makes things more logical and easier to maintain.

I replaced all variables that refer to hundredths of amps with variables that use floating point amps. It was too confusing having two different systems in various places. So, for example, in the overrideMaxAmps.txt file, you would now put 10 instead of 1000 to limit it to 10 amps.

overrideMaxAmps.txt is now checked every 5 seconds.

Because dlt has two chargers each with their own 32A circuit breaker, I had to add a new config variable called $wiringMaxAmpsPerTWC to allow 32A to be sent to each TWC. $maxAmpsWiringCanHandle was renamed to $wiringMaxAmpsAllTWCs and that gets set to 64 in his system.

I want to do a little more testing before I push these changes to git.

His TWCs were purchased around May 2016 and do not send any battery or other info that my TWCs don't send. In fact, when his TWCs are not charging, they report 0.0A used while mine report 0.25A. I'm not sure if that means the EU firmware (or just older firmware?) doesn't report power when not charging a car or if maybe they can't measure low enough to report power used when idle in the EU model.

I was not able to reproduce the 6A charging limit on his vehicles. I ramped up from 6A to 15A one A at a time and it never got limited. Jumping from 6A to 14A or 6A to 32A also did not trigger the bug. Jumping up and down between various fractional amps did not trigger it either. So either the bug has different triggers on EU cars or his cars or chargers aren't affected for some reason. Any new firmware installed the last few days? (oh, he says it's because the cars have older firmware)
 
Last edited:
  • Informative
  • Like
Reactions: Ulmo and spottyq
@CDragon: I would take a chance with CNA8 (White 7x2 Box Header - Lower left corner) ...

I guess that 's probably a 14-pin JTAG connector.
Be careful ... There is no such thing as a "standard 14-pin JTAG connector" layout !
A google image search and some probing around with you scope and/or DMM will get you a long way. As usual :D

All the JTAG pins that aren't ground are 3.3V. I guess I could use a step-up converter like this to get 5V. But this says rpi Zero can run off 3.3V. Haven't found anyone who's tested the Zero W yet.

I also found that one of the pins on the cable that powers the LEDs is 14.07V which shows no fluctuation in the scope. Seems like I could tap into that with a 5V switching voltage regulator.

Tested most of the other visible pin headers and all the rest are 3.3V or less.

I could also just tap into two 120V AC lines and use a small 400mA wall wart I've got. I'm pretty sure it would all fit.
 
  • Like
Reactions: spottyq