Pingin' Blues
I got my new Ping Ultrasonic sensors a couple of days ago and have been trying to put together a function that gives me a smooth, steady readout of my distance.·
I've tried several different approaches,·· averaging,· time delays, etc.
I still tend to get some pretty wide variences.· However, I find that the shape and position of the target seems to make the most difference.· ( a hand doesn't make·a good·target )
My last attempt to get a smooth reading is to take a group of readings,· sort them high to low and take the middle value.·
I figgure I'll come up with something that works reliably·( ... put enough monkeys in front of enough typewriters...· or a single monkey at the typewriter long enough...)·
However.. I ran into something that I can't explain and thought I'd ask the experts.
The attached code pings a distance and displays it on a VGA screen.
when my distance from the sensor is about 20+ inches... everything is fine, but when I get closer,· it starts to mess with my VGA display!·
A distance of just a few inches trashes my screen. · I'm pretty sure something is affecting the internal PLL because I can see the screen change like it would when you change frequencies on a monitor.
I suspect·this is something I'm doing wrong in software but I can't see what it might be.
Any ideas?
Ken B.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
" Anything worth doing... is worth overdoing. "
··············································· ( R.A.H. )
····································
I've tried several different approaches,·· averaging,· time delays, etc.
I still tend to get some pretty wide variences.· However, I find that the shape and position of the target seems to make the most difference.· ( a hand doesn't make·a good·target )
My last attempt to get a smooth reading is to take a group of readings,· sort them high to low and take the middle value.·
I figgure I'll come up with something that works reliably·( ... put enough monkeys in front of enough typewriters...· or a single monkey at the typewriter long enough...)·
However.. I ran into something that I can't explain and thought I'd ask the experts.
The attached code pings a distance and displays it on a VGA screen.
when my distance from the sensor is about 20+ inches... everything is fine, but when I get closer,· it starts to mess with my VGA display!·
A distance of just a few inches trashes my screen. · I'm pretty sure something is affecting the internal PLL because I can see the screen change like it would when you change frequencies on a monitor.
I suspect·this is something I'm doing wrong in software but I can't see what it might be.
Any ideas?
Ken B.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
" Anything worth doing... is worth overdoing. "
··············································· ( R.A.H. )
····································
zip
![](/plugins/FileUpload/images/file.png)
12K
Comments
Good luck!
I love the Propeller! I'm having fun with making it into an industrial controller, however, this is the type of thing that can be a literal killer if you don't understand what is causing it and be able to stay away from such things.
************* NOTE I've been changing my code as I've been writing on this. I KNEW I was doing something wrong! I was over-running my array size! I'm not sure why it was ever working with longer distances but opening up the array fixed it.
Sorry for posting a silly programming error here on the site!
As we used to say in flight Ops: " It was a loose nut in the cockpit"
Ken B.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
" Anything worth doing... is worth overdoing. "
··············································· ( R.A.H. )
····································
It's not a silly programming error, if you learned something as a result.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
To err is human, to compute, divine
You learn more from your failures than you do from your successes. (That sort of makes us all geniouses)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Evartt
People don't hate computers, they just hate lousy programmers.
http://wehali.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon