Most viewed

30 Nov 2011

AD Convertor


AD Convertor

Description

An analog to digital converter converts a analog input voltage into a digital value. The resolution of the converter indicates the number of discrete values it can produce. It is usually expressed in bits. For example, an ADC that encodes an analog input to one of 256 discrete values has a resolution of eight bits, 28 = 256. Most ADCs are linear, which means that they are designed to produce an output value that is a linear function of, i.e. proportional to, the input. In this example the AT Mega8 is used, it has 6 AD-converters which have a resolution of 10 bits so it has 210 = 1024 discrete values. In his example a potmeter is connected to the portC.0 of the Mega8 and a LCD module of 20x4 characters is connected to portD. The LCD module displays the values that are measured on the ADC port. The values are presented on the display as discrete values (0 to 1023), the percentage (0 to 100%) of the values and in a bargraph display.
AD Convertor

Software

The software of this example is written in the BASCOM AVR program language. BASCOM has build in commands for reading from an ADC port, the A/D convertor of the Mega8 has to be configured first before it can read:
    Configuration
  • ADC = single / ADC = free
  • PRESCALER - a numeric constant for the clock divider. AUTO lets the compiler generate the best value for the used crystal.
  • START ADC - puts the port in the ADC mode.
  • V = GETADC(channel) - reads the A/D value from the selected channel.
ADC_1.jpg
ADC_2.jpg
Downloads
FileDescriptionFile size
Download this file (AD Convertor.bas)AD Convert~.basAVR BASCOM source file2 Kb
Download this file (AD Convertor.HEX)AD Convert~.HEXhex file3 Kb

No comments:

Post a Comment

Confused? Feel free to ask

Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.

Note:
Please do not spam Spam comments will be deleted immediately upon my review.

 

Based on your view




You have to try this

This is trending now #