Tesla Charger alternative firmware

Topics concerning the Tesla front and rear drive unit drop-in board
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 Charger alternative firmware

Post by mdrobnak »

johu wrote: Mon Jan 11, 2021 7:12 pm
jon volk wrote: Mon Jan 11, 2021 6:51 pm So, inquiring minds want to know. Where was issue in drop?
Basically the STM32 has a 3 message CAN send FIFO. So if your code is like
can_send();
can_send();
can_send();
can_send();

Then the last message will be dropped. To get around this you have to implement a software FIFO that stores the excess messages until the hardware FIFO is free again and then sends them out. That's exactly what the CAN module in libopeninv does and that is why building your software on top of stm32-template is super king :D
Ouch. I had some similar problems moving to the new bxcan Rust crate. If you wait for the return for the transmit, it works fine. With a single ID, 8 bytes, 500k, I was able to pump out 4000 messages/sec with an 8MHz clock. That seems close to the theoretical limit. A simple FIFO works well too, but what I tried last night(FIFO + Interrupt driven TX) worked very poorly to say the least, so I abandoned that.

-Matt
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

I see, well waiting is hardly an option in a scheduled environment because it can starve the other "threads". So in fact I also use interrupt driven TX as soon as the hardware FIFOs are full:

Code: Select all

   if (can_transmit(canDev, canId, false, false, len, (uint8_t*)data) < 0 && sendCnt < SENDBUFFER_LEN)
   {
      /* enqueue in send buffer if all TX mailboxes are full */
      sendBuffer[sendCnt].id = canId;
      ///etc....
      sendCnt++;
   }
and then in the ISR (edit: just noticed I actually implemented a stack, not a FIFO - but shouldn't matter)

Code: Select all

   while (sendCnt > 0 && can_transmit(...) >= 0)
      sendCnt--;

   if (sendCnt == 0)
   {
      can_disable_irq(canDev, CAN_IER_TMEIE);
   }
So even though there is a while loop in the ISR I expect it to just send one message per interrupt because the interrupt already fires when one place in the FIFO is free, as far as I know.

The result: say you send a burst of 3 CAN messages every 1ms. Then the interrupt will never be called because they all fit in the FIFO and it takes like 600us to send your 3 messages.
If you send a burst of 10 CAN messages every 10ms then the interrupt will be called 7 times every 10ms or 700 times per second. Which compared to the PWM interrupt which used to be called up to 17600 times per second doesn't seem like much. So I'm struggling to understand why it didn't work for you.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
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 Charger alternative firmware

Post by mdrobnak »

Slightly different method - add to queue, add pending interrupt. Interrupt handler then sends from queue. Not my design. ;)
Yeah, unclear why it didn't work the way I wanted. But I wrote a wrapper that would make it easier to swap to something else later if needed.

Ok back to the main thread here. :)

Thanks for the info.

-Matt
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

My flashing and testing has been delayed until later in the week. I got wrapped up in the new Volt BMS code and getting it squared away for my purposes.
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

Ok. One US test would be good because there was something about the input voltage being sent to the charger that I kept as a constant of 224V.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Bryson
Posts: 179
Joined: Sat Jan 25, 2020 6:22 am
Location: California
Has thanked: 1 time
Been thanked: 4 times

Re: Tesla Charger alternative firmware

Post by Bryson »

I’ll get going tonight in the US! Thank you
‘70 jag XJ6, GS450h drivetrain, 102s Tesla pack
User avatar
Jack Bauer
Posts: 3583
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 2 times
Been thanked: 144 times
Contact:

Re: Tesla Charger alternative firmware

Post by Jack Bauer »

May I suggest changing the bypass cap on the wifi module from 0.1uF to 10uf as you may experience adc read problems otherwise. This is implemented on the new rev boards on order.
I'm going to need a hacksaw
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

Can you remember the relevance of the following:

Code: Select all

uint16_t ACvoltIN = 240; // AC input voltage 240VAC for EU/UK and 110VAC for US
.....
if (bChargerEnabled)
{
   CanTxData[1] = 0xBB;
   CanTxData[4] = 0xFE; //FE dont clear faults. FF do clear faults.
}
else
{
   CanTxData[1] = (uint8_t)(((uint16_t)(ACvoltIN / 1.2))&0xFF);
   CanTxData[4] = 0x64;
}
I have hard coded it to 0xBB (which translates to 224V) right now and apparently it works on 230V outlets. But will it work in 120V like this?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Bryson
Posts: 179
Joined: Sat Jan 25, 2020 6:22 am
Location: California
Has thanked: 1 time
Been thanked: 4 times

Re: Tesla Charger alternative firmware

Post by Bryson »

Jack Bauer wrote: Thu Jan 14, 2021 5:54 pm May I suggest changing the bypass cap on the wifi module from 0.1uF to 10uf as you may experience adc read problems otherwise. This is implemented on the new rev boards on order.
Thanks. Do you know the component size/family off hand? I’m still in the office and won’t be able to check or measure until tonight. Might be useful for others to know off hand in this thread as well.
‘70 jag XJ6, GS450h drivetrain, 102s Tesla pack
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

0603 but 0805 also fits
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Bryson
Posts: 179
Joined: Sat Jan 25, 2020 6:22 am
Location: California
Has thanked: 1 time
Been thanked: 4 times

Re: Tesla Charger alternative firmware

Post by Bryson »

Thanks, I was able to replace the C3 cap with a 10uF that we had in the office. I believe these are 0805 as the 0603 barely fit on the footprint and was smaller than what I removed, for what it's worth.

I was able to flash the software, but I'm no longer able to communicate with the USB serial link after flashing - has this been deprecated in the new firmware?

My ESP8266 WiFi has never worked properly and I believe that makes this firmware not useable for me until I can resolve that. WiFi at 192.168.4.1 has always shown '900' for all 'gauges' for me. I did have a hell of a time flashing the software to the ESP8266 on my mac, so perhaps I made a mistake there.

edit: I realized I had another ESP8266 sitting around - I programmed that one and we're off to the races. I'm able to edit parameters via the Management Console :D Very slick. The charger works great, and the 5 minute timer works exactly as advertised :) Thank you!

Here's me charging on a US single phase 240V circuit (I cycled the charger button to initiate the second charge start in the first image):
7A5E5968-4FC3-4EDE-A8C4-D1FF40AA8CD7_1_102_o.jpeg
B55A9B67-8B42-480F-97DE-792382F51509_1_102_o.jpeg
B3BBC5AA-30F9-401F-8FD4-CD0B2C6D2637_1_102_o.jpeg
B5851FA4-6F35-4934-B3D2-1AFE80E0CCBA_1_102_o.jpeg
Charge Params.png
‘70 jag XJ6, GS450h drivetrain, 102s Tesla pack
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

Nice, thanks for testing! Will send you a pin in a minute.
Yes the USB terminal has not been implemented, I'd keep it that way unless it stops the show for anybody.

Can you do a 120V test?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
Jack Bauer
Posts: 3583
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 2 times
Been thanked: 144 times
Contact:

Re: Tesla Charger alternative firmware

Post by Jack Bauer »

Sorry guys I was off to bed early last night. I'll write a few lines today on component mods. Just one cap and one resistor. All boards being shipped out now already have this done.
I'm going to need a hacksaw
Bryson
Posts: 179
Joined: Sat Jan 25, 2020 6:22 am
Location: California
Has thanked: 1 time
Been thanked: 4 times

Re: Tesla Charger alternative firmware

Post by Bryson »

johu wrote: Fri Jan 15, 2021 8:42 am Nice, thanks for testing! Will send you a pin in a minute.
Yes the USB terminal has not been implemented, I'd keep it that way unless it stops the show for anybody.

Can you do a 120V test?
Thanks again. I don’t have a 120V EVSE handy but can probably whip up a cable and run it in manual mode. I’m a bit hesitant as the grounds don’t seem to be very good in my old home, so it may take me a little time to test before plugging in.
‘70 jag XJ6, GS450h drivetrain, 102s Tesla pack
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

Ok, don't blow yourself up! Lets see what Jon Volk does
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

Im about to pull the car in the garage to get the cover off the charger. I can give it a go without changing the cap to save time and then pull the board if Im getting bad inputs on the ADC. It appears the openevse will accept the 120v input as well so it should be a quick reconfigure at the breaker box.
Formerly 92 E30 BMW Cabrio with Tesla power
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

No luck today. Updated the wifi module and have the interface showing. Updated the bootloader and charger file but no parameters coming through on the interface. Need to dig in further tomorrow.

EDIT: I’m a dumbass and didn’t tag the reset button. Will configure and test power after the kids are fed,
Formerly 92 E30 BMW Cabrio with Tesla power
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

120v EVSE charging works. Correctly IDd evse set 12a limit.
Attachments
DF3D510F-9277-4A3A-81E2-5F8F08CEAA18.png
DFB43D41-0B88-4036-BC20-A347A5C7F303.jpeg
A2FAB5FD-E85D-4BCF-9DFE-3619309B386F.jpeg
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

One bug found :) iaclim was limited to 16A, which limits total current on a single phase outlet to... well 16A. Even if it could provide 32A or more.

Fixed.
Attachments
stm32_charger.zip
(30.74 KiB) Downloaded 232 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

Excellent. Now I have to go do some burnouts to drag the pack voltage below charge threshold again. Tough life.
Formerly 92 E30 BMW Cabrio with Tesla power
Bryson
Posts: 179
Joined: Sat Jan 25, 2020 6:22 am
Location: California
Has thanked: 1 time
Been thanked: 4 times

Re: Tesla Charger alternative firmware

Post by Bryson »

Thanks, that explains the constant 4kW I was seeing. This firmware can be loaded OTA right? Is there a link to the process, or is it dummy proof? :)
‘70 jag XJ6, GS450h drivetrain, 102s Tesla pack
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

Yea it’s OTA. Just click choose file in the uart update and select the .bin, click upload.
Formerly 92 E30 BMW Cabrio with Tesla power
jon volk
Posts: 574
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: Tesla Charger alternative firmware

Post by jon volk »

Full power charging works as expected as does the CAN transmit messages as evidenced by my water pump and dcdc turning on with the charger enabled value of 5.

Good stuff.
Attachments
620CD4AA-C36B-497E-810A-776932DC79B0.jpeg
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
johu
Site Admin
Posts: 6323
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 250 times
Been thanked: 1318 times
Contact:

Re: Tesla Charger alternative firmware

Post by johu »

Cool, CHAdeMO water pump then :)

I guess I'll just publish then.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Bryson
Posts: 179
Joined: Sat Jan 25, 2020 6:22 am
Location: California
Has thanked: 1 time
Been thanked: 4 times

Re: Tesla Charger alternative firmware

Post by Bryson »

Mine is still charging at a steady 4kW = 16A on my 40A EVSE after the firmware upgrade. I am at 92% SOC so it may be coincidental that the taper current is the same and that’s what I’m seeing. I’ll have to drive a bunch to discharge it and try again.
‘70 jag XJ6, GS450h drivetrain, 102s Tesla pack
Post Reply