m
 
(30 intermediate revisions by 3 users not shown)
Line 4: Line 4:
 
In case of AVR/PIC/ARM or other high end controllers the inbuilt adc is used.
 
In case of AVR/PIC/ARM or other high end controllers the inbuilt adc is used.
 
In case of 8051/8052 as it doesn't have  an inbuilt adc, ADC0809(8-bit) adc is used.  
 
In case of 8051/8052 as it doesn't have  an inbuilt adc, ADC0809(8-bit) adc is used.  
 +
 +
  
  
 
==ADC_Init==
 
==ADC_Init==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{|{{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || void ADC_Init()
+
|Definition || void ADC_Init()
 
|-
 
|-
 
| Input Arguments || none
 
| Input Arguments || none
Line 27: Line 29:
  
 
==ADC_GetAdcValue==
 
==ADC_GetAdcValue==
{| class="wikitable"  style="colspan:1; background-color:#4682B4;"
+
{| {{Widget:LibCol}}
 
{{#Widget:LibTable}}
 
{{#Widget:LibTable}}
 
|-
 
|-
|Defination || uint16_t ADC_GetAdcValue(uint8_t channel)
+
|Definition ||<syntaxhighlight> uint16_t ADC_GetAdcValue(uint8_t var_adcChannel_u8)</syntaxhighlight>
 
|-
 
|-
| Input Arguments || uint8_t(channel number).
+
| Input Arguments || uint8_t : channel number
 
|-
 
|-
 
| Return Value|| uint16_t(10 bit ADC result)
 
| Return Value|| uint16_t(10 bit ADC result)
Line 46: Line 48:
  
 
==User guide==
 
==User guide==
#include <avr\io.h>  
+
<html>  
 
+
<script src="https://gist.github.com/Amritach/c2832a936ab1faf3117e.js"></script>
#include "lcd.h"  //User defined LCD library which contains the lcd routines
+
</html>
#include "adc.h"   //User defined library which contains the adc routines
+
 
+
 
+
/* start the main program */
+
void main()
+
{
+
  uint16_t adc_result0,adc_result1,adc_result2,adc_result3;
+
 
+
  /* Initialize the lcd before displaying any thing on the lcd */
+
    LCD_Init(8,LCD_16x2);
+
 
+
  /* Initialize the adc before starting the conversion */
+
    ADC_Init();
+
 
+
 
+
 
+
  /* Display the adc channel zero-Three values continuously */
+
  while(1)
+
    {
+
  /*Get the adc values of the first four channels(0-3) */
+
adc_result0= ADC_GetAdcValue(0);
+
adc_result1= ADC_GetAdcValue(1);
+
adc_result2= ADC_GetAdcValue(2);
+
adc_result3= ADC_GetAdcValue(3);
+
  
      /*Display the adc values on LCD*/
+
{{DISQUS}}
        LCD_GoToLine(LCD_LineZero);
+
LCD_Printf("ch0:%d ch1:%d ch2:%d ch3:%d",adc_result0,adc_result1,adc_result2,adc_result3);       
+
   
+
      }
+
  }
+

Latest revision as of 18:07, 30 May 2015

ADC

This library provides the functions for initializing the adc and to get the raw adc values. In case of AVR/PIC/ARM or other high end controllers the inbuilt adc is used. In case of 8051/8052 as it doesn't have an inbuilt adc, ADC0809(8-bit) adc is used.



ADC_Init

{{#Widget:LibTable}}
Definition void ADC_Init()
Input Arguments none
Return Value none
Description This function initializes the ADC module.
Usage void main()

{

ADC_Init();

}

ADC_GetAdcValue

{{#Widget:LibTable}}
Definition
 uint16_t ADC_GetAdcValue(uint8_t var_adcChannel_u8)
Input Arguments uint8_t : channel number
Return Value uint16_t(10 bit ADC result)
Description This function does the ADC conversion for the Selected Channel and returns the converted 10bit result.

The adc value per bit depends on the resolution of the ADC. For AVR/PIC(10-bit adc) the adc value per lsb will be 5/1023=0048v

Usage uint16_t adc_result;

adc_result = ADC_GetAdcValue(0); //Adc value for channel 0

User guide