doubt regarding adc&8051

Discussion in 'Embedded Systems and Microcontrollers' started by nv.vj1794, Jun 5, 2014.

  1. nv.vj1794

    Thread Starter New Member

    Jun 5, 2014
    14
    0
    Hello,
    I have small doubt regarding the converted signal after it passes through the ADC and enters the uC.
    Is it possible to perform calculations using that data?
    Like for example I have an input voltage from a sensor that I have converted to a digital signal. Now I want to use this data in an algorithm and perform various calculations on it. Is it possible?

    Regards
    Vj
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Of course you can take the converter data and perform further calculations on it. It would be pretty useless not to be able to use the converter output.

    On some processors it is very useful to take the register where the converter result is placed and copy that to a "normal" memory location for ease of use.

    That is standard in PIC processors where the result is spread across two 8-bit registers. The separate numbers are combined into one larger type. I haven't used anything like a 8051 in decades so I don't remember.

    And welcome to the forums!
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,387
    497
    People do it every day.

    Let us say you have 8 bit ADC.
    The lowest value that ADC produces is 0.
    The highest value that ADC produces is 255.

    You input voltage varies from 0 to 5 volts.

    So what values are stored in 8051?
    If input to ADC is 0 volts, the value is 0.
    If input to ADC is 2.5 volts, the value is 127.
    If input to ADC is 5 volts, the value is 255.

    Now in the program of the 8051 you can convert the digital values to voltage values:
    Voltage Value=[(ADC Output)/255]*5
     
    Last edited: Jun 5, 2014
    absf likes this.
  4. nv.vj1794

    Thread Starter New Member

    Jun 5, 2014
    14
    0
    Thanks a lot for the clarification.
    Another doubt. If I want to add a value like 0.1V, instead of converting my digital output to voltage values can I convert the factor I want to add/sub to digital value based on the DAC step size?
    This is because I have to compare this value with a triangular waveform voltage to get a PWM !
     
  5. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Values such as 0.1 are quite difficult to handle. Natural or integer numbers are easy, but real numbers with fractional portions require float data types, which need extra memory and time to do the computations. They should be avoided whenever possible.

    A value such as 0.1 may translate into an integer number of least significant bits so it can be worked with directly. If not, always remember you are free to choose your units, meaning 0.1V is also 100 mV and also 100000 uV.
     
    nv.vj1794 likes this.
  6. nv.vj1794

    Thread Starter New Member

    Jun 5, 2014
    14
    0
    Thank you.
     
  7. nv.vj1794

    Thread Starter New Member

    Jun 5, 2014
    14
    0
    The output values from the ADC can I directly store them as int values or do they need to be stored as string?
     
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,387
    497
    Your choice. The simplest choice is to store them as integers.
     
    nv.vj1794 and ErnieM like this.
Loading...