ONG WEI GIAP WROTE:yes, i did. i even try wif the ICSP programmer socket. it also can detect the PIC chip.. i have bought 3 DIY project, 3 of the PIC chip having the same problem..
ONG WEI GIAP WROTE:i have done all the soldering. when i swticth on the circuit, the LCD and led(greed) light up but nothing is show in LCD. may i know how to solve this problem? besides, when i connect UIC00B to the cicuit and my laptop, MPLAB IDE shown BUILD SUCCESSFUL.. but when i use PICkit2 to read, it shown no devices is detected. i have to solve this problem urgently for presentation purpose. i am really highly appreciate the guilding for me to success running this system.
ONG WEI GIAP WROTE:i have done all the soldering. when i swticth on the circuit, the LCD and led(greed) light up but nothing is show in LCD. may i know how to solve this problem? besides, when i connect UIC00B to the cicuit and my laptop, MPLAB IDE shown BUILD SUCCESSFUL.. but when i use PICkit2 to read, it shown no devices is detected. i have to solve this problem urgently for presentation purpose. i am really highly appreciate the guilding for me to success running this system.
ober WROTE:Hi, all DIY project circuit, PCB and sample source code is being tested before we launched the particular DIY set. And for PR11, many have did it with success.
It might be polarity ? Anyway, please can you capture a photo of PCB board, top and bottom? Also with UIC00B connected.
//==================include=================================
#include <p18f4520.h>
#include <delays.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//===============define IO port=============================
#define lcd PORTD //edited
#define RS RA2
#define E RA5
#define CHANNEL0 0b00000001 // AN0
#define CHANNEL1 0b00000101 // AN1
#define buzzer RC5
#define fanA RC4
#define fanB RC3
#define ledA RC2
#define ledB RC1
unsigned short result;
unsigned short temp,tempA,tempB;
//==============FUNCTION PTOTOTYPE=========================
void e_pulse(void);
void delay(unsigned short i);
void send_char(unsigned char data);
void send_config(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void dis_num(unsigned long data);
void increment(unsigned long data);
void read_adc(void);
unsigned short read_temp(void);
//====================MAIN================================
void main(void)
{
ADRESH=0; //clear A/D result
ADRESL=0; //clear A/D result
ADCON1 = 0b00111101; // configure RA2 and RA5 as digital I/O
ADCON2 = 0b10001110; //// Set result right justified, manual acquisition time, Fosc/4
TRISA=0b11011011; //configure PORTA I/O direction
TRISB=0b00000000; //configure PORTB as output
TRISC=0b00000000; //configure PORTC as output//edited
TRISD=0b00000011; //configure PORTD I/O direction
PORTA=0;
PORTC=0;
while(1)
{
send_config(0b00000001); //clear display at lcd
send_config(0b00000010); //Lcd Return to home
send_config(0b00000110); //entry mode-cursor increase 1
send_config(0b00001100); //diplay on, cursor off and cursor blink off
send_config(0b00111000); //function set
lcd_goto(0); //cursor start from beginning
//display character on LCD
send_char('T ');
send_char('E ');
send_char('M');
send_char('P');
send_char('.');
send_char('A');
send_char('.');
send_char('=');
lcd_goto(20); //cursor go to 2nd line of the LCD
//display character on LCD
send_char('T ');
send_char('E ');
send_char('M');
send_char('P');
send_char('.');
send_char('B');
send_char('.');
send_char('=');
while(1) //infinity loop
{
//sensor A
ADCON0=CHANNEL0; //CHANNEL1=0b10001001
lcd_goto(8);
read_adc();
temp=read_temp();
dis_num(temp/10);
send_char('.');
dis_num(temp%10);
send_char(0b11011111);
send_char('C');
send_char(' ');
send_char(' ');
tempA=temp;
//sensor B
ADCON0=CHANNEL1; //CHANNEL0=0b10000001
lcd_goto(28);
read_adc();
temp=read_temp();
dis_num(temp/10);
send_char('.');
dis_num(temp%10);
send_char(0b11011111);
send_char('C');
send_char(' ');
send_char(' ');
tempB=temp;
if((tempA>=350)&&(tempB<400))
// ************************************************************************************************
{
// * LED A and Fan A activated only for *
PORTCbits.RC2=1;//ledA=1;
// * temperature A greater than 40'C *
PORTCbits.RC1=0;//ledB=0;
// * and temperature B less than 35'C *
PORTCbits.RC4=0;//fanA=1;
// *****************************************
PORTCbits.RC3=1;//fanB=0;COOLER FAN'LL BE ON
PORTCbits.RC5=0;//buzzer=0;
}
else if((tempA>=200) && (tempB<350))
// *****************************************
{
// * LED B and Fan B activated only for *
PORTCbits.RC2=0;//ledA=0;
// * temperature A less than 40'C and *
PORTCbits.RC1=1;//ledB=1;
// * temperature B greater than 35'C *
PORTCbits.RC4=1;//fanA=0;HEATER FAN'LL BE ON
// ********************************************
PORTCbits.RC3=0;//fanB=1;
PORTCbits.RC5=0;//buzzer=0;
}
else
// *****************************************************
{
// *All LED A & LED B, Fan A & Fan B and Buzzer *
PORTCbits.RC1=0;//ledB=0;
//*disactivated for temperature less than 40'C *
PORTCbits.RC2=0;//ledA=0;
//*and temperature greater than 30'C *
PORTCbits.RC4=0;//fanA=0;
// *****************************************************
PORTCbits.RC3=0;//fanB=0;
PORTCbits.RC5=0;//buzzer=0;
}
}
//==================subroutine LCD setting ==========================
}
}
void send_config(unsigned char data)
{
PORTAbits.RA2=0;//RS=0;
lcd=data;
delay(500);
e_pulse();
}
void e_pulse(void)
{
PORTAbits.RA5=1;//E=1;
delay(500);
PORTAbits.RA5=0;//E=0;
delay(500);
}
void send_char(unsigned char data)
{
PORTAbits.RA2=1;//RS=1;
lcd=data;
delay(500);
e_pulse();
}
void lcd_goto(unsigned char data)
{
if(data<16)
{
send_config(0x80+data);
}
else
{
data=data-20;
send_config(0xc0+data);
}
}
void lcd_clr(void)
{
PORTAbits.RA2=0;//RS=0;
send_config(0x01);
delay(600);
}
void dis_num(unsigned long data)
{
unsigned char hundred_thousand;
unsigned char ten_thousand;
unsigned char thousand;
unsigned char hundred;
unsigned char tenth;
hundred_thousand = data/100000;
data = data % 100000;
ten_thousand = data/10000;
data = data % 10000;
thousand = data / 1000;
data = data % 1000;
hundred = data / 100;
data = data % 100;
tenth = data / 10;
data = data % 10;
if(hundred_thousand>0)
{
send_char(hundred_thousand + 0x30); //0x30 added to become ASCII code
send_char(ten_thousand + 0x30);
send_char(thousand + 0x30);
send_char(hundred + 0x30);
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(ten_thousand>0)
{
send_char(ten_thousand + 0x30); //0x30 added to become ASCII code
send_char(thousand + 0x30);
send_char(hundred + 0x30);
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(thousand>0)
{
send_char(thousand + 0x30); //0x30 added to become ASCII code
send_char(hundred + 0x30);
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(hundred>0)
{
send_char(hundred + 0x30); //0x30 added to become ASCII code
send_char(tenth + 0x30);
send_char(data + 0x30);
}
else if(tenth>0)
{
send_char(tenth + 0x30); //0x30 added to become ASCII code
send_char(data + 0x30);
}
else send_char(data + 0x30); //0x30 added to become ASCII code
}
void increment(unsigned long data)
{
unsigned short j;
for(j=10;j>0;j--)
{ lcd_goto(32);
data=data+1;
dis_num(data);
delay(10000);
}
}
//==================subroutine ADC=========================
void read_adc(void)
{
unsigned short i;
unsigned long result_temp=0;
for(i=2000;i>0;i-=1) //looping 2000 times for getting average value
{
//ADGO = 1; //ADGO is the bit 2 of the ADCON0 register
//while(ADGO==1); //ADC start, ADGO=0 after finish ADC progress
ADCON0bits.GO = 1; // Start ADC
while(ADCON0bits.DONE); // ADC completed?
result=ADRESH;
result=result<<8; //shift to left for 8 bit
result=result|ADRESL; //10 bit result from ADC
result_temp+=result;
}
result = result_temp/1000; //getting average value
}
unsigned short read_temp(void)
{
unsigned short temp;
temp=result;
return temp;
}
Users browsing this forum: No registered users and 3 guests