faari
Newbie level 1
- Joined
- Jul 1, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 11
I am writing a program which can take the analogue voltage reading and use adc to convert this signal into digital signal and display In terms of digital values. Initially I was using a digital lcd and displayed the above mentioned data on lcd. Now I need a program which can display the data in the form of a dial (gauge) on GLCD with a needle showing the change in voltage.
I am using
1. PIC – C compiler
2. 18F452 micro controller
3. HDM64GS12 GLCD with a KS0108 display controller. The HDM64GS12 is 128 by 64 pixels GLCD
4. I have driver file “HDM64GS12.c”. This file contains drivers for using a Hantronix HDM64GS12 .
5. I also have a graphics file named ”graphics.c”. It contains functions to draw lines, rectangles, bars, circles and text to a display
My code written for digital lcd is as shown below
Waiting for some help
I am using
1. PIC – C compiler
2. 18F452 micro controller
3. HDM64GS12 GLCD with a KS0108 display controller. The HDM64GS12 is 128 by 64 pixels GLCD
4. I have driver file “HDM64GS12.c”. This file contains drivers for using a Hantronix HDM64GS12 .
5. I also have a graphics file named ”graphics.c”. It contains functions to draw lines, rectangles, bars, circles and text to a display
My code written for digital lcd is as shown below
Code:
#include <18F452.h>
#device ADC=10
#fuses HS
#use delay(clock=12000000)
#include "lcd.c"
char lcd_string[20];
void print_lcd(char *str)
{
byte cntr=0;
for (cntr=0;cntr<20;cntr++)
lcd_putc(str[cntr]);
}
void PrintVoltage1(float m_Volts)
{
lcd_gotoxy(1,1);
sprintf(lcd_string,"Voltage1 = %3.3f ",m_Volts);
print_lcd(lcd_string);
}
void PrintVoltage2(float m_Volts)
{
lcd_gotoxy(1,2);
sprintf(lcd_string,"Voltage2 = %3.3f ",m_Volts);
print_lcd(lcd_string);
}
void main (void)
{
byte m_Cntr=0;
long m_Adc_Value=0;
float m_inp=0.0;
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
setup_adc(ADC_CLOCK_INTERNAL );
lcd_init();
while(1)
{
set_adc_channel(0); //ADC Channel 0
delay_ms(1); //Donot remove delay
m_Adc_Value=read_adc();
delay_ms(1); //ADC needs some time for reading input so Donot remove this delay
m_inp=(m_Adc_Value/1024.0)*5.0;
PrintVoltage1(m_inp);
set_adc_channel(1); //ADC Channel 1 for reading second input
delay_ms(1); //Donot remove delay
m_Adc_Value=read_adc();
delay_ms(1); //ADC needs some time for reading input Donot remove this delay
m_inp=(m_Adc_Value/1024.0)*5.0;
PrintVoltage2(m_inp);
delay_ms(100); //This delay Can be removed
}
while(1);
}
Waiting for some help
Last edited by a moderator: