sneakthief Posted September 12, 2012 Report Share 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: Quote Link to comment Share on other sites More sharing options...
TK. Posted September 16, 2012 Report Share 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. Quote Link to comment Share on other sites More sharing options...
sneakthief Posted September 21, 2012 Author Report Share 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.