hareeshchamiyar
Newbie level 4
am trying to make a project for 230 ac voltage measuring by dspic30f2010 and lcd.but didn't get the output on my bread board.am using mikroc pro.and the lcd is 16x1.
please anyone help me.
here is my program
please anyone help me.
here is my program
Code:
// LCD module connections
sbit LCD_RS at LATD0_bit;
sbit LCD_EN at LATD1_bit;
sbit LCD_D4 at LATE0_bit;
sbit LCD_D5 at LATE1_bit;
sbit LCD_D6 at LATE2_bit;
sbit LCD_D7 at LATE3_bit;
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISE0_bit;
sbit LCD_D5_Direction at TRISE1_bit;
sbit LCD_D6_Direction at TRISE2_bit;
sbit LCD_D7_Direction at TRISE3_bit;
// End LCD module connections
unsigned char ch;
unsigned int adc_rd;
char *text;
long tlong;
void main() {
ADPCFG = 0xFFFF;
TRISB = 0xFF; // PORTB is input
Lcd_Init();
LCD_Cmd(_LCD_CURSOR_OFF); // send command to LCD (cursor off)
LCD_Cmd(_LCD_CLEAR); // send command to LCD (clear LCD)
text = "AUREEMAS"; // assign text to string
LCD_Out(1,1,text); // print string a on LCD, 1st row, 1st column
Delay_ms(2000);
LCD_Cmd(_LCD_CLEAR);
text = "VOLTAGE"; // assign text to string
LCD_Out(1,1,text); // print string a on LCD, 2nd row, 1st column
Delay_ms(2000);
LCD_Cmd(_LCD_CLEAR);
text = "V:"; // assign text to string
while (1) {
adc_rd = ADC1_read(1); // get ADC value from 2nd channel
LCD_Out(1,1,text); // print string a on LCD, 2nd row, 1st column
tlong = (long)adc_rd * 5000; // covert adc reading to milivolts
tlong = tlong / 4011; // 0..1023 -> 0-5000mV
ch = tlong / 1000; // extract volts digit
LCD_Chr(1,3,48+ch); // write ASCII digit at 2nd row, 9th column
LCD_Chr_CP('.');
ch = (tlong / 100) % 10; // extract 0.1 volts digit
LCD_Chr_CP(48+ch); // write ASCII digit at cursor point
ch = (tlong / 10) % 10; // extract 0.01 volts digit
LCD_Chr_CP(48+ch); // write ASCII digit at cursor point
LCD_Chr_CP('V');
Delay_ms(1);
}
}
Last edited by a moderator: