Skip to content

Commit

Permalink
add temperature reorder buf
Browse files Browse the repository at this point in the history
  • Loading branch information
tiandahuang committed Jul 11, 2024
1 parent a11181b commit 48c3ef1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Apps/Src/Temperature.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ static TemperatureFilter1_t TemperatureFilter1;
#include "EMAFilter.h"
static TemperatureFilter2_t TemperatureFilter2;

// hacky remapping for temperature hat error in pin assignment. TODO: fix this in HW
/**
* [1->1, 2->5, 3->9, 4->13 ],
* [5->2, 6->6, 7->10, 8->14 ],
* [9->3, 10->7, 11->11, 12->15],
* [13->4, 14->8, 15->12, 16->16]
*/
static const uint8_t temp_reindex[16] = {0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15};

// simulator bypasses ltc driver
#ifndef SIMULATION
// Interface to communicate with LTC6811 (Register values)
Expand Down Expand Up @@ -102,6 +111,8 @@ ErrorStatus Temperature_ChannelConfig(uint8_t tempChannel) {
#ifdef SIMULATION
currentChannel = tempChannel;
#else
// define actual temp channel in HW based on error in PCB. TODO: fix this in HW
tempChannel = temp_reindex[tempChannel];

uint8_t muxAddress;
uint8_t otherMux;
Expand Down
4 changes: 2 additions & 2 deletions Tasks/Src/Task_Amperes.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ void Task_AmperesMonitor(void *p_arg) {
Amps_UpdateMeasurements();
CheckCurrent();
amps_data_count++;
amps_totals += Amps_GetReading();
amps_totals += Amps_GetReading(false); // use filtered value here

// update state of charge
Charge_Calculate(Amps_GetReading());
Charge_Calculate(Amps_GetReading(true)); // use raw value here

// NONBLOCKING ==================
// Send CAN messages
Expand Down

0 comments on commit 48c3ef1

Please sign in to comment.