PDA

View Full Version : Hysteresis and better programming skills...



Wolfbrother
02-24-2010, 02:26 AM
Hi all,

I'm in over my head, as usual. I am using a reading from the Ping sensor and comparing that to the last couple of readings from the ping sensor to determine if a person is moving toward the sensor, away from the sensor, changing direction or standing still. I attached the code I have written and cobbled together from others. What my boggle is, is to add some hysteresis to the conditionals in my subroutine Track_position. Right now it's a touch too precise, a person can stand still and wobble a couple of inches just because. I'd like to add +/- 3 inches to each value and then compare the ranges, see if there is any overlap with the conditional statements in Track_position. I am also thinking my brute force method of comparison could use some refinement. I did a search of the forum for Hysteresis and really didn't find much, except for taking four measurements and averaging them to get a more consistent reading. Any body have a good suggestion for me?

Thanks in advance.

Dave