In: Computer Science
Write an ALP to get the data rom channel 0 of the ADC of Atmega 32 and display the result on port A and port B . This should continue for ever.
ADC (Analog to Digital converter) is the most widely used device in embedded systems which is designed especially for data acquisition. In AVR ATmega series normally 10-bit ADC is inbuilt in the controller.
Let us see how to use the ADC of AVR ATmega16 / ATmega32.
ATmega16/32 supports eight ADC channels, means we can connect eight analogue inputs at a time. ADC channel 0 to channel 7 are present on PORTA. i.e. Pin no.33 to 40.
The controller has 10 bit ADC, means we will get digital output 0 to 1023.
i.e. When the input is 0V, the digital output will be 0V & when input is 5V (and Vref=5V), we will get the highest digital output corresponding to 1023 steps, which is 5V.
So controller ADC has 1023 steps and
So Digital data output will be Dout = Vin / step size.