Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit ff4ba0d

Browse files
Added stall detection code
1 parent 77847d1 commit ff4ba0d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

arduino_controller/arduino_controller.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define SAMPLE_FREQUENCY 20
77
#define MAXIMUM (DEBOUNCE_TIME * SAMPLE_FREQUENCY)
88
#define NUMBER_MOTORS 1
9+
#define TIMEOUT 10000
910

1011
// relay pin
1112
int relayPin = 53;

arduino_controller/arduino_controller_functions.ino

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ void ProcessData()
1313
bool is_reset = false;
1414
bool go = true;
1515
int total_turns = 0;
16+
long timeout_counter = 0
1617

1718
PopulateArray();
1819

@@ -103,14 +104,22 @@ void ProcessData()
103104
go = false;
104105
}
105106
total_turns = 0;
107+
108+
// time out loop if stall
109+
if (timeout_counter >= TIMEOUT)
110+
{
111+
go = false;
112+
}
113+
timeout_counter = timeout_counter + 1
114+
115+
106116
}
107117
}
108118
else
109119
{
110120
int reset_counter[NUMBER_MOTORS] = {1}
111121
while (go == true)
112122
{
113-
114123
// stop motors that have reached 0
115124
for (int i = 0; i < NUMBER_MOTORS; i++)
116125
{
@@ -128,10 +137,16 @@ void ProcessData()
128137
// Serial.print("Total number of turns in array: ");
129138
// Serial.println(total_turns);
130139
}
140+
131141
if (total_turns <= 0)
142+
{
143+
go = false;
144+
}
145+
if (timeout_counter >= TIMEOUT)
132146
{
133147
go = false;
134148
}
149+
timeout_counter = timeout_counter + 1
135150
}
136151
}
137152
// Send Finished Signal

0 commit comments

Comments
 (0)