Jump to content

Recommended Posts

Posted

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:

glovetest1.jpg

This is just for testing, unlike my 2nd prototype below which has a proper glove, smaller case and TQFP (!) SMD PIC18F:

glovetest1b.jpg

Posted

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.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...