Why isn't less than working for me?
ghost13
Posts: 133
Hi,
I am building an altimeter for rocketry, and when the rocket reaches the peak of its flight (apogee), it should beep out the altitude. I am trying to do this by getting the altitude and then checking if the current altitude is less than the previous altitude (the rocket is falling). This is not working, however. The altimeter thinks it has reached apogee as soon as it is turned on.
Thanks in advanced for your help!
PS: code is attached.
I am building an altimeter for rocketry, and when the rocket reaches the peak of its flight (apogee), it should beep out the altitude. I am trying to do this by getting the altitude and then checking if the current altitude is less than the previous altitude (the rocket is falling). This is not working, however. The altimeter thinks it has reached apogee as soon as it is turned on.
Thanks in advanced for your help!
PS: code is attached.
Comments
Sensor VOUT = 368 millivots (960')
Altimeter output = 960'
After ground reading (PYRO is called):
Sensor VOUT = 368 millivots (960')
Altimeter output = 5' (which means that PYRO should never have been called because of the noise-reduction code.)
The values are as expected... the altitude is not changing, but "Pyro" is still being called.
Thanks!
My question was: What were the values of feet and prev? They're probably wrong and you'll have to trace back to find out why.
In debugging, you start with the observed resulting action. You're not debugging the BS1 ... That's assumed to work, much like you normally assume that your processor and memory for your PC are working. If the IF is doing the wrong thing, your data must be wrong. You want to verify that, then work backwards to see where the data came from. You can also work forward from known good data.
FEET = 15
PREV = 0
FEET = 15
PREV = 65531
I assume 65531 is the variable being maxed out, and that is why the if statement is returning true. Nothing changes... and then I get that data. Any ideas?
Thanks!
EDIT: After some more testing, I realized that Prev is always being maxed out! I tried resetting AD to zero in the Convert subroutine, but it didn't do a thing [noparse]:([/noparse]
Post Edited (ghost13) : 8/20/2007 8:33:48 AM GMT
Maybe you should check for "feet < 20" and set "prev = 0" in that case.