|
Re: Ultrasonic sensors on digital ports 3-6 problems
Did you get rid of the floating point? 1, it won't fly unless you typecast around the block, and 2, floating point math takes a long while and is something you should probably never put in an ISR. You might instead try using fractional multiplication instead (multiply by numerator, divide by denominator).
Also, where you reset the timer after catching the first edge of the pulse to be timed, I don't know if I'd reset the timer that way... perhaps you can instead zero the timer (with it off) when you send your triggering pulse, then when you catch the first edge just set the TMR3ON bit.
A lot of your other stuff looks fine to me... far as I can tell you're close.
Again, I'll be releasing my four channel single-pin simultaneous measurement ultrasonic code here in about 5 days... unfortunately have tons of code I have to write for our robot right now so I don't really have time to clean up the (now messy looking) driver. Again, if you're planning on using something like this, my driver utilizes TMR1, and of course the second half of PORTB (digio 3-6). I didn't make it reconfigureable, but do with it what you want, just don't repost it or anything... more on that later when I release it. Best part about being able to have four pings flying at the same time... we (1024) have a tested rig that gets 200Hz update guaranteed at nine feet... and amazingly the ping's don't get confused.
-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
|