How to transform non-digital data into digital data

Asked

Viewed 6,826 times

9

I would like to know how you would develop a software that displays the statistics of a car for example. Speed is not a digital data until I turn it into one. How to do it ? Is microcontroller, Arduine plates used (etc)? How this is done?

1 answer

18


There is something called Analog/Digital Conversion.

What is Analog/Digital Conversion?

This technique involves the use of sensors, sampling rate and mathematical calculations and a Converter A/D, to transform an analog greatness such as temperature, pressure, speed (etc.) into a digital greatness.

Internally in microcontrollers there is an important component called A/D Comparator or or Converter A/D. It is responsible for converting a voltage level (an analog value) to a digital value. In the case of Arduino this value varies between 0 and 5v and the converted value has a 10bit resolution.

What is resolution?

With these variations in voltage levels, a microcontroller can perform a reading and then convert it to a digital value, this is done by the A/D comparators, and after the microcontroller performs the reading it is compared and converted so that it fits in a limited number of bits. The amount of bits is the resolution. The higher the resolution, the more accurate the value compared. Arduino has a 10-bit resolution, so the analog values read (0 to 5v) are converted to digital values from 0 to 1023 (2 10-1). In a very simple example, we have to:

  1. 0v corresponds to 0.
  2. 5v corresponds to 1023.
  3. 2,5v corresponds to 511.
  4. 1,25v corresponds to 255

After the value is read and converted, the content of this read is stored in some microcontroller logger and you can recover this value later and use it.

In more robust microcontrollers, for use in medical equipment, for example, the resolution of A/D Comparators is usually quite high. I’ve seen cases of 16 to 18 bits, a very high number.

What is sampling rate?

According to the Wikipedia, sampling rate is the amount of samples of an analog signal collected in a given unit of time, for conversion into a digital signal. Being a frequency, it is commonly measured in Hertz (Hz).

Samples are the values of an analog signal measured at a given instant. The sample capture process is called signal sampling.

Therefore, the higher the number of signal samples, the more accurate it will be.

Theory:

Imagine the following circuit:

O CIRCUITO INTERNO DO CONVERSOR A/D

Now imagine that a sensor is connected to the input of this A/D. Converter as the sensor varies the voltage level, we have a variation in the Leds that will be lit. Basically this is it, but in a 10-bit A/D converter, we have 1024 possible read combinations and therefore all this is done in a much more sophisticated way, using filters for noise and other things that do not fit here.

Software:

Here’s a simple example of an analog reading for Arduino:

void setup() {
  //Inicializa a comunicação serial com velocidade de 9600 bits por segundo
  Serial.begin(9600);
}

void loop() {
  //Lê o valor do pino analógico A0 e armazena numa variável
  int valorLido = analogRead(A0);
  //Escreve o valor lido na serial
  Serial.println(valorLido);
  delay(1);   //Espera 1ms para a próxima leitura
}

Final Considerations

Therefore, if you want to make the value of the ambient temperature and use a sensor that varies 10mV every 1ºC, as is the case of LM35. You would read the analog signal, which would be between 0 and 1023 and calculate the corresponding temperature as shown below:

  • 0~1023 = 1024 values.
  • 0~5v = 500 values (10mV each)
  • 1v = 100 * 10mv

soon:

500 <=> 1024 x <=> 1

1024x = 500

x = 500/1024

x= 0.0048828125 (Conversion factor)

Temperature = (Read value * Conversion factor) * 100 Or simply:

Temperature = (Read Value * 0.48828125)

In this way, we find the temperature value through the value read by the analog sensor, which varies its output in mV (millivolts). The A/D Converter converts this to a number of 10 bits (divided into 2 bytes) that varies from 0~1023 and we multiply the value obtained from the A/D Converters by the conversion factor, which was found by the simple 3x rule, thus resulting in temperature.

Sources:

  1. http://en.wikipedia.org/wiki/Sampling_rate
  2. http://pt.wikipedia.org/wiki/Converter_anal%C3%B3gico-digital
  3. http://www.newtoncbraga.com.br/index.php/como-funciona/1508-conversores-ad
  4. http://www.newtoncbraga.com.br/index.php/como-funciona/1509-conversores-ad-2.html
  5. http://www.clubedohardware.com.br/artigos/1307
  6. http://arduino.cc/en/Tutorial/AnalogReadSerial
  • +1 - Excellent answer.

  • +1 Sensational response.

  • Great answer, very complete

Browser other questions tagged

You are not signed in. Login or sign up in order to post.