BMS & MBDT - MC33771B/MC33772B SPI communication with S32K

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

BMS & MBDT - MC33771B/MC33772B SPI communication with S32K

BMS & MBDT - MC33771B/MC33772B SPI communication with S32K

1. Introduction

This article details the SPI communication setup between S32K1xx boards and MC3377xBSPI Battery Cell Controllers. It covers both hardware and software setup for the Battery Management System models designed using Model-Based Design Toolbox for battery packs up to 14 cells in series.  At the end of this article, the user will be able to setup the Battery Cell Controller hardware and to design a Simulink model that reads the cell and pack voltages, current, temperatures and faults status. The measured values will be displayed on the host PC using FreeMaster. 

2. Hardware

MC3377xBSPI is a Battery Cell Controller family that manages battery packs up to 14 Li-Ion cells in series. The BCC (Battery cell Controller) communicates with the main MCU over the classic SPI communication.

 This Batter Cell Controller comes in two derivatives.

  • MC33771BSPI – can handle 7 up to 14 cells
  • MC33772BSPI – can handle 3 up to 6 cells

Even though the hardware setup is very similar for both derivatives and we could detail the setup only for one of them, we will mention the hardware parts and settings for each of the derivatives.

 2.1.1 MC33771BSPI (7 up to 14 cells battery pack) Setup

mariuslucianand_0-1600076940629.jpeg

 

  1. S32K144EVB
  2. FRDM33771BSPIEVB + connectors
  3. BATT-14EMULATIOR + ribbon cable
  4. microUSB cable (for S32k) + 12V power supply (for Battery emulator)

Before going to the next step, the solder jumpers for the FRDM33771BSPIEVB board must be configured in order to make it compatible with the S32K144EVB. This process is detailed both in the UM1143 [4.1] Table 1 or  User-Guide [4.2] Table 16. Jumper setting to work with S32K144EVB. The JP26 & JP36 must be unsoldered while the JP27 (1-2), JP37 (1-2), JP39(2-3) and JP43(2-3) must be resoldered. Without these settings, the communication on the EVBs will be unsuccessful.

2.1.2 MC33772BSPI (3 up to 6 cells battery pack) Setup

mariuslucianand_1-1600076941222.jpeg

  1. S32K144 EVB
  2. FRDM33772BSPIEVB + connectors
  3. BATT-6EMULATOR + ribbon cable
  4. microUSB cable (for S32k) + 12V power supply (for Battery emulator)

Before going to the next step, the solder jumpers for the FRDM33772BSPIEVB board must be configured in order to make it compatible with the S32K144EVB. This process is detailed both in the UM1143 [4.1] Table 3 or  User-Guide [4.3] Table 11. Jumper setting to work with S32K144EVB. The J26 & J36 must be unsoldered while the J27 (1-2), J37 (1-2),  JP30(2-3) and JP31(2-3) must be resoldered.  Without these settings, the communication on the EVBs will be unsuccessful.

2.2 Hardware connection

This step is common for both cases presented in the previous chapter. Before following the next steps, be sure that your board has all the jumpers soldered correctly as described previously.

  1. First, you have to attach the double connectors that come with the MC3377xBSPI boards to the S32K evaluation board. You will notice that the BCC board is smaller than the S32KEVB, so the external connectors row of the BCC board will align to the internal rows of the S32K evaluation board. The following two images describe the connection setup. The FRDM3377xBSPIEVB.J9 aligns with the S32K144EVB.J3 (J9.2 with J3.1)

mariuslucianand_2-1600076941847.jpeg

 

mariuslucianand_3-1600076942269.jpeg

 

  1. Connect the Battery Emulation board with the FRDM3377xBSPIEVB via the ribbon cable provided in the same box with the BATT-xEMULATOR board.
  2. Power up the BATT-xEMULATOR board with the 12V via a power jack of 3.5mm
  3. Connect the S32K144 EVB via the micro USB cable to the PC.

Be aware that the MC3377xB chip is powered up by the cells, in our case the Emulator. The emulator has to be powered up in order to have successfully communication between the BCC and the main MCU. The final setup will look like this.

mariuslucianand_4-1600076943049.jpeg

3. Software

In this section, we are going to detail the settings of the blocks required to configure and achieve data from the battery cell controller, connected over the SPI peripheral.

3.1 General/Boards Configuration Blocks

mariuslucianand_5-1600076943083.png

 

For all the models that generate code for the S32K1xx microcontrollers, the MBD_S32K1xx_Config_Information must be added inside the model. In this block, the user selects the controller for which Simulink will generate code, the compiler, and the deploying way of the generated code on the target.

The FreeMaster Config block needs to be added in the model to configure the FreeMaster and the peripheral used for communication, between UART or CAN. For this model, we are going to use the LPUART 1 peripheral.

3.2 Battery Cell Controller Configuration Blocks

mariuslucianand_6-1600076943107.png

 

To accomplish a successful communication between the S32K and MC3377xBSPI block we firstly must add an LPSPI Configuration block in our model. This will initialize the LPSPI peripheral and will configure the pins selected for the communication. For this application, we can select only the right pins for the LPSPI and leave the communication parameters default. In the MC3377xB_Config block, there is a button that, once pressed, will set the right parameters for the BCC communication in the LPSPI Config Block.

The MC3377xB_Config block initializes the Battery Cell Controller.

mariuslucianand_7-1600076943145.png

mariuslucianand_8-1600076943191.png

 

In the Configuration TAB, the user must choose the communication mode (SPI/TPL), the device type (MC33771B/MC33772B), and the Cell number connected to the Battery Cell Controller.

The SPI tab refers to the LPSPI peripheral. In the case of the SPI communication mode, only one LPSPI instance is required. The dropdown options will be populated only after one of the LPSPI Configuration blocks were added to the model displaying their instance number. Here the user must set the Chip Select pin number that is going to be used for BCC selection during communication. If the user presses on the “Config for BCC as Master” button, then the right values will be set in the LPSPI Config block.

mariuslucianand_9-1600076943230.png

The last tab lets the user specify the NTC thermistors characteristics and the shunt resistance value. These values are used by the MC3377xB_GetValues block, to automatically convert the RAW values, provided by the Battery Cell Controllers into values delivered in common measure units like Amps and *C. If the user wants to read only the RAW values and not to automatically convert the block, this tab must be ignored.

3.3 Measurements

In this section, we are going to detail two modes in which the values converted by the Battery Cell Controllers can be transferred to the main MCU via the SPI connection.

mariuslucianand_10-1600076943390.png

 

The first method uses MC3377xB_Get_Values Block. As you can see in the previous image, this block returns all the measured values directly in Volts, Amps, and degrees Celsius. The conversions from RAW values are based on the parameters inserted in the Pack Settings tab of the MC3377xB_Config. The Cells Voltage returns always a 14 uint32 array, the maximum cells number. The user must ignore the values that are not used. The same scenario is applied for the NTC Temperatures because the MC3377xB can measure up to 7 thermistors.

mariuslucianand_11-1600076943415.png

 

The MC3377xB_Get_Values block has the following options:

  1. CID – this selects the BCC number that will provide the values.
  2. Send Start Conversion Command for the requested CID – if this option is checked, then the block will insert automatically the code that will send the start conversion command and waits until the conversions are performed.  If the checkbox is not checked, then the block will only read and converts the values.

mariuslucianand_12-1600076943490.png

For reading the raw values, then the following approach can be used.

  1. Start the conversion using the MC3377xB_Start_Conversion block for initializing the ADC conversions.
  2. Then, the application needs to wait until the conversion is done. For this, the dedicated MC3377xB_Is_Converting block must be used. Below there is the content of the WHILE body, using the MC3377xB_Is_Converting.

mariuslucianand_13-1600076943574.png

  1. Now that the conversion is complete, we need to read the raw values from the BCC controller. The block MC3377xB_Get_Raw_Values returns a 30 UINT16 values array that contains all the measured values. For the MC33772B, the block will return still 30 values, all the cells from 7 to 14 voltage raw values will be 0.

3.4 Faults reading

mariuslucianand_14-1600076943616.png

 

The Battery Cell Controller monitors have fault status registers in which notifies unusual behavior. Getting the Fault status values to the microcontroller is possible using the MC3377xB_Fault_Get_Status. This will return an 11 uin16_t array containing the fault status registers. The understand the error flags from the registers please have a look at the MC3377xB Reference Manual.

3.5 Status outputs

 

mariuslucianand_15-1600076943636.png

As you have probably noticed already, each of the blocks has an output called Status. This output provides the status output for the current operation. It can notify the user regarding if the transfer is not successful, either if the SPI instance is busy, or there is a timeout, communication CRC error or the communication is successful and there is no error. All the error values are detailed in each of the blocks Help page.

4. Examples and Validation

This article comes with the examples described above. Running the models on your setup could be a good starting point for your project. Once the code has been successfully generated and deployed on the target, the FreeMaster can be connected to the board via UART and the values can be monitored on the Host PC, just like in the application below.

mariuslucianand_16-1600076944321.jpeg

5. Resources

5.1. UM 1114 https://www.nxp.com/webapp/Download?colCode=UM11143&location=null

5.2. FRDM33771BSPIEVBUG https://www.nxp.com/docs/en/user-guide/FRDM33771BSPIEVBUG.pdf 

5.3. FRDM33772BSPIEVBUG https://www.nxp.com/docs/en/user-guide/FRDM33772BSPIEVBUG.pdf 

5.4. S32K144 EVB https://www.nxp.com/design/development-boards/automotive-development-platforms/s32k-mcu-platforms/s3... 

添付
100%が役に立ったと言っています (4/4)
バージョン履歴
最終更新日:
‎02-24-2021 01:46 AM
更新者: