-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds temp cells code and small dash changes, forgot to commit
- Loading branch information
1 parent
b33a845
commit c75f8fa
Showing
12 changed files
with
356 additions
and
66 deletions.
There are no files selected for viewing
Binary file added
BIN
+53.1 KB
teensy_cells/Thermistor Expansion CANBUS Protocol - J1939 - thermistor_module_canbus.pdf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <FlexCAN_T4.h> | ||
#include "Arduino.h" | ||
|
||
#define TOTAL_BOARDS 6 | ||
#define DELAY_INTERVAL 500 | ||
#define N_NTC 18 | ||
#define VDD 5.0 | ||
#define RESISTOR_PULLUP 10000.0 | ||
#define RESISTOR_NTC_REFERNCE 10000.0 // Resistência a 25°C do NTC | ||
#define TEMPERATURE_DEFAULT_C 25.0 | ||
#define TEMPERATURE_DEFAULT_K 298.15 | ||
#define NTC_BETA 3971.0 | ||
#define MAXIMUM_TEMPERATURE 60.0 | ||
#define MASTER_CELL_ID 0x109 | ||
#define CELLS_PER_MESSAGE 6 | ||
#define CELL_TEMPS_BASE_ID 0x110 | ||
#define CAN_BAUD_RATE 500000 | ||
#define THERMISTOR_MODULE_NUMBER 0x00 | ||
#define NUMBER_OF_THERMISTORS 0x01 | ||
#define HIGHEST_THERMISTOR_ID 0x01 | ||
#define LOWEST_THERMISTOR_ID 0x00 | ||
#define CHECKSUM_CONSTANT 0x39 | ||
#define MSG_LENGTH 0x08 | ||
#define BMS_THERMISTOR_ID 0x1839F380 | ||
#define MAX_INT8_T 127 | ||
#define MIN_INT8_T -128 | ||
#define ANALOG_MAX 1023 | ||
struct BoardData { | ||
int8_t min_temp = MAX_INT8_T; | ||
int8_t max_temp = MIN_INT8_T; | ||
int8_t avg_temp = 0; | ||
bool valid = false; | ||
}; | ||
|
||
float read_ntc_temperature(int analog_value); | ||
void read_Temperatures(); | ||
void check_Temperatures(); | ||
int8_t safeTemperatureCast(float temp); | ||
void send_CAN_max_min_avg_Temperatures(); | ||
void send_to_BMS(int8_t global_min, int8_t global_max, int8_t global_avg); | ||
void send_CAN_all_cell_temperatures(); | ||
void show_Temperatures(); | ||
void code_reset(); | ||
void can_sniffer(const CAN_message_t& msg); | ||
void calculate_global_stats(int8_t& global_min, int8_t& global_max, int8_t& global_avg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env:teensy41] | ||
[env] | ||
platform = teensy | ||
board = teensy41 | ||
framework = arduino | ||
board = teensy41 | ||
build_flags = | ||
-D THIS_IS_MASTER=false | ||
-D BOARD_ID=0 | ||
|
||
[env:teensy_master] | ||
extends = env | ||
build_flags = | ||
-D THIS_IS_MASTER=true | ||
-D BOARD_ID=0 | ||
|
||
[env:teensy1] | ||
extends = env | ||
build_flags = -D BOARD_ID=1 -D THIS_IS_MASTER=false | ||
|
||
[env:teensy2] | ||
extends = env | ||
build_flags = -D BOARD_ID=2 -D THIS_IS_MASTER=false | ||
|
||
[env:teensy3] | ||
extends = env | ||
build_flags = -D BOARD_ID=3 -D THIS_IS_MASTER=false | ||
|
||
[env:teensy4] | ||
extends = env | ||
build_flags = -D BOARD_ID=4 -D THIS_IS_MASTER=false | ||
|
||
[env:teensy5] | ||
extends = env | ||
build_flags = -D BOARD_ID=5 -D THIS_IS_MASTER=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch |
10 changes: 10 additions & 0 deletions
10
teensy_cells_master/teensy_cells_master/.vscode/extensions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"platformio.platformio-ide" | ||
], | ||
"unwantedRecommendations": [ | ||
"ms-vscode.cpptools-extension-pack" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
This directory is intended for project header files. | ||
|
||
A header file is a file containing C declarations and macro definitions | ||
to be shared between several project source files. You request the use of a | ||
header file in your project source file (C, C++, etc) located in `src` folder | ||
by including it, with the C preprocessing directive `#include'. | ||
|
||
```src/main.c | ||
|
||
#include "header.h" | ||
|
||
int main (void) | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
Including a header file produces the same results as copying the header file | ||
into each source file that needs it. Such copying would be time-consuming | ||
and error-prone. With a header file, the related declarations appear | ||
in only one place. If they need to be changed, they can be changed in one | ||
place, and programs that include the header file will automatically use the | ||
new version when next recompiled. The header file eliminates the labor of | ||
finding and changing all the copies as well as the risk that a failure to | ||
find one copy will result in inconsistencies within a program. | ||
|
||
In C, the usual convention is to give header files names that end with `.h'. | ||
It is most portable to use only letters, digits, dashes, and underscores in | ||
header file names, and at most one dot. | ||
|
||
Read more about using header files in official GCC documentation: | ||
|
||
* Include Syntax | ||
* Include Operation | ||
* Once-Only Headers | ||
* Computed Includes | ||
|
||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html |
Oops, something went wrong.