Moved from Compiler v1.3.2, now about FP vs Integer math

This forum is for posts that might be considered off-topic but that may be useful or interesting to members. Examples include posts about electronics or programming in general, other microcontrollers or interesting devices, useful websites, etc.
Post Reply
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Moved from Compiler v1.3.2, now about FP vs Integer math

Post by spamiam »

Re: last 3 posts in the Compiler Update V1.3.2 thread
Tony, you were born too late, I think! Had you entered programming when
some of us did, you'd be sick and tired of fixed-point everything.
Watching reverse evolution - recoding from floats to fixed-point for a
rally computer? - seems perverse. That's akin to driving your BMW like
a Buick. Why would you do that?

I believe single floats provide six or seven significant digits; do you
need more than that? Does zero not necessarily being exactly zero, or
one not necessarily being exactly one, make floats unusable? Usually
not. Do you need more processing speed? Probably not. Is there error
in floats? Absolutely, but you say you haven't actually seen it, yet,
so it's probably in the noise.

It sounds to me like floats are perfect for you, Tony.
Tom, I think you are correct. The floats probably give me sufficient accuracy, and when handled properly, can have sufficiently low accumulated error. I certainly am not seeing it yet.

So far, as far as I can tell, my processing speed is adequate. I have not seen any dropped interrupts, and I have been very careful to prevent this!

Believe me, I do NOT want to make work for myself. I just want the most efficient processing "possible". I must say, the floats are easy to maintain because the math is very self-explanatory when the variables are named well. I have put-off the conversion to all integer math until I got the rest of the software functions sorted out. That time is approaching.

Nevertheless, I will keep the FP math unless I see a problem with it. So far in pretty extensive stress testing, it has been fine. OTOH, I have not used the device in a real rally.....

I was kidding - - with an application than can stand hundreds of microseconds or maybe miliseconds to do floating point in a humble 8 bit micro, fixed point isn't needed.

Steve, I knew you were kidding, but your point was a very good one. These little processors are slow compared to the big stuff in a PC, for instance. We can get lulled into a false sense of security if we do any programming of the fast machines. Problems of excessively slow execution may be subtle at first. Simply a missed interrupt occasionally. The clock interrupts are every 0.97 mS.

I break the rules pretty extensively by running most interrupt services with interrupts ENABLED. I definitely feel my pants down at my knees when I do this. IN these cases I am trying to perform pre-emptive multitasking. I grab a volatile variable's value, reenable interrupts, and use the (stale) the number I just grabbed. Some times this is not possible.

I have not tested the system's speed, but if I do anything that keeps the interrupts off for more than 1.9mS could cause a dropped clock tick. I have no idea how many floating point operations can be done in that time (on raw AVR h/w programmed in C). 1.95mS is about 32,000 instructions, and I guess a ton of FP operations can be done in that time.



My uncle used to rally extensively around Boston. His wife drove, he calculated, (being radar engr for Ratheon). If I recall his stories, he had a ticker in line in the speedometer cable giving a switch closure every x tire rotations. He used an HP45 calculator, and a couple of stop watches.
BTW, at one rally, where the cars were dispatched from the starting point at every so many minutes, the race coordinator played the time signal from WWV over a PA system. Everyone thought it was live. Many synched their watches or rally clocks to it. In fact he had recorded the signal and was playing it back a couple minutes off! Really trashed everyone's score.
OH well, geek jokes.
JC, OOOOH, that is so unfair! I have a hard enough time when the rally master is NOT trying to screw you up! I fall for every one of the traps!

As for a "ticker" system. Many rally-ists use this exact same system now. They have the "ticker" increment a counter of some sort (running on a ZX-24?) and this gives a display showing the total mileage.

Then they have a SEPARATE clock-based device showing them what the Odometer ought to be. The navigator then tells the driver to slow down or speed up.

As long as the odometer and clock are separate, then you may get to rally in a different class (easier?????) than the "equipped" class. It is called the "limited" class (sometimes, depending on the rules you can run in "stock" class!). It is very common for the "non-equipped" classes to do better than those in the equipped class. GIGO!

In the "equipped" class, I get either rather good scores, or really CRAPPY scores. Definite GIGO.

-Tony
Post Reply