Problems with fixed point numbers

The favorite HDL language in Europe and in Universities

Problems with fixed point numbers

Postby cmjulian » Thu Jul 15, 2010 1:43 pm

Hello everybody!!

I'm finishing my thesis work as an electronics engineer, and I saw your website while I was looking for some information, so I decided to register and aks some questions here, I hope you could help me.

I'm developping a GPS-guided autopilot for a tiny boat, this means, the boat has to follow some waypoints automatically using a GPS to get its position. For the moment I have programmed succesfully the RS232 interface and a FSM to decode the GPRMC sentence of the NMEA 0183 protocol (it sounds difficult but, it isn't) and I get the LATITUDE, LONGITUDE, SPEED and BEARING information that I show in the 7-segment displays.
From now on, I have to work with these parameters and make some fixed-point operations, but I don't know how to, because I need it to be synthetizable, I have also think to program a Microblaze but I've never done that and i think i could solve this in other ways...

Thank you so much.

PD: sorry about my awful english
cmjulian
 
Posts: 3
Joined: Thu Jul 15, 2010 1:21 pm

Postby tricky » Fri Jul 16, 2010 7:48 am

I assume these numbers arrive as floating point? With fixed point, you have a limited range but with a fixed precision, unlike floating point where precision depends on value. Unless you have huge (very very huge) fixed point values you cannot accept the full range of floating point.

Fixed point is great because you can treat every number like an integer. Integer math and fixed point are all the same - just with fixed point you have to track your fractional bits, but the rules are simple and so this is easily done.

Eg: a number with 10 integer bits and 8 fractional (10.8) multiplied by 4.12 number, gives a 14.20 result. each bit just represents a power of 2, with bits 0-19 representing 2^-20 to 2^-1, then bit 21 being 2^0 and so on.
tricky
 
Posts: 56
Joined: Wed Dec 09, 2009 11:50 am

Postby cmjulian » Fri Jul 16, 2010 1:01 pm

thank you for your answer!

Well, these numbers arrive in ASCII format and I store them in a string that I send to the 7-segment displays, I think I have no problem to store them as integers instead of strings, but the problem is that I don't know exactly if they are fixed or floating point, I'll give you an example of what I have:

LATITUDE: 2023.9088 this is HHMM.MMMM the first 2 characters are degrees and the rest are minutes, I would like to operate all in degrees so I have to divide the minutes by 60 and add this result to the degrees

LONGITUDE: 00450.1096 this is HHHMM.MMMM the same as in latitude.

BEARING: 358.86 this data is all degrees

I think this numbers are fixed point because they have the same precision, but I need to make some operations to calculate the bearing to the next waypoint and i'm not sure how to do this
cmjulian
 
Posts: 3
Joined: Thu Jul 15, 2010 1:21 pm

Postby cmjulian » Sat Jul 24, 2010 4:17 pm

can anybody help me, please?
cmjulian
 
Posts: 3
Joined: Thu Jul 15, 2010 1:21 pm


Return to VHDL