This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pressure

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

Parents
  • 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

Reply
  • 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

Children
  • When you posted your data as

    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
    I thought this showed that you understand what the little dots mean!

    The little dots mean, "this is incomplete; extra values go here"

    Thus, the table 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
       :
       :
    }
    is icomplete - it contains only the first 3 entries!
    You need to fill-in the other 497 entries!

    Your "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] );
    }
    doesn't assign a value to 'voltage' before using it in the printf!

    It'd probably be better to add a newline at the end of the output:
    printf( "Voltage %u mV = Pressuse %s\r\n", voltage*10, pressure_string[voltage] );

    Please read the instructions on how to post code in the forum:

    http://www.keil.com/forum/tips.asp

    and use the 'preview' to check before pressing 'post'

  • Hi sir

    I assign a value to 'voltage'

    now iam geting correct values.

    up to 24 string elements [array elements]it showing correct.

    Above the 24 elements it is compiling but it is showing linking error

    the error is:

    "Build target 'Target 1'
    linking...
    *** ERROR L107: ADDRESS SPACE OVERFLOW
    SPACE: DATA
    SEGMENT: _DATA_GROUP_
    LENGTH: 0071H
    Program Size: data=123.1 xdata=0 code=1559
    Target not created*/"


    above the 50 elements it is not compiling and showing this error .

    the error is:

    " compiling forum.c...
    MAIN\FORUM.C(19): error C241: 'main': auto segment too large
    main\forum.c - 1 Error(s), 0 Warning(s). "


    regards
    chandu


  • *** ERROR L107: ADDRESS SPACE OVERFLOW
    SPACE: DATA


    This means that there is not enough memory available in DATA memory space to hold all the variables you have declared. Which is not surprising, as the 8052 only has 128 bytes of DATA memory.

    Since your programm will most likely not change the contents of the string array at run-time, you could simply store the array in CODE space instead. If the program does need to change the contents, and your device has enough XDATA memory, store the array there instead.

    Refer to the Cx51 manual for more information on memory types and areas:

    http://www.keil.com/support/man/docs/c51/c51_extensions.htm

  • Chandra,

    Is it just that English is not your first language, or do you really not understand the word "OVERFLOW" ?

    See: http://www.keil.com/forum/docs/thread7364.asp

    As Christoph says, the data in the lookup table is constant - it will not change at run-time - so you should put it into CODE space.

    You might find that you exceed the code space limit of the evaluation version, though...

  • MAIN\FORUM.C(19): error C241: 'main': auto segment too large
    main\forum.c - 1 Error(s), 0 Warning(s). 
    All the error messages are described in the Manual:

    http://www.keil.com/support/man/docs/c51/c51_c241.htm

    In uVision, just click the message and press F1 - it will show you help for that message.

  • thank you sir

    thank you for your valueble answers

    Hear in my project iam using 4 seven segment display for to display the pressure.

    up to now iam displaying the pressure on the serial window.

    pleace tell how to display the data on 7 segment display with out using printf statement.

    Because printf is taking lot of memory .

    regards

    chandu

  • "in my project iam using 4 seven segment display for to display the pressure."

    Do you mean a four-digit 7-segment display?

    If so, how do you plan to display, for example, "4.1E-4" on four 7-segment digits:

    4. = 1st digit
    1  = 2nd digit
    E  = 3rd digit
    -  = 4th digit
    4  = Oops! no more digits!!
    Or, as all the values contain the 'E' and '-', will they just be permanently marked on the panel?
    In which case, you only need 3 digits - not 4!

    "please tell how to..."

    No - you need to learn how to think these things out for yourself!

    The Lookup-Table technique can still be used; you could even still make it a table of strings.
    Instead of using printf, you just write the 1st character of the string to the left-most 7-segment digit, and so on...

    Using a table of strings for this is probably quite inefficient, because:
    1. each string has a null-terminator added, which you don't need;
    2. the actual table contains pointers to the strings (textbook basics) - so these pointers have to be stored in addition to the actual strings, With such small strings, this is a significant overhead!

    A more compact way would be to use a two-dimensional array...

    Textbook time, again!

    "Because printf is taking lot of memory"

    Yes, printf does take quite a lot of memory.
    But, in this case are you sure that it's printf that's the real problem - or is it just the size of the table?

  • "in my project iam using 4 seven segment display for to display the pressure."

    Do you mean a four-digit 7-segment display?

    If so, how do you plan to display, for example, "4.1E-4" on four 7-segment digits:

    4. = 1st digit
    1  = 2nd digit
    E  = 3rd digit
    -  = 4th digit
    4  = Oops! no more digits!!
    Or, as all the values contain the 'E' and '-', will they just be permanently marked on the panel?
    In which case, you only need 3 digits - not 4!

    "please tell how to..."

    No - you need to learn how to think these things out for yourself!

    The Lookup-Table technique can still be used; you could even still make it a table of strings.
    Instead of using printf, you just write the 1st character of the string to the left-most 7-segment digit, and so on...

    Using a table of strings for this is probably quite inefficient, because:
    1. each string has a null-terminator added, which you don't need;
    2. the actual table contains pointers to the strings (textbook basics) - so these pointers have to be stored in addition to the actual strings, With such small strings, this is a significant overhead!

    A more compact way would be to use a two-dimensional array...

    Textbook time, again!

    "Because printf is taking lot of memory"

    Yes, printf does take quite a lot of memory.
    But, in this case are you sure that it's printf that's the real problem - or is it just the size of the table?

  • Textbook time, again!

    Andy, do not come to the US, we have laws against cruel and unusual punishment :)

    Erik

  • we have laws against cruel and unusual punishment

    Textbook time may be cruel, but it is certainly not unusual, and therefore perfectly fine. :)

  • "Textbook time ... is certainly not unusual"

    It seems to be becoming increasingly unusual amongst today's students... :-(

  • hi sir

    this is my code

    {
    unsigned int voltage;
    unsigned char *pressure_string[] ={"3.07E-12","1.22E-10","6.56E-10");
    v=0x02;
    voltage=voltage*50;
    P1=string[voltage];
    }


    For voltage=0x02 carresponding pressure is

    6.56E-10 from table.

    that is P1=6.56E-10;

    sir my doubt is PORT 1 well takes only 1 byte

    (8bits) then how it takes 6.56E-10;

    and how to devide the pressure 6.56E-10

    into "6",".=constant","5","6","E=constant",

    "-=constant","1","0" .

    sir here iam using seven numbers 7segment

    Led display for displaying the pressure.

    thank you sir

    Regards

    chandu

  • Hi sir

    how to divide the "string" into singal elements

    example:

    string={"3.56E-12") in to "3", "." ,"5","6","E","-","1","2".

    Thank you

    Regards

    chandu

  • Stop! Now!!

    You are struggling with absolutely basic concepts of both 'C' programming and, apparently, the hardware itself.

    You seriously need to set this project aside, go back to basics, and get a proper understanding in the 'C' Language

    Get yourself a good book, and study it:
    http://www.keil.com/books/8051books.asp
    http://www.8052.com/books.phtml


    "my doubt is PORT 1 well takes only 1 byte (8bits) ... i am using seven numbers 7segment LED display"

    Sure, all the 8051's ports are 8 bits (1 byte) wide.
    So how have you connected seven 7-Segment digits to your 8051?

    Obviously, the way you write stuff to the display will depend entirely on how it is connected to the 8051!!