+ Post New Thread
Results 1 to 4 of 4
  1. #1
    Member level 4
    Points: 1,606, Level: 9

    Join Date
    Aug 2007
    Location
    PAKISTAN
    Posts
    77
    Helped
    2 / 2
    Points
    1,606
    Level
    9

    16 bit division asm for 80c51

    hello forum!
    i want to convert the data i am getting from adc ic into voltage .if the data reaches ff it means we have 5v and so on.so the formula should be (adc_data*5)/ff how to write the code in assembly i can do it in c and bascom but i need to do it in assembly please help

    •   Alt13th January 2009, 10:01

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 160,151, Level: 95
    Awards:
    Downloads

    Join Date
    Oct 2004
    Location
    West Coast
    Posts
    7,943
    Helped
    2301 / 2301
    Points
    160,151
    Level
    95

    Re: 8051 assembly question

    Create a look-up-table and use the MOVC A, @A+DPTR instruction ..
    Here is an example:
    http://www.8052.com/faqs/119923

    Rgds,
    IanP



    •   Alt13th January 2009, 14:06

      advertising

        
       

  3. #3
    Full Member level 3
    Points: 2,298, Level: 11
    amol_shah's Avatar
    Join Date
    Apr 2008
    Location
    Nasik
    Posts
    150
    Helped
    31 / 31
    Points
    2,298
    Level
    11

    Re: 8051 assembly question

    u can calculate it, i guess ur using 8-bit adc with Vref+ as 5v and Vref- as 0v
    so the step size is approx 20mv,
    use two ram location say voltage_msb and voltage_lsb, where the voltage is stored in milli volts in BCD format. decrement the adc reading by 1 and add 20 to it keep repeating this loop till the adc reading becomes 0.
    This method is much simpler are less tedious than making a lookup table

    check :
    http://www.dnatechindia.com/index.php/Code-Library/
    for sample 8051 codes



    •   Alt13th January 2009, 17:52

      advertising

        
       

  4. #4
    Full Member level 2
    Points: 2,014, Level: 10

    Join Date
    Jan 2009
    Location
    Pakistan
    Posts
    127
    Helped
    10 / 10
    Points
    2,014
    Level
    10

    8051 assembly question

    You can place the ADC_DATA in a ACC and the number (05h) in (B) register and use the multiply instruction (mul a,b) for multiplication and after the execution of this instruction you get the result in accumulator. and for division move the number (#0ffh) in (B) register and use (div a,b). if your result of multiplication is greater then 8 bits then your result will be placed in A and B registers and you should take care of it. you should handle the 16 bit division in 2 steps. like divide the number by 2,4 to bring it in the range of 8 bits. by shifting right and divide them in 2 or 4 steps.



+ Post New Thread
Please login