shalini v
Newbie level 3
In the below mentioned program how to calculate the step size and resolution
Code:
/* program for adc channel 4 and its value display in LCD */
#include <18f4580.h>
#device ADC=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PC,errors)
#define LCD_ENABLE_PIN PIN_C5
#define LCD_RS_PIN PIN_C1
#define LCD_RW_PIN PIN_C0
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7
#include <lcd.c>
long value;
void main()
{
setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 4 );
set_tris_d(0x00);
set_tris_c(0x00);
output_d(0x00);
lcd_init();
Delay_ms(100);
lcd_gotoxy(1,1);
Delay_ms(1000);
lcd_putc("ADC TEST");
while(1)
{
value = Read_ADC();
lcd_gotoxy(1,2);
printf(lcd_putc,"ADC_HEX: %4LX ",value);
//printf(lcd_putc,"ADC_HEX: %u ",value);
delay_ms(1000);
}
}
Last edited by a moderator: