Skip to content

Commit bfe789b

Browse files
committed
updated current sensing
1 parent 6ebd2cf commit bfe789b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Power Board/thrusters.ino

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ DO NOT FLASH TO TEENSY OR TO ARDUINO
44
55
*/
66

7+
#include <Arduino.h>
78
#include <Servo.h>
89

910
// defines all MCU pins
@@ -107,19 +108,19 @@ void waterInterrupt() {
107108
}
108109

109110
void senseCurrent(float Tcurrents[]) {
110-
Tcurrents[0] = ((analogRead(TC_1) * 3.3) / 1023) / 0.005;
111-
Tcurrents[1] = ((analogRead(TC_2) * 3.3) / 1023) / 0.005;
112-
Tcurrents[2] = ((analogRead(TC_3) * 3.3) / 1023) / 0.005;
113-
Tcurrents[3] = ((analogRead(TC_4) * 3.3) / 1023) / 0.005;
114-
Tcurrents[4] = ((analogRead(TC_5) * 3.3) / 1023) / 0.005;
115-
Tcurrents[5] = ((analogRead(TC_6) * 3.3) / 1023) / 0.005;
116-
Tcurrents[6] = ((analogRead(TC_7) * 3.3) / 1023) / 0.005;
117-
Tcurrents[7] = ((analogRead(TC_8) * 3.3) / 1023) / 0.005;
111+
Tcurrents[0] = (analogRead(TC_1)) / (0.005 * 50);
112+
Tcurrents[1] = (analogRead(TC_2)) / (0.005 * 50);
113+
Tcurrents[2] = (analogRead(TC_3)) / (0.005 * 50);
114+
Tcurrents[3] = (analogRead(TC_4)) / (0.005 * 50);
115+
Tcurrents[4] = (analogRead(TC_5)) / (0.005 * 50);
116+
Tcurrents[5] = (analogRead(TC_6)) / (0.005 * 50);
117+
Tcurrents[6] = (analogRead(TC_7)) / (0.005 * 50);
118+
Tcurrents[7] = (analogRead(TC_8)) / (0.005 * 50);
118119
}
119120

120121
void senseVoltage(float Bvoltages[]) {
121-
Bvoltages[0] = analogRead(VBAT1_SENSE) * 1.6625 + 12.5;
122-
Bvoltages[1] = analogRead(VBAT2_SENSE) * 1.6625 + 12.5;
122+
Bvoltages[0] = map(analogRead(VBAT1_SENSE), 0.180, 2.586, 12.8, 16.8);
123+
Bvoltages[1] = map(analogRead(VBAT2_SENSE), 0.180, 2.586, 12.8, 16.8);
123124
}
124125

125126
void setup() {

0 commit comments

Comments
 (0)