If I use a timer, I would clearly get the first arrival time (that meets the threshold).
Yup, that part is easy
I'm a little unsure of how to get the other arrival times. Could you descibe this in a little more detail for me please?
Not a problem, but I'm now "remembering what I did" not looking at the actual solution ...
What I did was "one measurement per ping" assuming that I am measuring static environment. I was also measuring only 4 echoes but you could expand using the similar technique.
1st echo is "measure the interval"
2nd echo is "measure the interval" but set the capture postscaler to 1:2
3rd echo is "interrupt on 1st echo then clear interrupt flag and go again" ..this "turn on and do again" cost some cycles that you have to deduct from the total score later on
4th echo same as 2nd one only postscaler 1:4
The 2 OP idea was used only in hardware, I used the second half of the mcp602 to get the "low amplitude echo" but I never implemented any of it in software. The plan was not to use capture timer but to use 40MHz PIC and loop like
Code:
...
x:
test PINL
jump if set LL
test PINH
jump if set HH
jump CC
LL:
inc LOW
set L[LOW] = CLOCK
nop
nop
nop
HH:
inc HIGH
set H[HIGH] = CLOCK
CC:
inc CLOCK
jump x
...
the general idea is to have same number of clocks in one loop so it need some work, and some way in / out of the loop need to be defined, using interrupt to set some flag and then check it before "jump x" or if clock is > something or if high > sizeof(H)....
anyhow, the idea was to scan the 2 input pins (assuming if low pin is set that the high one is also set without need to test it) and storing the data in RAM array ... then later on, you can analyze the array ....
I never implemented this so I have no idea if that would be useful at all ... I do not know why I even wanted that (I suspect I wanted to use the other half of mcp602 for something
)
you can also have timer run (do not set it to stop on capture) and connect echo pin on interrupt and then just copy the timer value into array ... probably better way then what I was doing but .. I did not remember it then