So, time being what it is, I thought I’d post an update on the status of the train stop watch project.
Tim and I have toiled and struggled and finally we’ve gotten our code working. Our data from last time was correct. Our math, however, was not. We were taking the speed by averaging over all the samples, instead of over an interval. So now we’re getting the speed by averaging all the intervals (at 10ms) per second. So now we’re getting clear acceleration and deceleration in the data.
So the logic behind our program is as follows:
- We sample the speed each second.
- We baseline the high and low speeds at the start of the program.
- We determine new high and low speeds based on a simple algorithm. If there is a new high/low point that is steady (within 100 of each other), and 300 away from the current (high if low and low if high) point, for 3 seconds then a new high/low is set. Simple, right?
- If there is a constant deceleration for 6~ish seconds, we say “Ok, we’ve detected a stop.”
This is all fairly accurate so far and the data reflects it except for a few false negatives that we hope to smooth out by changing the constant deceleration time from 6 seconds to 10ish. We’ll have to play around w/ that.
Right now we just have to actually build a case for our project, and maybe pretty up the input/output mechanisms. Right now we just have a switch that we push to raise the stop count and some lights/a buzzer that can go off.