pic 18f4580 and adc using mplab

Status
Not open for further replies.

shalini v

Newbie level 3
Joined
Sep 14, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
36
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:

how to calculate the step size and resolution
Means exactly what? You are displaying ADC results with 10 bit resolution, the relation between input voltage and ADC result is explained in the PIC datasheet.

Not mentioned in your post, but the code is using CCS C specific built-in functions, it's not compatible with generic MPLAB-X compiler.
 

You are asking about the ADC parameters? for that code doesn't needed. It can be checked in the datasheet itself.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…