the dataset you are trying to infer information from consists of two pieces of data
1. the adc reading
2. the timestamp of the reading
The periods you are interested in are between .2 and 1 sec. if you sample the input volts at 200 times / sec (5mS)
then you need to store at least 200 samples and their timestamps . when you have those samples you could analyse the dataset
for press/longpress data. you need to understand that if you sort the data on the adc value then the time stamp value needs to be included in the sort otherwise the data becomes useless [all the time info is lost].
If the data is so noisey that my method fails the the above method could work but it would not be possible on a 12f675 [insufficient ram]
lowering the input impedence, altering the sample rate or increasing the "pressed"/"not pressed" tolorance may help.
Write a pgm to capture and print the adc reading at a 5mS sample rate .then you can examine the data statistically for a fundamental noise frequency that may be possible to filter out or maybe some other ways to mitigate the noise problem. without real data i'm just speculating.
my method could also be turned around to count the number of "valid" reads in a period rather than the number of "periods" of valid reads ,
which may perform better in noisy environments
Bookmarks