stereo
Newbie level 6

here are my programming. this is a programme that read the voltage(max voltage 5v microcontroller) from analog to digital on the LCD screen.
by using potentiometer, the value can be adjusted to 1024(max) on the lcd. and it is = to 5v.
i really appreciate if someone could help me with this.
>instead of displaying in binary, can i display 5v?
>i would like to add on the value of current max 6A. so on the screen there will be two value. by adjusting the potentiometer to the max, there will be 5v and 6A.
thank you
im using mplab c18 and pic 18f4520
#include <p18f4520.h>
#include <delays.h>
#include <stdlib.h>
int result;
void Init_LCD(void);
void W_ctr_4bit(char);
void w_data_4bit(char);
#define LCD_DATA PORTD
#define LCD_RW
#define LCD_RS
#define LCD_E
unsigned char LCD_TEMP, i;
char MESS[11]= "convertion";
char MESS2[4]= " ";
void InterruptHandlerLow(void);
routine
#pragma code InterruptVectorLow= 0x018
void InterruptVectorLow(void) {
_asm
goto InterruptHandlerLow
routine
_endasm
}
#pragma code
#pragma interruptlow InterruptHandlerLow
void InterruptHandlerLow()
{
if(PIR1bits.TMR1IF){
Delay10TCYx(1);
ADCON0bits.GO=1;
while(ADCON0.bits.DONE);
result= ADRESH*256+ADRESL;
//result>>=4;
PORTB=result;
W_ctr_4bit(0xc0);
for(i=0; i<4;i++)
{W_data_4bit(MESS2);
}
W_ctr_4bit(0xc0);
itoa(result,MESS);
i=0;
while(MESS)
{
W_data_4bit(MESS);
i++;}
TMR1H=0x0b;
TMR1L=0xdc;
PIR1bits.TMR1IF=0;
}
}
void main()
{
TRISD=0;
TRISA=0b11110001;
TRISB=0b11110000;
ADCON0=0b00000001;
ADCON1=0b00001110;
ADCON2=0b10000100;
INTCONbits.GIE=0;
Init_LCD();
for(i=o;i<10;i++)
{
W_data_4bit(MESS);
}
PORTB=0b00000110;
RCONbots.IPEN=1;
IPR1bits.TMR1IP=0;
TMR1H=0x0b;
TMR1L=0xdc;
T1CON=0b11110001;
PIR1bits.TMR1IF=0;
PIR1bits.TMR1IE=1;
INCONbits.GIEL=1;
INCONbits.GIE=1;
while(1);
}
void Init_LCD()
{
Delay1kTCYx(15);
W_ctr_4bit(0x03);
Delay1kTCYx(5);
W_ctr_4bit(0x02);
W_ctr_4bit(0b00101000);
W_ctr_4bit(0b00001100);
W_ctr_4bit(0b00000110);
W_ctr_4bit(0b00000001);
}
void W_ctr_4bit(char x)
{
LCD_RW=0;
LCD_RS=0;
LCD_TEMP=x;
LCD_TEMP>>=4;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1);
LCD_TEMP=x;
LCD_TEMP &=0x0f;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1)
}
void W_ctr_4bit(char x)
{
LCD_RW=0;
LCD_RS=1;
LCD_TEMP=x;
LCD_TEMP>>=4;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1);
LCD_TEMP=x;
LCD_TEMP &=0x0f;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1)
}
by using potentiometer, the value can be adjusted to 1024(max) on the lcd. and it is = to 5v.
i really appreciate if someone could help me with this.
>instead of displaying in binary, can i display 5v?
>i would like to add on the value of current max 6A. so on the screen there will be two value. by adjusting the potentiometer to the max, there will be 5v and 6A.
thank you
im using mplab c18 and pic 18f4520
#include <p18f4520.h>
#include <delays.h>
#include <stdlib.h>
int result;
void Init_LCD(void);
void W_ctr_4bit(char);
void w_data_4bit(char);
#define LCD_DATA PORTD
#define LCD_RW
#define LCD_RS
#define LCD_E
unsigned char LCD_TEMP, i;
char MESS[11]= "convertion";
char MESS2[4]= " ";
void InterruptHandlerLow(void);
routine
#pragma code InterruptVectorLow= 0x018
void InterruptVectorLow(void) {
_asm
goto InterruptHandlerLow
routine
_endasm
}
#pragma code
#pragma interruptlow InterruptHandlerLow
void InterruptHandlerLow()
{
if(PIR1bits.TMR1IF){
Delay10TCYx(1);
ADCON0bits.GO=1;
while(ADCON0.bits.DONE);
result= ADRESH*256+ADRESL;
//result>>=4;
PORTB=result;
W_ctr_4bit(0xc0);
for(i=0; i<4;i++)
{W_data_4bit(MESS2);
}
W_ctr_4bit(0xc0);
itoa(result,MESS);
i=0;
while(MESS)
{
W_data_4bit(MESS);
i++;}
TMR1H=0x0b;
TMR1L=0xdc;
PIR1bits.TMR1IF=0;
}
}
void main()
{
TRISD=0;
TRISA=0b11110001;
TRISB=0b11110000;
ADCON0=0b00000001;
ADCON1=0b00001110;
ADCON2=0b10000100;
INTCONbits.GIE=0;
Init_LCD();
for(i=o;i<10;i++)
{
W_data_4bit(MESS);
}
PORTB=0b00000110;
RCONbots.IPEN=1;
IPR1bits.TMR1IP=0;
TMR1H=0x0b;
TMR1L=0xdc;
T1CON=0b11110001;
PIR1bits.TMR1IF=0;
PIR1bits.TMR1IE=1;
INCONbits.GIEL=1;
INCONbits.GIE=1;
while(1);
}
void Init_LCD()
{
Delay1kTCYx(15);
W_ctr_4bit(0x03);
Delay1kTCYx(5);
W_ctr_4bit(0x02);
W_ctr_4bit(0b00101000);
W_ctr_4bit(0b00001100);
W_ctr_4bit(0b00000110);
W_ctr_4bit(0b00000001);
}
void W_ctr_4bit(char x)
{
LCD_RW=0;
LCD_RS=0;
LCD_TEMP=x;
LCD_TEMP>>=4;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1);
LCD_TEMP=x;
LCD_TEMP &=0x0f;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1)
}
void W_ctr_4bit(char x)
{
LCD_RW=0;
LCD_RS=1;
LCD_TEMP=x;
LCD_TEMP>>=4;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1);
LCD_TEMP=x;
LCD_TEMP &=0x0f;
LCD_E=1;
LCD_DATA=LCD_TEMP;
Delay1KTCYx(1);
LCD_E=0;
Delay1KTCYx(1)
}