Skip to content

Conversation

@szihlmann
Copy link

Hi Evan

I've been using your code for my own metal detector project and made some changes which I believe will make your code more reliable, clear and useful.

Please check the individual commits to understand the changes. Due to a change in line-end formatting all code appears deleted/inserted.

Serge

Allow negative differences of (storedTimeDelta - signalTimeDelta) by using a long datatype and using abs() of the difference. This accounts for metals that decrease the colpitts oscillator frequency.
Clarified that TCNT1 is the counter variable. OCR1A is the register TCNT1 will be compared to. TCNT1 is increasing NOT decreasing.
TIMER1_COMPA_vect was executed immediately after enabling timer compare interrupt A since the interrupt flag was not cleared. Because the OCR1A value was set to 1 AFTER enabling compare interrupt, wrong values for storedTimeDelta were obtained during Arduino startup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant