4. Eclipse Workspace Setup and Flashing

In this section, it is shown how to set up an Eclipse workspace to work with the foxBMS sources. Within the workspace, it is possible to flash the compiled sources on the foxBMS Master Unit.

4.1. Setting an Eclipse Workspace

Warning

Every part of this setup instruction must be read carefully and it must be followed step by step, including details. If not the case, the Eclipse Workspace will not work.

Warning

Only foxconda3 is supported. The support for older versions has been dropped.

In the following, it is described which requirements have to be fulfilled and what steps have to be made to setup an Eclipse workspace for working with the foxBMS sources.

Note

The following setup instructions use two variables which have to be adapted to the user’s settings. The example below shows how to adapt these two variables.

  • Variable 1: Project directory (path\to\foxbms)

    The proejct directory is foxbms, then the path has to be set to C:\Users\username\Documents. The path C:\Users\username\Documents\foxbms has to be used instead of path\to\foxbms. The path to the project directory must not contain spaces.

  • Variable 2: Path to foxconda3 installation (C:\foxconda3)

    • The prefered installation path of foxconda3 is C:\foxconda3. This path will be used during the setup. If this is changed, it is up to the reader to change it at time to the appropiate path. It is strongly recommended to install foxconda to C:\foxconda3.
    • If foxconda3 is installed into C:\foxconda3 some steps of these instructions can be skipped. These steps are indicated.

4.1.1. Requirements

The following requirements have to be fulfilled to be able to set up an Eclipse Workspace for working with the foxBMS sources.

  • foxconda3 is installed.

  • foxBMS source files are downloaded to path\to\foxbms. Getting the source files is described in section “Building the foxBMS Software and Documentation”.

  • Eclipse CDT , in version Oxygen.1.Release (4.7.1a). Eclipse CDT Oxygen.1.Release (4.7.1a) can be downloaded form eclipse.org. After downloading the .zip file and extracting it, eclipse.exe must be started to launch Eclipse CDT.

  • The following plugins must be installed into Eclipse CDT. PyDev (PyDev project website) is mandatory, while LiClipseText (LiClipseText project website) is optional. However it is recommended to install both plugins. The plugins can be installed from the Eclipse Marketplace.

    ../../_images/eclipse-marketplace.png

    Fig. 4.1 Eclipse Marketplace

    • Installing PyDev

      ../../_images/eclipse-marketplace-pydev.png

      Fig. 4.2 PyDev Eclipse plugin

      • Click ECLIPSEINSTALL to install the plugin.
    • Installing LiClipseText

      ../../_images/eclipse-marketplace-liclipsetext.png

      Fig. 4.3 LiClipseText Eclipse plugin

      • Click ECLIPSEINSTALL to install the plugin.

4.1.2. How to Setup the Eclipse Workspace

The setup process is divided into following parts:

The order of these steps must not be changed.

4.1.2.1. Creating the Workspace

The Eclipse Workspace will be called .ws.

  1. Start Eclipse and click File -> Switch Workspace -> other and configure path/to/foxbms/.ws as workspace, see Fig. 4.4.

    ../../_images/switch-workspace.png

    Fig. 4.4 Selecting the correct workspace location

  2. Click ECLIPSELAUNCH

OK The foxBMS Eclipse Workspace is now successfully created. OK

4.1.2.2. Configuring the Python Interpreter

  1. Open Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter.

    ../../_images/select-python-interpreter-1.png

    Fig. 4.5 Selecting the python interpreter

  2. Click ECLIPSENEW. In the window Select Interpreter use

    1. foxconda3 for the Interpreter Name
    2. C:\foxconda3\python.exe for Interpreter Executable.
    ../../_images/select-python-interpreter-2.png

    Fig. 4.6 Choosing the python interpreter name and executable

  3. Click ECLIPSEOK

  4. In menu Selection needed do not change anything and click ECLIPSEOK

    ../../_images/python-selection-needed.png

    Fig. 4.7 Adding the PYTHONPATH

  5. Click ECLIPSEAPPLYANDCLOSE

    ../../_images/python-configuration-done.png

    Fig. 4.8 Configuration done

OK foxconda3 is now successfully selected as Python interpreter. OK

4.1.2.3. Importing the Project

  1. Import the project via File -> Import

    ../../_images/eclipse-import.png

    Fig. 4.9 Select Import

  2. Click General -> Existing Projects into Workspace.

    ../../_images/setup-project-existing-projects-into-workspace.png

    Fig. 4.10 Select projects import by Existing Projects into Workspace

  3. Click ECLIPSENEXT

  4. Chose Select archive file: and use path/to/foxbms/tools/foxbms-eclipse-project.zip This will list the foxBMS projects.

    ../../_images/setup-project-import-projects.png

    Fig. 4.11 Select all projects to be imported

    Note

    Always import all projects that appear, as the number of projects might increase with future updates and this help might not be up-to-date.

  5. Click ECLIPSEFINISH to complete the project import process.

OK The foxBMS projects are now successfully imported. OK

4.1.2.4. Configuring the Project PATHs

Note

If foxconda3 was installed in the default installation path (C:\foxconda3), this section can be skipped.

For this setup: Change the path C:\foxconda3 to the path where foxconda3 was installed to.

  1. Select the Primary project and click right and select Properties.

    ../../_images/eclipse-project-properties.png

    Fig. 4.12 Eclipse project properties

  2. Goto C/C++ Build -> Environment. Select [All configurations]

    ../../_images/eclipse-project-properties-c-cpp-environment.png

    Fig. 4.13 C/C++ Build project properties

    1. Click ECLIPSEADD and

      1. use FOXCONDA3 for Name

      2. use C:\foxconda3; C:\foxconda3\bin; C:\foxconda3\Scripts; C:\foxconda3\Library\bin; C:\foxconda3\Lib; for Value.

        Warning

        • The Value property must not include spaces.
        • Do not add a backslash (\) at the end of the paths.
        • These paths need to be in a single line.
      3. Check Add to all configurations

      4. Click ECLIPSEOK

    2. Click ECLIPSEADD and

      1. Use PATH for Name
      2. Leave Value empty
      3. Click ECLIPSEOK
    3. Select the PATH entry and click ECLIPSEEDIT

      1. Delete all entries in Value
      2. Add ${FOXCONDA3}; to Value
      3. Click ECLIPSEOK

    The result should look like this:

    ../../_images/project-path-adding.png

    Fig. 4.14 Environment settings for the project.

  3. Repeat these steps for the following projects:

    • documentation
    • foxbms
    • secondary

OK The foxBMS projects now include the correct environment settings. OK

4.1.2.5. Configuring the Project Includes

Note

If foxconda3 was installed in the default installation path (C:\foxconda3), this section can be skipped.

For this setup: Change the path C:\foxconda3 to the path where foxconda3 was installed to.

  1. Select the primary project and click right. Goto C/C++ General -> Paths and Symbols and switch to Tab Includes.

  2. Click ECLIPSEADD for Assembly, GNU C and GNU C++ and configure the following two paths as Includes

    1. C:\foxconda3\Library\arm-none-eabi\include
    2. C:\foxconda3\Library\lib\gcc\arm-none-eabi\4.9.3\include
    ../../_images/include-header.png

    Fig. 4.15 Adding the gcc-includes to a project

    1. Click ECLIPSEAPPLYANDCLOSE
  3. Repeat this procedure for the secondary project.

  4. Restart Eclipse

OK The foxBMS projects are now successfully configured. OK

4.1.2.6. Testing the Project Setup

  1. foxbms project

    1. Select the foxbms project and click ECLIPSEHAMMER button and select 1 configure. The project is now configured and all options (building documentation and binaries) can now be used.

      'configure' finished successfully (0.450s)
      
    2. Select the foxbms project and click ECLIPSEHAMMER button and select 2 help. The project help for building is printed.

  2. documentation project

    1. Select the documentation project and click on the dropdown menu of the ECLIPSEHAMMER button and select 1 sphinx to build the general foxBMS documentation.

      'sphinx' finished successfully (0.105s)
      
    2. The Documentation project is now successfully tested.

  3. primary project

    1. Select the primary project and click on the dropdown menu of the ECLIPSEHAMMER button and select 1 build_primary to build the foxBMS binaries of the primary mcu.

      The binary generation was successful, if the Eclipse console puts the following line at the bottom:

      'build_primary' finished successfully (1.340s)
      
    2. Select the primary project and click on the dropdown menu of the ECLIPSEHAMMER button and select 2 doxygen_primary to build the foxBMS embedded documentation of the primary mcu.

      The primary mcu dopxygen documentation generation was successful, if the Eclipse console puts the following line at the bottom:

      'doxygen_primary' finished successfully (46.906s)
      
    3. Select the primary project, right click the project and select Clean Project

      The cleaning of the primary mcu binaries and doxygen documentation was successful, if the Eclipse console puts the following line at the bottom:

      'clean_primary' finished successfully (1.065s)
      
    4. The primary project is now successfully tested.

  4. secondary project

    1. Select the secondary project and repeat all steps of the primary project.
    2. The secondary project is now successfully tested.

OK The foxBMS Eclipse Workspace is now successfully tested. OK

Warning

To test flashing in the next step, binaries of the primary and secondary mcu need to be build again.

4.1.3. Optional Settings

When working with the build scripts (wscript) it is more convenient to have python syntax highlighting. The following has to be configured to achieve it:

  1. Click Window -> Preferences

  2. Select General -> Editors -> File Associations

  3. At the entry File types click ECLIPSEADD

    ../../_images/syntax-highlighting-wscript-1.png

    Fig. 4.16 File Associations settings

  4. Define the file type wscript and click ECLIPSEOK

    ../../_images/syntax-highlighting-wscript-2.png

    Fig. 4.17 File type definition

  5. Select the Python Editor as and click ECLIPSEOK

    1. ../../_images/syntax-highlighting-wscript-3.png

      Editor Selection setting

  6. Finish the configuration by clicking ECLIPSEAPPLYANDCLOSE

    ../../_images/syntax-highlighting-wscript-4.png

    Fig. 4.19 Final file association setting for wscript

4.2. Flashing foxBMS

This section describes how to supply the foxBMS Master Unit in order to flash both MCU0 and MCU1 with the firmware produced by compiling the C-code source files.

This section shows how to connect the different parts of the foxBMS platform.

4.2.1. Convention for Connector Numbering

Fig. 4.20 presents the convention for the connector numbering. It is used throughout the documentation.

../../_images/connector_viewing_direction2.png

Fig. 4.20 Supply connector pin out, receptable - rear view, header - front view (image source: MOLEX)

There are two types of connectors:

  • Header
  • Receptable, plugged into the header

The numbering shown on the left in fig. 4.20 is always valid when viewing in the direction indicated by the arrow with the indication viewing direction. This must be taken into account when crimping the receptables.

4.2.2. Hardware Setup of foxBMS Master Unit and foxBMS Slave Units

The foxBMS system can be mounted in a metal housing, as shown in fig. 4.21.

../../_images/foxbms_housing1.jpg

Fig. 4.21 foxBMS Master Unit housing

Connectors are available, shown in Fig. 4.22, which presents all the connectors of the foxBMS Master Unit.

../../_images/foxbms-frontplate-rotated2.png

Fig. 4.22 Front view of the foxBMS Master Unit indicating the location of each header

For this section on flashing, only the connector Supply is needed.

4.2.3. Supply of the foxBMS Master Unit

The first step is to supply the foxBMS Master Unit, which works with supply voltages between 12V and 24V DC. To supply the foxBMS Master Unit, a connector must be prepared for the Supply connector as shown in table 4.1, which describes the different pins used.

../../_images/connector_6pin1.png
Table 4.1 BMS-Master Board Supply Connector
Pin Signal Input/Output Description
1 SUPPLY_EXT_2 Input 12 - 24V
2 SUPPLY_EXT_2 Input 12 - 24V
3 GND_EXT_2 Input GND
4 SUPPLY_EXT_0 Input 12 - 24V
5 GND_EXT_0 Input GND
6 GND_EXT_2 Input GND

The supply is separated as follows:

  • The microcontrollers and the isolation devices are supplied through the pins SUPPLY_EXT_0 and GND_EXT_0
  • The contactors and the interlock are supplied through the pins SUPPLY_EXT_2 and GND_EXT_2

To power up the foxBMS Master Unit, plug in the supply connector and apply a voltage between 12V and 24V. SUPPLY_EXT_0 / GND_EXT_0 and SUPPLY_EXT_2 / GND_EXT_2 may be connected to the same source for this initial test. At this point, the foxBMS Master Unit should draw approximately 150mA at 12V or 110mA at 24V.

4.2.4. Primary and Secondary MCU

The BMS-Master Board has two MCUs: primary (MCU0) and secondary (MCU1). The MCU1 is present to ensure redundant safety especially when used in research and development prototyping.

First, the primary MCU will be flashed.

In order to program the primary MCU, the mini USB jack indicated as Prim. USB in fig. 4.22 must be used to connect the foxBMS Master Unit to a PC. The foxBMS Master Unit can be connected to a PC immediately. When connecting foxBMS Master Unit for the first time, the required drivers will install automatically.

Note

Before the connection is made between the foxBMS Master Unit and the computer for the first time, the computer must be connected to the internet, because the operating system might look for drivers on the internet. It this fails, administrators right are needed to install the driver.

In case of problems by the installation of the drivers, administrator rights might be needed. Once the hardware is supplied with the appropriate voltage, the foxBMS binaries can be flashed.

The same procedure must be made for secondary: the mini USB jack indicated as Sec. USB in fig. 4.22 must be used to connect the foxBMS Master Unit to a PC. As for the primary MCU, the PC must be connected to the internet before the connection is made with the foxBMS Master Unit for the first time.

4.2.5. Flashing the Compiled Sources for the Primary MCU

In the chapter Building the foxBMS Software and Documentation, the foxBMS sources have been compiled and the generated binary is ready to be flashed. The MCU0 will be flashed first.

These binaries are needed:

  1. a binary file with the header
  2. a binary file with the main code

Unless the build process has been altered or different binaries should be flashed, there is no need to change the default file locations. For this guide, the default file locations are used.

The device must be connected to the computer with the USB cable. The MCU0 USB-connector must be used. The primary project must be select. Clicking on the dropdown menu of the ECLIPSEHAMMER button and selecting 3 flash_primary allows flashing the foxBMS binaries of the primary mcu.

Note

Make sure that CAN0 connector is either disconnected or that there is no traffic on CAN0 bus while flashing primary MCU. If this is not the case, the internal bootloader of the controller will select a wrong boot source and the flashing fails.

The connection state can also be checked by watching the LEDs on the foxBMS Master Unit hardware: for a running board, the green power LED is on, and the two indicator LEDs (green and red) are blinking alternately. If the device is connected and being flashed, the power-on LED is on but the two indicator LEDs are off.

The LEDs for the MCU0 must be used. In the Cabling foxBMS, it is explained how to find the MCU0 indicator LEDs.

When the flashing is complete, the flashing windows disappears and the indicator LEDs start to blink again.

Under Windows 7 (64 bit), it can happen that the COMPORT number is increased by Windows, leading to problems during flashing. This can be reset in registry, by setting ComDB to zero in the entry HKEY_LOCAL_MACHINE::SYSTEM::CURRENT_CONTROL_SET::CONTROL::COM NAME ARBITER. This way, all COM ports used are reset.

4.2.6. Flashing the Compiled Sources for the Secondary MCU

The same procedure as explained above must be followed for the MCU1. The difference is that the MCU1 USB-connector must be used. The secondary project must be selected before clicking on the dropdown menu of the ECLIPSEHAMMER button. 3 flash_secondary must then be selected to flash the foxBMS binaries of the secondary mcu.

With the supplied code, the MCU1 checks the temperatures and voltages. If one or more of the values are outside the limits, the MCU1 opens the interlock line (thus opening the contactors). The interlock line remains open until the MCU1 is reset.

Note

Setting the limits is safety relevant and must be done with care.

Note

Working without configuring the right battery cell voltage limits is dangerous and should never be done when real batteries are connected, since they may burn and explode when overcharged or shorted.

The next step shown in Cabling foxBMS is to connect a foxBMS Slave Unit to perform voltage and temperature measurement.

4.2.7. Debugging the Primary and Secondary MCU

The following two debuggers can be used for debugging and have been tested with foxBMS: