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.

Temperature data logger

Status
Not open for further replies.

rutvik1588

Newbie level 5
Joined
Jun 3, 2010
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,344
Hello there,I am making a temperature logger based on AT89S52.The logging is to be done with ADC through a thermocouple.It is working fine and the temperature is being sampled for every 5 seconds. I want to save this data- as text file. How can i do this? Till now i've used Keil uvision3 compiler using C language.

I know the C file handling commands but i don't know how to handle them to the memory. I've used I2C serial eeprom as a memory. I can precisely handle this serial eeprom. Please Tell me how to convert this sampled data in a *.txt format.
Thanks in Advance.;-)
 

Hmmmm. You want to take a number stored as binary, and convert it to decimal text...

First of all, does your micro have a register that stores and calculates in Binary Coded Decimal (BCD) format? That will make it easier to work with. Just read the values, get the ASCII code, and string it all together.

I'm not sure how to locate the decimal point. The power of ten should be stored somwhere at one end of the register.

But if you have to resort to doing it in binary...

The method is to subtract a power of ten repeatedly and keep count.

Start with the largest power of ten you expect to need. You might want to calculate binary representations of powers of ten ahead of time and store them in memory somewhere.

Example, if your number is 456, then you start subtracting 100. Increment a counter with each subtraction.

Stop when your remainder is less than 100.

Your counter will have a value of 4. Whatever the value, you'll add 48 to obtain an ASCII character. You'll concatenate all the characters into a string. Each character of the string goes into a byte of memory.

Next start subtracting 10 (the next lower power of ten). Keep count. In my example the result will be 5.

Repeat. When you're down to a value between 0 and 9.99999, you are subtracting 1. In my example, you can subtract 1 six times.

If you want fractional values, this is when you concatenate a decimal point to the string. (ASCII code 46).

Handling fractions in binary is anything but straightforward. I would just multiply by ten with each loop, then count how many times I can subtract 1. (Don't know whether you'll find it easier to multiply by ten, or add the number to itself ten times.)

Continue the process til you have your desired amount of decimal places.

You'll end up with an ASCII text string. You'll need a counter for its amount of characters. Or else you can use asterisks in memory to designate its beginning and end.

And if you need to deal with negative numbers, then test your original number for being less than zero. If it is, then start your text string with a minus sign (ASCII code 45). Convert your number to positive by subtracting it from zero. (The cpu may perform a bitwise NOT, then add 1, or is it subtract 1?) Then you do the process described above.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top