generated from HyperloopUPV-H8/template-project
-
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.
- Loading branch information
Showing
11 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
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
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,16 @@ | ||
#pragma once | ||
#include "Data/Data.hpp" | ||
class CurrentSensors{ | ||
private: | ||
Data_struct *data; | ||
LinearSensor<float> sensor_u_a{Pinout::CURRENT_SENSOR_U_A,Current_Sensors::slope_u_a,Current_Sensors::offset_u_a,&data->actual_current_sensor_u_a}; | ||
LinearSensor<float> sensor_u_b{Pinout::CURRENT_SENSOR_U_B,Current_Sensors::slope_u_b,Current_Sensors::offset_u_b,&data->actual_current_sensor_u_b}; | ||
LinearSensor<float> sensor_v_a{Pinout::CURRENT_SENSOR_V_A,Current_Sensors::slope_v_a,Current_Sensors::offset_v_a,&data->actual_current_sensor_v_a}; | ||
LinearSensor<float> sensor_v_b{Pinout::CURRENT_SENSOR_V_B,Current_Sensors::slope_v_b,Current_Sensors::offset_v_b,&data->actual_current_sensor_v_b}; | ||
LinearSensor<float> sensor_w_a{Pinout::CURRENT_SENSOR_W_A,Current_Sensors::slope_w_a,Current_Sensors::offset_w_a,&data->actual_current_sensor_w_a}; | ||
LinearSensor<float> sensor_w_b{Pinout::CURRENT_SENSOR_W_B,Current_Sensors::slope_w_b,Current_Sensors::offset_w_b,&data->actual_current_sensor_w_b}; | ||
void zeroing(); | ||
public: | ||
CurrentSensors(Data_struct *data); | ||
void read(); | ||
}; |
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,12 @@ | ||
#pragma once | ||
#include "Data/Data.hpp" | ||
#include "Sensors/CurrentSensors.hpp" | ||
class Sensors{ | ||
private: | ||
Data_struct *data; | ||
CurrentSensors currentSensors; | ||
public: | ||
Sensors(Data_struct *data); | ||
void read(); | ||
|
||
}; |
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
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,37 @@ | ||
#include "Sensors/CurrentSensors.hpp" | ||
#define TIMES_TO_CREATE_ZERO 10000 | ||
CurrentSensors::CurrentSensors(Data_struct *data):data(data){ | ||
zeroing(); | ||
} | ||
void CurrentSensors::zeroing(){ | ||
float new_offset_u_a = 0; | ||
float new_offset_u_b = 0; | ||
float new_offset_v_a = 0; | ||
float new_offset_v_b = 0; | ||
float new_offset_w_a = 0; | ||
float new_offset_w_b = 0; | ||
for(int i = 1; i < TIMES_TO_CREATE_ZERO; i++){ | ||
read(); | ||
new_offset_u_a = (new_offset_u_a * (i - 1) + data->actual_current_sensor_u_a)/i; | ||
new_offset_u_b = (new_offset_u_b * (i - 1) + data->actual_current_sensor_u_b)/i; | ||
new_offset_v_a = (new_offset_v_a * (i - 1) + data->actual_current_sensor_v_a)/i; | ||
new_offset_v_b = (new_offset_v_b * (i - 1) + data->actual_current_sensor_v_b)/i; | ||
new_offset_w_a = (new_offset_w_a * (i - 1) + data->actual_current_sensor_w_a)/i; | ||
new_offset_w_b = (new_offset_w_b * (i - 1) + data->actual_current_sensor_w_b)/i; | ||
} | ||
//once we have the average of 10000 thousand values | ||
sensor_u_a.set_offset(new_offset_u_a); | ||
sensor_u_b.set_offset(new_offset_u_b); | ||
sensor_v_a.set_offset(new_offset_v_a); | ||
sensor_v_b.set_offset(new_offset_v_b); | ||
sensor_w_a.set_offset(new_offset_w_a); | ||
sensor_w_b.set_offset(new_offset_w_b); | ||
} | ||
void CurrentSensors::read(){ | ||
sensor_u_a.read(); | ||
sensor_u_b.read(); | ||
sensor_v_a.read(); | ||
sensor_v_b.read(); | ||
sensor_w_a.read(); | ||
sensor_w_b.read(); | ||
} |
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,7 @@ | ||
#include "Sensors/Sensors.hpp" | ||
|
||
Sensors::Sensors(Data_struct *data):data(data),currentSensors(data){} | ||
|
||
void Sensors::read(){ | ||
currentSensors.read(); | ||
} |
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
Submodule ST-LIB
updated
20 files