BMW S-Box Phev (SafeyBox 9846612)

Viewtop1
Posts: 11
Joined: Wed Sep 14, 2022 9:07 am
Has thanked: 3 times

BMW S-Box Phev (SafeyBox 9846612)

Post by Viewtop1 »

I have a S-Box on my desk bought from a Breakers. Trying to play with it but I don't currently have a high Voltage Battery.

I tried the code from Damiens Github, that the Wiki links to, but this code fails to compile since crc.h is and I assume crc.c is not included in the repo. ( I am also using a ESP32 not a Due)


Fine, So I go to STM32VCU, grab the lookup table and modify away. ( I also found a CRC8 Maxim routine that appears to spit out the correct answers, especially as compared to some online CRC Calculators.)

So, I hook up the Battery+ and + terminals to 12V, and the Data Connector 12V , GND CANH CANL.

The box spits out can messages matching 12V battery, but none of the contactors will close. No this is either my CRC being wrong or perhaps the Voltage is too low. At this stage I have no way to get a higher voltage.

Does anyone know if the S-BOX has a min cut-off voltage at which point it refuses to switch?
Is it possible to test the S-BOX using just the Data Connector (PWR and CAN signals)? Any one with info to assist would be great.


Terminal Output of Sbox data
****************************
Battery Current: -1.00mA
Battery Voltage: 13.20V
Output Voltage: 0.32V
**************************
(PSU is Set to 13.2V
Viewtop1
Posts: 11
Joined: Wed Sep 14, 2022 9:07 am
Has thanked: 3 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Viewtop1 »

Solved.
There is no, Voltage cutoff. My CAN routine was sending garbage... Whoops. Clicking away nicely now.
Mhs
Posts: 46
Joined: Fri Jul 26, 2019 8:06 pm
Location: Bahrain
Has thanked: 135 times
Been thanked: 7 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Mhs »

Viewtop1 wrote: Mon Jun 19, 2023 12:02 am Solved.
There is no, Voltage cutoff. My CAN routine was sending garbage... Whoops. Clicking away nicely now.
Hello, do you mind sharing the ESP32 code that you are using? I have the Sbox around and would like to test it as well
Prius gen3 inverter
Outlander rear motor
Pajero 1990
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

so I took a stab at this myself, both using an Arduino Due with a CAN Bus transceiver and also the Lexus GS450h ver 2 VCU (pre ZombieVerter hardware)

IMG_9450.JPG
IMG_9450.JPG (27.86 KiB) Viewed 5968 times
IMG_4654.JPG
IMG_4671.JPG
IMG_4679.JPG
IMG_4760.JPG




"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

I could really use your help, I have noticed the S-Box intermittently reporting some quirky things, for example with it just powered on, (both contactors still opened) it sometimes shows volts as high as 16,777.20V

now I have been informed that's because it is a signed value in an unsigned int, but aside from GOOGLing that one can hold negative numbers and the other one can't I'm more confused than a blind goat on astroturf and could greatly benefit from your tutelage and really just wanna know how to fix it, ha ha

S-Box reporting high volts - arrow.jpg
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
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: BMW S-Box Phev (SafeyBox 9846612)

Post by EV_Builder »

Can you post a piece of code of that variabele? And especially where it's written too?
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

EV_Builder wrote: Sun Jul 30, 2023 7:38 am Can you post a piece of code of that variabele? And especially where it's written too?
thank you for taking interest, and offering to help, the variable appears to be called: OutputVoltage and is mentioned three times in the code


first it is defined like so in what I would call the Global Definitions Section

float OutputVoltage=0;





later on it appears in the void CheckRecCan()

else if(inFrame.id ==0x220)
{
OutputVoltage=((inFrame.data.bytes[2]<<16)| (inFrame.data.bytes[1]<<8)| (inFrame.data.bytes[0]))*0.001;

}





and lastly in the void ShowRecData()

SerialDEBUG.print("Output Voltage: ");
SerialDEBUG.print(OutputVoltage);
SerialDEBUG.println("V");
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
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: BMW S-Box Phev (SafeyBox 9846612)

Post by EV_Builder »

A float is quite flexible I think something else is going on....
Normally a float is 4 bytes; in the code i only see 3 being Processed.

I think you should try adding the 4th and maybe the value is just below zero sometimes....

To test you add byte nr [3] and you shift left (<<24).

If you need more help just post. The assignment is the place to check.
Converting an Porsche Panamera
see http://www.wdrautomatisering.nl for bespoke BMS modules.
royhen99
Posts: 211
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 16 times
Been thanked: 101 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by royhen99 »

Zombieverter code uses int32_t for Voltage and sign extends from 24 bit value to 32 bit.

Voltage=((bytes[2] << 16) | (bytes[1] << 8) | (bytes[0]));
Voltage = (Voltage<<8) >> 8; // sign extend

you could then convert to float with the multiplication by 0.001
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

EV_Builder wrote: Sun Jul 30, 2023 5:09 pm A float is quite flexible I think something else is going on....
Normally a float is 4 bytes; in the code i only see 3 being Processed.

I think you should try adding the 4th and maybe the value is just below zero sometimes....

To test you add byte nr [3] and you shift left (<<24).

If you need more help just post. The assignment is the place to check.
I'm sorry this is Greek to me, if you could actually modify the code I posted above with this change I would really appreciate it
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

royhen99 wrote: Sun Jul 30, 2023 7:02 pm Zombieverter code uses int32_t for Voltage and sign extends from 24 bit value to 32 bit.

Voltage=((bytes[2] << 16) | (bytes[1] << 8) | (bytes[0]));
Voltage = (Voltage<<8) >> 8; // sign extend

you could then convert to float with the multiplication by 0.001
thank you, however I am not sure if you left off the assignment part in your example cause I am a total newb and you are assuming I know how to assign a int32_t, lol

as far as the two lines of code you provided, then the top line is essentially the same to the code I have, the second line is what I will add to my code to extend from 24 bit value to 32 bit
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
royhen99
Posts: 211
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 16 times
Been thanked: 101 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by royhen99 »

Zombieverter declares Voltage in the header file so you will need to declare in your code, int32_t Voltage.
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

royhen99 wrote: Fri Aug 11, 2023 6:23 pm Zombieverter declares Voltage in the header file so you will need to declare in your code, int32_t Voltage.
with a big help from a friend, I think we got it working, using your advice, thank you so much, here is the code:


int32_t ov;
ov=((inFrame.data.bytes[2]<<16)| (inFrame.data.bytes[1]<<8)| (inFrame.data.bytes[0]));
ov = (ov<<8) >> 8; // sign extend
OutputVoltage = (float)ov * 0.001;
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
Viewtop1
Posts: 11
Joined: Wed Sep 14, 2022 9:07 am
Has thanked: 3 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Viewtop1 »

Does anyone know if the ZombieVerter VCU can use the BMW S-Box to replace the IVT Shunt yet?
The SBOX is nice and compact solution for Precharge and Contactors and they cost less than the IVT Shunt.
I am in the gathering parts phase now.
Thanks
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

just wanted to share some symptoms of a bad BMW 530e Safety Box 15 OHM resistor


Good Resistor Reading: 15 ohms
IMG_6774.JPG


Bad Resistor Reading: 1 million ohms
IMG_6776.JPG
IMG_6778.JPG

"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
m.art.y
Posts: 558
Joined: Sat Jun 06, 2020 6:54 pm
Location: UK
Has thanked: 28 times
Been thanked: 16 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by m.art.y »

Anybody knows what Amps are the contactors/fuse rated for in an S Box? Some sources seem to suggest 120A which is rather low. In that case what would be the amp range that the internal current sensor could measure?
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

m.art.y wrote: Tue Aug 29, 2023 5:22 pm Anybody knows what Amps are the contactors/fuse rated for in an S Box? Some sources seem to suggest 120A which is rather low. In that case what would be the amp range that the internal current sensor could measure?
the fuse is 350A, the resistor is 15 OHMs, maybe the Panasonic contactor part number AEV14012 below will help you find the specs
IMG_8114.JPG
IMG_8120.JPG
IMG_8157.JPG
IMG_8155.JPG
IMG_8328.JPG
IMG_8330.JPG
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

those of you who follow The Greg's 1971 GMCe Lexus GS450H BMW 530e Tesla Model S powered Electruck [FIRST DRIVE] build, know that his latest past time is welding these Panasonic contactors found in the BMW Safety Box

so he decided to take one for the team and went out and purchased an extra one on eBay for $12 bucks, same AEV14012 part number but... (yes knowingly he bought one the wrong size, aka "shorty")

so does anybody know what the M25 vs M19 designation refers to?

IMG_7262.JPG
IMG_7266.JPG
IMG_7268.JPG
IMG_7272 labeled.jpg
IMG_7274.JPG
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
User avatar
Ev8
Posts: 801
Joined: Sat Jan 30, 2021 11:05 am
Has thanked: 41 times
Been thanked: 149 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Ev8 »

Look an awful lot like the Prius ones in using for the chademoImage
Attachments
IMG_3195.jpeg
Mhs
Posts: 46
Joined: Fri Jul 26, 2019 8:06 pm
Location: Bahrain
Has thanked: 135 times
Been thanked: 7 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Mhs »

Gregski wrote: Sat Sep 02, 2023 5:17 pm so does anybody know what the M25 vs M19 designation refers to?
I read somewhere (I can't seems to find it) that the number refers to the model and the physical layout, but technically they are identical
Prius gen3 inverter
Outlander rear motor
Pajero 1990
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

I would love to hear from people who are running this Safety Box with Damien's code from his GitHub, does the Current reading work for you while driving the vehicle? Mine does not, not in the Serial Monitor on my laptop and not on my Nextion display.

here is a pic of a really dumbed down Nextion display showing three things:

1. Current in Amps from the Safety Box (this never changes)
2. Output Voltage from the Safety Box
3. Temperature from the Inverter

in the Arduino sketch in the void Loop() I have to write this to the Nextion display every 2 seconds or else my Inverter does not work if I just let the loop run every second by default
IMG_7802.JPG
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
royhen99
Posts: 211
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 16 times
Been thanked: 101 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by royhen99 »

I think the calculation is wrong, should be like below ( calculation taken from Zombieverter code ).
BattCurrent is int32_t with current in mA, you may want to convert to amps and float in a similar way to the voltage

BattCurrent=((inFrame.data.bytes[2]<<16)| (inFrame.data.bytes[1]<<8)| (inFrame.data.bytes[0]));
BattCurrent = (BattCurrent<<8) >> 8;//sign extend

If you change the baud rate of the Nextion display you maybe able to update more often. Instructions here. https://forum.arduino.cc/t/nextion-baud ... e/560081/2
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

royhen99 wrote: Wed Sep 13, 2023 6:35 am I think the calculation is wrong, should be like below ( calculation taken from Zombieverter code ).
BattCurrent is int32_t with current in mA, you may want to convert to amps and float in a similar way to the voltage

BattCurrent=((inFrame.data.bytes[2]<<16)| (inFrame.data.bytes[1]<<8)| (inFrame.data.bytes[0]));
BattCurrent = (BattCurrent<<8) >> 8;//sign extend

If you change the baud rate of the Nextion display you maybe able to update more often. Instructions here. https://forum.arduino.cc/t/nextion-baud ... e/560081/2
thank you that did it, here is my actual code:



if (inFrame.id == 0x200) {
int32_t bc;
bc= ((inFrame.data.bytes[2] << 16) | (inFrame.data.bytes[1] << 8)| (inFrame.data.bytes[0]));
bc = (bc<<8) >> 8;//sign extend
BattCurrent = (float)bc * 0.001;
}






Why are the numbers negative?


"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
royhen99
Posts: 211
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 16 times
Been thanked: 101 times

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by royhen99 »

I assume it's just the convention that BMW has chosen, ( +ve = charge, -ve = discharge ). Easy enough to add a "-" somewhere so it displays as positive.
User avatar
Gregski
Posts: 2271
Joined: Tue Sep 14, 2021 10:28 am
Location: Sacramento, California
Has thanked: 327 times
Been thanked: 449 times
Contact:

Re: BMW S-Box Phev (SafeyBox 9846612)

Post by Gregski »

royhen99 wrote: Wed Sep 13, 2023 3:37 pm I assume it's just the convention that BMW has chosen, ( +ve = charge, -ve = discharge ). Easy enough to add a "-" somewhere so it displays as positive.
gotcha, fixed it with the abs Arduino function, once again a huge thanks for your help

IMG_7880.JPG
"I don't need to understand how it works, I just need to understand how to make it work!" ~ EV Greg
Post Reply