Skip to content

Commit 2c3b5d0

Browse files
committed
Initial commit of fs-2 bms code
- Update bms code from fs-1 to use mbed os - Add TartanLlama/optional library for bms - Add readme with mbed workflow
0 parents  commit 2c3b5d0

17 files changed

+1290
-0
lines changed

.gitignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
*.py[cod]
2+
3+
# Distribution dir
4+
dist
5+
6+
# MANIFEST file
7+
MANIFEST
8+
doxygen_objdb_*
9+
10+
# Private settings
11+
mbed_settings.py
12+
13+
# Default Build Directory
14+
.build/
15+
BUILD/
16+
.mbed
17+
venv/
18+
19+
# Mbedls
20+
.mbedls-mock.lock
21+
22+
# Eclipse Project Files
23+
.cproject
24+
.project
25+
.pydevproject
26+
27+
# C extensions
28+
*.so
29+
30+
# Packages
31+
*.egg
32+
*.egg-info
33+
dist
34+
build
35+
eggs
36+
parts
37+
bin
38+
var
39+
sdist
40+
develop-eggs
41+
.installed.cfg
42+
43+
# Installer logs
44+
pip-log.txt
45+
46+
# Unit test / coverage reports
47+
.coverage
48+
.tox
49+
nosetests.xml
50+
.cache
51+
.hypothesis
52+
53+
# Translations
54+
*.mo
55+
56+
# Mr Developer
57+
.mr.developer.cfg
58+
59+
output.txt
60+
uVision Project/
61+
62+
# Sublime Text Project Files
63+
*.sublime*
64+
65+
*.bak
66+
debug.log
67+
68+
# Ignore OS X Desktop Services Store files
69+
.DS_Store
70+
71+
# Orig diff files
72+
*.orig
73+
74+
# PyCharm
75+
*.idea
76+
77+
# Cscope
78+
cscope.*
79+
80+
# Ctags
81+
tags
82+
83+
# vim swap files
84+
*.swp
85+
*~
86+
87+
# Visual Studio Code
88+
.vscode/
89+
90+
features/FEATURE_BLE/targets/TARGET_CORDIO/stack_backup/
91+
92+
.pytest_cache
93+
log
94+
95+
# Icetea related file
96+
test_suite.json
97+
98+
# default delivery dir
99+
DELIVERY/

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# FS-2
2+
3+
This repo contains all the software for the fs-2 racecar running on mbed os 5 on the LPC1768 microcontroller.
4+
5+
## Projects
6+
7+
- `bms`: LTC6811-based bms code for use with the fs-2 accumulator
8+
9+
## Workflow
10+
11+
The workflow should be used as follows.
12+
13+
### Git
14+
15+
Features/fixes can only be added with a pull request. Branches should be named as follows.
16+
17+
- Fix: `fix/<short description>`
18+
- Feature: `feature/<short description>`
19+
20+
### Required tools
21+
- [mbed cli](https://github.com/ARMmbed/mbed-cli)
22+
- [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm)
23+
- Ubuntu/Debian: `gcc-arm-none-eabi`
24+
- Brew: `gcc-arm-embedded`
25+
- Nix: `nixpkgs.gcc-arm-embedded`
26+
- A unix shell
27+
28+
### Installing dependencies
29+
30+
A project's dependencies can be installed by running the following command in the project folder.
31+
32+
```
33+
mbed update
34+
```
35+
36+
This will produce warnings about not using source control management. These can be safely ignored.
37+
38+
### Compiling
39+
40+
A project can be compiled using
41+
42+
```
43+
mbed compile
44+
```
45+
46+
or if you wish to flash the board after compiling
47+
48+
```
49+
mbed compile -f
50+
```
51+
52+
### Connecting to serial terminal
53+
54+
All of our boards use a rate of 115200 baud.
55+
56+
```
57+
mbed sterm -b 115200
58+
```
59+
60+
### Adding libraries
61+
62+
Libraries can be added to a project using
63+
64+
```
65+
mbed add <url>
66+
```
67+
68+
then the corresponding directory should be added to the `.gitignore` in the project's directory.
69+
70+
### All other issues
71+
72+
For any other issues see the [mbed cli documentation](https://os.mbed.com/docs/mbed-os/v5.15/tools/working-with-mbed-cli.html).

bms/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mbed-os
2+
optional

bms/.mbedignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
optional/tests/

bms/mbed-os.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/ARMmbed/mbed-os/#565ab149819481224ab43f878c3921b14b11d180

bms/mbed_app.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"target_overrides": {
3+
"LPC1768": {
4+
"platform.stdio-baud-rate": 115200,
5+
"platform.default-serial-baud-rate": 115200
6+
}
7+
}
8+
}

bms/optional.lib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/TartanLlama/optional/#0dfc7b4e41b1245e47936d6c99bf8e3d80e42b9f

bms/src/BmsConfig.h

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#pragma once
2+
3+
#include "mbed.h"
4+
5+
extern Serial* serial;
6+
7+
// TODO: So there's an issue here.
8+
9+
// BMS Master Configuration
10+
11+
#define BMS_BANK_COUNT 1
12+
#define BMS_BANK_CELL_COUNT 7
13+
#define BMS_BANK_TEMP_COUNT BMS_BANK_CELL_COUNT
14+
15+
#define BMS_FAULT_TEMP_THRESHOLD_HIGH 55
16+
#define BMS_FAULT_TEMP_THRESHOLD_LOW 0
17+
18+
// Threshold when fault will be thrown for cell voltage
19+
//
20+
// Units: millivolts
21+
#define BMS_FAULT_VOLTAGE_THRESHOLD_HIGH 4200
22+
#define BMS_FAULT_VOLTAGE_THRESHOLD_LOW 2550
23+
24+
// Threshold when cells will be discharged when discharging is enabled.
25+
//
26+
// Units: millivolts
27+
#define BMS_DISCHARGE_THRESHOLD 15
28+
29+
// IO Configuration
30+
31+
/*
32+
#define LINE_BMS_FLT PAL_LINE(GPIOB, 0)
33+
#define LINE_BMS_FLT_LAT PAL_LINE(GPIOF, 1)
34+
#define LINE_IMD_STATUS PAL_LINE(GPIOF, 0)
35+
#define LINE_IMD_FLT_LAT PAL_LINE(GPIOA, 8)
36+
#define LINE_CHARGER_CONTROL PAL_LINE(GPIOB, 1)
37+
#define LINE_SIG_CURRENT LINE_ARD_A0 // => (GPIOA, 0)
38+
39+
// SPI Configuration
40+
41+
#define BMS_SPI_DRIVER SPID1
42+
#define BMS_SPI_CR1 (SPI_CR1_BR_2 | SPI_CR1_BR_1) // Prescalar of 128
43+
#define BMS_SPI_CR2 (SPI_CR2_DS_2 | SPI_CR2_DS_1 | SPI_CR2_DS_0) // 8 bits data
44+
45+
#define LINE_SPI_MOSI PAL_LINE(GPIOA, 7)
46+
#define LINE_SPI_MISO PAL_LINE(GPIOA, 6)
47+
#define LINE_SPI_SCLK PAL_LINE(GPIOA, 5)
48+
#define LINE_SPI_SSEL PAL_LINE(GPIOA, 4)
49+
50+
// CAN Configuration
51+
#define BMS_CAN_DRIVER CAND1
52+
#define BMS_CAN_CR1 CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP
53+
#define BMS_CAN_CR2 CAN_BTR_SJW(1) | CAN_BTR_TS1(5) | CAN_BTR_TS2(0) | CAN_BTR_BRP(2)
54+
55+
#define LINE_CAN_TX PAL_LINE(GPIOA, 12)
56+
#define LINE_CAN_RX PAL_LINE(GPIOA, 11)
57+
*/
58+
59+
// BMS Cell lookup
60+
const int BMS_CELL_MAP[12] = {0, 1, 2, 3, -1, -1, 4, 5, 6, -1, -1, -1};

0 commit comments

Comments
 (0)