hi sir i need one help now iam doing project on 89c51 using C51 Evaluation Software i converted 0-5 analog volatge to 0-5 digital voltage . now i want convert digital data to pressure my output should be like this 0v 1.1E-1 3v 4.1E-4 0.1 1.2E-1 4v 5.1E-5 1v 2.1E-2 5v 6.1E-6 2v 3.1E-3 i want 500 values in between 0 to 5 volts how to calibrate the voltage interms of preesure what logic i want use to convert Voltage to pressure my C51 not taking floting oparations please help regards chandra sri
if you do not like the replies, do you really think you are going to get something more to your liking by posting in unrelated threads?
Erik
"You still haven't said what unit of pressure you're using - bar? atmosphere? mm of water? mm of mercury? Pascal?" sir iam using Bar
If you work in units of mV and uBar, there is no need for fractions:
Voltage Pressure 0mV =110 000 uBar 10mV =120 000 uBar 20mV =130 000 uBar : 1000mV = 21 000 uBar : 2000mV = 3 100 uBar : 3000mV = 410 uBar : 4000mV = 51 uBar : 5000mV = 6 uBar
hellow sir sir iam very very happy with your replys sir here this data iam taken from a standard table here my job is simply display the preesure for caresponing input voltage here units are not impartent. just i want display the pressure on display like 0.00v =1.1E-1 0.01v =1.2E-1 0.02v =1.3E-1 . . 1.00 =2.1E-2 . . 2.00 =3.1E-3 . . 3.00 =4.1E-4 4.00 =5.1E-4 5.00 =6.1E-5 thank you regards chandu
"my job is simply display the preesure for caresponing input voltage" If it's purely for display purposes. maybe strings would be best:
unsigned int voltage; // In units of 10mV char pressure_string[] = { "1.1E-1", // Index 0 corresponds to 0mv "1.2E-1", // Index 1 corresponds to 10mv "1.3E-1", // Index 2 corresponds to 20mv : : } printf( "Voltage %u mV = Pressuse %s", voltage*10, pressure_string[voltage] );
thank you sir i tried this program but iam getting one error #include<stdio.h> #include<reg51.h> #include <string.h> void main() { unsigned int voltage; char pressure_string[2] ={"1.1E-1","1.2E-1","1.3E-1"}; voltage=0x0A; /*10mv*/ SCON = 0x50; TMOD |= 0x20; TH1 = 221; TR1 = 1; TI = 1; printf( "Voltage %u mV = Pressuse %s", voltage*10, pressure_string[voltage] ); } iam getting this error compiling forum.c... MAIN\FORUM.C(8): error C243: 'array[]': string out of bounds main\forum.c - 1 Error(s), 0 Warning(s). sir how much memory well take for 500 values of the look up table regards chandu
sir char pressure_string[] ={"1.1E-1","1.2E-1","1.3E-1"};
"compiling forum.c... MAIN\FORUM.C(8): error C243: 'array[]': string out of bounds" Look-up the error in the Manual - it tells you exactly what is wrong! http://www.keil.com/support/man/docs/c51/c51_c243.htm
"how much memory well take for 500 values of the look up table" Keil C51 does not add any extra space for padding or alignment; therefore the size of an array is simply the size of one element multiplied by the number of elements in the array. The sizes of the data types used by C51 are listed in the Manual: http://www.keil.com/support/man/docs/c51/c51_ap_datastorage.htm You need to become familiar with the Manual - that doesn't mean you have to learn it by heart, but you need to be familiar with what's in it, and how to find stuff in it... You probably also need a good 'C' textbook...
sir i tried this expressions char pressure_string[] ={"1.1E-1","1.2E-1","1.3E-1"}; it is showing same error char pressure_string[3] ={"1.1E-1","1.2E-1","1.3E-1"}; it is also showing same error then which is correct. thank you
Oops - I made a mistake in the code I posted:
char pressure_string[] = { "1.1E-1", // Index 0 corresponds to 0mv "1.2E-1", // Index 1 corresponds to 10mv "1.3E-1", // Index 2 corresponds to 20mv : : }
Iam sorry sir i can not spot your mistake please give solution for that one thank you sir
It's a classic 'C' programmer's mistake! You need to learn to spot these things if you want to do 'C' programming! (it's the kind of thing you'd get in a 'C' test at a job interview!) Another hint: what's the difference between a char and a string in 'C'? Don't be afraid to look in your 'C' textbook... (they probably won't let you do that in an interview, though!)
Have you given up? Try
char * pressure_string[] =
hi sir thank you sir i tried this program { unsigned int voltage; unsigned char *pressure_string[] ={"11E-1","12E-2","13E-3"}; printf( "Voltage %u mV = Pressuse %s", voltage*10, pressure_string[voltage] ); } it is showing folling out put "voltage 10mv=pressure 13E- " it is not showing full value. regards nari