sneakthief Posted September 12, 2012 Report Posted September 12, 2012 What's the best routine to capture the peak value from an analog in pin? I'm working on a gesture-based instrument, in specific, a glove with a 3-axis accelerometer on it. It's obviously impossible to maintain some kind of constant acceleration with one's hand, so instead I want to choose a note based on how fast I move my hand along an axis. That means taking the maximum (or minimum) AIN-reading each time it passes a threshold, like some kind of track-and-hold. Here's my first prototype, with an accelerometer, flex sensor and finger contacts using conductive thread: This is just for testing, unlike my 2nd prototype below which has a proper glove, smaller case and TQFP (!) SMD PIC18F:
TK. Posted September 16, 2012 Report Posted September 16, 2012 Nice work! :) I think that the a "deadband" algorithm would be sufficient, it's already integrated into MIOS -> MIOS_AIN_DeadbandSet You could also dynamically decrease the deadband if your application notices a fast movement, and set it to a higher value again if it stops. The C implementation of the deadband can be found in the MIOS32 variant under: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fmios32%2FLPC17xx%2Fmios32_ain.c This one even supports a "spike filter", which could be helpful for your application as well! :) Best Regards, Thorsten.
sneakthief Posted September 21, 2012 Author Report Posted September 21, 2012 (edited) Aha! That's exactly what I needed. Thanks for those suggestions :)I'll try them out tomorrow. Edited September 21, 2012 by sneakthief
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now