doubt regarding adc&8051

Thread Starter

nv.vj1794

Joined Jun 5, 2014
14
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
 

ErnieM

Joined Apr 24, 2011
8,377
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!
 

shteii01

Joined Feb 19, 2010
4,644
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:

Thread Starter

nv.vj1794

Joined Jun 5, 2014
14
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 !
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 
Top