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.

Float Values store in EEPROM of ATmega16

Status
Not open for further replies.
Dear alexan_e,

My ammeter should as under,

Normally it shows amps like 1.24 or 12.4 or 124 depends on load.
But if user want to set value for amps as he want to set 2.34.
The value 2.34 should be compare with display value as well as store in EEPROM.
When display value 1.24 reaches 2.34 the (any) port_bit should toggles.

I programmed 90%. But problem in storing and retrieving from EEPROM.
The storing value in EEPROM is done but when I retrieve it,its decimal point missed.
As I stored 4.56 and when retrieve it would 456.
 

You mean in the way I suggest?
You can store the value as array "4.56"
or save as integer in eeprom and add second variable that holds the scale (1, 10, 100)
 

Whether you choose to use type float, integer, long, etc, you might consider implementing a union of of the native type with a structure or possibly an array of multiple bytes corresponding with number of bytes the native type uses for storage.

You would then simply input the value of the native type and then access each byte sequentially for reading or writing.

The EEPROM read/write routines would then access the structure or array on a byte level, after which the native type could be read/write directly from/into the union.

I often utilize this technique when handling multibyte output from an ADC.

However, be aware the endianess of the microcontroller must be considered when accessing the structure or array.

BigDog
 

Dear alexan_e,

You can store the value as array "4.56"
or save as integer in eeprom and add second variable that holds the scale (1, 10, 100)

Please give any example.

- - - Updated - - -

Dear bigdogguru,

Do you mean as like as in post#17?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top