Skip to content

Commit f5b2262

Browse files
committed
pwm current characteristic + simpler code without need for interrups for kill switch
1 parent da1aefa commit f5b2262

File tree

2 files changed

+16
-39
lines changed

2 files changed

+16
-39
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
microseconds,mA,notes
2+
n/a,0.15,when thrusters are not connected
3+
1540,0.45,
4+
1600,1.6,
5+
1650,2.6,
6+
1700,3.7,
7+
1750,6.9,
8+
1775,9,approximate value

Power Board/thrusters.ino

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,9 @@ DO NOT FLASH TO TEENSY OR TO ARDUINO
44
55
*/
66

7-
// test MCU kill switch
8-
// test water interrupt
9-
// test delay needed for thruster initialization
10-
// test if ESCs arm after kill switches
11-
// arm all thrusters
12-
137
#include <Servo.h>
148

15-
// boolean for interrupts
16-
volatile bool interruptFlag = false;
17-
189
// defines all MCU pins
19-
#define SYSTEM_KILLED 0
20-
#define THURSTERS_KILLED 1
21-
2210
#define SRG_P_PIN 2
2311
#define SRG_S_PIN 3
2412
#define SWY_BW_PIN 4
@@ -87,8 +75,8 @@ void initThrusters() {
8775

8876
updateThrusters(offCommand);
8977
delay(7000);
90-
91-
interruptFlag = false;
78+
// reamring works when system killed automatically at 2000
79+
// 7000 should be tested since it is more reliable based on bluerobotics
9280
}
9381

9482
void killSystem() {
@@ -101,38 +89,19 @@ void powerSystem() {
10189
delay(100);
10290
}
10391

104-
void interruptRaised() {
105-
interruptFlag = true;
106-
}
107-
10892
void waterInterrupt() {
109-
if (digitalRead(WATER_DETECTED) == HIGH) {
110-
killSystem();
111-
} else {
112-
powerSystem();
113-
}
93+
killSystem();
94+
while (true) {}
11495
}
11596

11697
void setup() {
117-
pinMode(SYSTEM_KILLED, INPUT_PULLUP);
118-
pinMode(THURSTERS_KILLED, INPUT_PULLUP);
119-
pinMode(WATER_DETECTED, INPUT_PULLUP);
120-
121-
pinMode(MCU_KS, OUTPUT);
122-
123-
attachInterrupt(digitalPinToInterrupt(SYSTEM_KILLED), interruptRaised, RISING);
124-
attachInterrupt(digitalPinToInterrupt(THURSTERS_KILLED), interruptRaised, RISING);
125-
attachInterrupt(digitalPinToInterrupt(WATER_DETECTED), waterInterrupt, CHANGE);
98+
//pinMode(WATER_DETECTED, INPUT_PULLUP);
99+
//pinMode(MCU_KS, OUTPUT);
100+
//attachInterrupt(digitalPinToInterrupt(WATER_DETECTED), waterInterrupt, RISING);
126101

127102
initThrusters();
128103
}
129104

130105
void loop() {
131-
if (interruptFlag) {
132-
initThrusters();
133-
}
134-
135-
if (digitalRead(WATER_DETECTED) == LOW) {
136-
updateThrusters(microseconds);
137-
}
106+
updateThrusters(microseconds);
138107
}

0 commit comments

Comments
 (0)