The ZombieVerter VCU Project

Locked
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Thanks folks. Goddamn my brain is pulped about now. Got the LIM working with the vcu in ac mode but made myself a doozy of a bug that puts the car in charge mode when you hit the start key. Had to quit for the night. 13 hours on this today:) Sure wish I'd learned some C along my journey ...
I'm going to need a hacksaw
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

I think a state machine would fix that problem, that's what I was attempting to design with the diagram above. It would also be much easier to debug too.
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: The ZombieVerter VCU Project

Post by Jack Bauer »

100% agree Dilbert. In case it wasn't obvious to folks I am very very out of my depth in this level of programming so I once again appeal to the community for some participation in this project.
I'm going to need a hacksaw
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Implementing the main state machine is actually straightforward, the hard part is the logic. Also some of the state transitions could be as a result of hardwired inputs or other transitions could be CAN messages etc...

I've updated the logic, if people could let me know what they think. I've possibly forgotten a few things. Things like the regen code would be implemented in the "moving" state. The "moving" state could also be used to control the electric power steering, or maybe "ready" would be a better state for that with some sort of time out.
Attachments
zombie ecu logic x2.gif
zombie ecu logic x2.pdf
(63.65 KiB) Downloaded 104 times
User avatar
chuuux
Posts: 68
Joined: Fri Mar 12, 2021 5:11 am
Location: Ural
Has thanked: 1 time

Re: The ZombieVerter VCU Project

Post by chuuux »

What is the difference between "Stopped" and "Select Direction" states? May be combine them into one?

What about "Start DC-DC 12V" state with delay?
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

I guess the thinking is that you can be stopped, but actually be in forward or reverse gear. A better name for the "select direction" state might be "neutral"?

Also, there is a mistake on that diagram as you can go from stopped back to moving, without selecting the direction again.
User avatar
chuuux
Posts: 68
Joined: Fri Mar 12, 2021 5:11 am
Location: Ural
Has thanked: 1 time

Re: The ZombieVerter VCU Project

Post by chuuux »

I understood a bit. But I try to follow all scenarious and there is no exit to "Disconnect contactors" from "Neutral" (without moving)
In some cases, like GS450h, with machanical parking lock I quess it's more logical to make "Parking" state instead of "Neutral" with moving denied.
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Thanks Dilbert. I'll look this over asap but don't let me hold up the process. I'm up to my ears in ccs right now:) On that note I found my mode bug. Stupid of course but they all are once found:)
I'm going to need a hacksaw
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Thanks for the feedback above, here is an updated version of the diagram.
Attachments
zombie ecu logic x3.png
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

The one thing i need to confirm is are we going to put the CPU into a low power state, or is the quiescent of the power supply large that the CPU current doesn't make a difference.

Normally the system receives an ignition signal, obviously with the charging now integrated it wouldn't be a traditional ignition signal. I was considering if an external 12V charge timer could be used, this could be wired in to wake the ECU when charging is required, I've a few ideas around how this could work (might require a relay).
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Well I don't see the need for a sleep state personally. I just switch off the 12v if I'm away from the car for more than a few days.
I'm going to need a hacksaw
User avatar
johu
Site Admin
Posts: 5768
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 157 times
Been thanked: 1009 times
Contact:

Re: The ZombieVerter VCU Project

Post by johu »

For the BMS we used two external input for firing up the 5V regulator.
The MCU can then choose to keep the regulator on as long as it pleases.
Power down mode was not very effective because the draw from all other chips and the regulator by far exceeded MCU consumption.
Attachments
Bildschirmfoto vom 2021-06-03 19-56-07.png
Bildschirmfoto vom 2021-06-03 19-56-07.png (8.23 KiB) Viewed 7496 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

Jack Bauer wrote: Thu Jun 03, 2021 2:58 pm Well I don't see the need for a sleep state personally. I just switch off the 12v if I'm away from the car for more than a few days.
It doesn't necessary need to be a sleep state as such, but it is a state where all of the ECU outputs are off and the system is checking for ignition active or charger active. For the Outlander charger we would probably be checking an ADC for the charger handle connected. So the low power state, would actually include the two checks above it. For some vehicles we could be monitoring CAN traffic looking for KL15 signal and then deciding to "wake up proper". In the "low power" state we could have the DC:DC converter off for example.
Dilbert
Posts: 410
Joined: Mon Aug 12, 2019 7:21 pm
Location: Dublin, Ireland
Been thanked: 4 times

Re: The ZombieVerter VCU Project

Post by Dilbert »

johu wrote: Thu Jun 03, 2021 5:57 pm For the BMS we used two external input for firing up the 5V regulator.
The MCU can then choose to keep the regulator on as long as it pleases.
Power down mode was not very effective because the draw from all other chips and the regulator by far exceeded MCU consumption.
I've used this solution in commercial ECUs and it can work quite well as the software can decide when to drop out the 5V Regulator.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: The ZombieVerter VCU Project

Post by EV_Builder »

Jack Bauer wrote: Mon May 31, 2021 9:45 am On a specific note can someone please help me with this :

Code: Select all

I_Batt=(Param::GetInt(Param::idc)+819.2)*10; //This crashes the stm32
I_Batt=(Param::GetInt(Param::idc)+819)*10; //This works but with a slightly wrong value.
Is I_Batt a float?
If you do *10.0 it will be a float i think. 10 is an int.
You can easily check with * 10.0001 if needed.
The parameter also needs to become a float.
With the function mentioned.

Ow and be carefull with using (float) etc..because those are compiler instructions to interpret memory. It's like point to a plane and telling the compiler it's a car. Since the memory layout differs that ain't gonna work always. It should only be used when you are sure where you are working with.

If we convert often to float we should add one function in the parameter class that it can give back the parameter as a float. It makes the code more readable too. That's the pro solution IMHO.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: The ZombieVerter VCU Project

Post by EV_Builder »

Jack Bauer wrote: Mon May 31, 2021 9:45 am On a specific note can someone please help me with this :

Code: Select all

I_Batt=(Param::GetInt(Param::idc)+819.2)*10; //This crashes the stm32
I_Batt=(Param::GetInt(Param::idc)+819)*10; //This works but with a slightly wrong value.
The most elegant and clean way of doing this is simply:

I_Batt= ((Param::GetInt(Param::idc)*10) + 8192 );

I just re-read my last post and thought i should post the cleanest solution when everything should stay INT.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Cool thanks:) Next thing I need to do is fix my broken soc calc routine :

Code: Select all

void CalcSOC()
{
int32_t Capacity_Parm = Param::GetInt(Param::BattCap);
int32_t kwh_Used = FP_FROMINT(ISA::KWh);    //grab actual Wh from isa shunt
if(kwh_Used<0)
{
    NetWh = Capacity_Parm - kwh_Used;
    SOCVal = (kwh_Used/Capacity_Parm)*100;
}

if(kwh_Used>0) SOCVal=100;
Param::SetInt(Param::SOC,SOCVal);

}
I'm going to need a hacksaw
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Also need some way to run a cc/cv charge on ccs.
I'm going to need a hacksaw
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: The ZombieVerter VCU Project

Post by EV_Builder »

Jack Bauer wrote: Wed Jun 09, 2021 8:05 am Cool thanks:) Next thing I need to do is fix my broken soc calc routine :

Code: Select all

void CalcSOC()
{
int32_t Capacity_Parm = Param::GetInt(Param::BattCap);
int32_t kwh_Used = FP_FROMINT(ISA::KWh);    //grab actual Wh from isa shunt
if(kwh_Used<0)
{
    NetWh = Capacity_Parm - kwh_Used;
    SOCVal = (kwh_Used/Capacity_Parm)*100;
}

if(kwh_Used>0) SOCVal=100;
Param::SetInt(Param::SOC,SOCVal);

}
Ok then I have some design questions.
Do we have Float in stm32? If yes then tell the compiler that kwh_used is one.
Because you are pulling a int into the function to return a float.
The comparison < 0 should be 0.0 if it's a float.

So as is the code is not correct because the 4bytes are like a float and the code handles it like a int32. If the float is 8bytes (64bits) you even overwrite some memory but I suspect this gives warnings and won't build....

I don't know about the ifs , iam working too right now, but I would at least make sure that capacity_parm > 0 else you devide by zero and that's quite terminal. So add that one to the iff.

I miss a declaration for socval and netwh.

I would first build the method with int32's it's also possible to save the values with bigger resolution (as you know) 1000=100% etc.

Instead of doing math on many places i like to 'enrichen' the classes.
For example if you need the ISA reported in float add that method to the class itself and simply call it where you need it. It saves doing the same stuff on multiple places and if one day there is a change it's only needed tobe made on one place.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
jon volk
Posts: 572
Joined: Wed Apr 10, 2019 7:47 pm
Location: Connecticut
Been thanked: 2 times

Re: The ZombieVerter VCU Project

Post by jon volk »

FP is fixed point, not floating point.
Formerly 92 E30 BMW Cabrio with Tesla power
User avatar
chuuux
Posts: 68
Joined: Fri Mar 12, 2021 5:11 am
Location: Ural
Has thanked: 1 time

Re: The ZombieVerter VCU Project

Post by chuuux »

Give me some advice, please, how to check serial connection between ZombieVerter (ZV) and Camry AVV50 inverter.
First I wired all power, serial etc.and check - ZV and web interface work well. Get ZV to "Run" status, but Inverter is still "Off" and no data from it.
Then I used my tablet scope and check the serial pins. All in about 2.6V level, but I can't see any pulse. What should I check next?
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Have you selected GS450H from the inverter menu?
I'm going to need a hacksaw
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: The ZombieVerter VCU Project

Post by EV_Builder »

jon volk wrote: Wed Jun 09, 2021 3:55 pm FP is fixed point, not floating point.
:o :o :o :o
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
EV_Builder
Posts: 1199
Joined: Tue Apr 28, 2020 3:50 pm
Location: The Netherlands
Has thanked: 16 times
Been thanked: 33 times
Contact:

Re: The ZombieVerter VCU Project

Post by EV_Builder »

Dilbert wrote: Thu Jun 03, 2021 10:34 am Thanks for the feedback above, here is an updated version of the diagram.
The most simple form of what we need is a SWITCH CASE
and in EACH case we call the methods applicable to that state.

More is not needed i think.

We should use ENUMS for the switch comparison.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
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: The ZombieVerter VCU Project

Post by Jack Bauer »

Yep. From my_fp.h :

Code: Select all

#define FP_FROMINT(a) ((s32fp)((a) << CST_DIGITS))
#define FP_TOINT(a)   ((s32fp)((a) >> CST_DIGITS))
#define FP_FROMFLT(a) ((s32fp)((a) * FRAC_FAC))

#define FP_MUL(a, b) (((a) * (b)) >> CST_DIGITS)
#define FP_DIV(a, b) (((a) << CST_DIGITS) / (b))
I'm going to need a hacksaw
Locked