EasonOng
Newbie level 1
- Joined
- Mar 16, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 8
Hi everyone,
I am doing a Temperature Monitoring System by using PIC18F4550 with LCD Ampire 128x64.
I use CCS C of MPLab plugin to compile the .hex file. And simulate on Proteus.
My problem is : the display on Ampire 128x64 is unusual. Is there any configuration on Ampire need to done before simulate? I'm new to this.
Here is the design.
View attachment Project Design.rar
here is the coding.
- - - Updated - - -
Problem found. Set PIC to 20MHz.
I am doing a Temperature Monitoring System by using PIC18F4550 with LCD Ampire 128x64.
I use CCS C of MPLab plugin to compile the .hex file. And simulate on Proteus.
My problem is : the display on Ampire 128x64 is unusual. Is there any configuration on Ampire need to done before simulate? I'm new to this.
Here is the design.
View attachment Project Design.rar
here is the coding.
Code:
//Code starts from here
#include <18F4550.h>
#DEVICE ADC=10
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,VREGEN,NOBROWNOUT
#use delay(clock = 48000000)
#include <math.h>
#include <HDM64GS12.c>
#include <graphics.c>
unsigned char buffer[3];
unsigned char Celcius[] = "Celcius";
unsigned char warning[] = "Warning";
void displayTemperature(unsigned int adc)
{
sprintf(buffer,"%u",adc);
glcd_rect(45, 38, 55, 45, YES, OFF); // Clear the old voltage
//The above line removes the old values on lcd
glcd_text57(45, 38, buffer, 1, ON); // Write the new voltage
glcd_text57(70,38,Celcius,1,ON);
}
unsigned char name[] = "MY PROJECT";
unsigned char system1[] = "TEMP. MONITORING";
unsigned char system2[] = "SYSTEM!";
void main()
{
unsigned int16 adc;
unsigned int adc_old = 0;
unsigned int16 i,j;
int1 warn = FALSE;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
i=0;
glcd_init(ON);
delay_ms(10);
glcd_rect(1,25,126,35,NO,ON);
glcd_text57(70,38,Celcius,1,ON);
glcd_text57(20,0,system1,1,ON);
glcd_text57(45,10,system2,1,ON);
while(1)
{
adc = read_adc();
if(adc > 52)
{
adc = adc - 2;
}
else
{
//Don't do anything
}
adc = adc/2;
displayTemperature(adc);
delay_ms(10);
//Bar Start From this code
if(adc != adc_old)
{
glcd_rect(adc + 1, 26, adc_old + 1, 34, YES, OFF); // Clears the old bar
glcd_rect(1, 26, adc + 1, 34, YES, ON); // Draws a new bar
adc_old = adc;
if(adc > 40 )//&& !warn) //Check if over 40 degree celcius
{
//Controller comes here when Temperature is greater than 40 degree
//and warn is FALSE
//warn is defined as FALSE in earlier part of the program
//at the end of this loop warn is defined as TRUE
//so that program doesn't comes inside this if statement again
glcd_rect(5, 48, 126, 63, YES, OFF); // Draw a filled black rectangle
glcd_text57(25, 48, warning, 2, ON); // Write "Warning" on the LCD
}
else if(adc <=40)// && warn)
{
glcd_rect(5, 48, 126, 63, YES, OFF); // Draw a filled white rectangle
glcd_text57(5,55,name,1,ON);
}
#ifdef FAST_GLCD
glcd_update();
#else
delay_ms(100);
#endif
}
}
}
- - - Updated - - -
Problem found. Set PIC to 20MHz.