Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Hex (From ADC) to Float number

Status
Not open for further replies.

mymadi

Newbie level 6
Joined
Sep 20, 2006
Messages
11
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,345
Dear all forumer,

I have a little bit problem how to convert the hexadecimal (the value read from ADC) to a floating point. Currently i'm doing the Fuzzy Logic that need range from -1000 to 1000

so i have some idea how to convert it, it is possible:

Code:

Code:
float e;

e = ((ADC - 128)/128)*1000;


128 is the setpoint (128H is equal to 0)

Thats mean the idea is:

0H is equal to -1000
128H is equal to 0
255H is equal to 1000


Please help me!!! :idea:
 

The code that you've written should do what you want on most compilers.

You can also try casting
Code:
float e; 

e = (float) ((ADC - 128)/128)*1000;

It would help if you tell us which compiler you are using.
 

    mymadi

    Points: 2
    Helpful Answer Positive Rating
kender said:
It would help if you tell us which compiler you are using

Thank you... Currently i'm using SDCC... free compiler for 8051.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top