PR 11

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

PR 11

Postby Cloud9 » Sat Nov 28, 2009 2:12 pm

Hi, i am testing PR 11, the temperature sensor around. After that, I decided to replace the PIC with PIC16f877a. However, when I test the LCD, it just shows grey block on the first line on the LCD. Can anyone explain why?

Following the tutorial, I reroute the pin address since PIC16f877a has more pins. The rest, LCD subroutine remain the same. SO, it looks like this,
LCD =>PIC
DB0~DB7=> RB1~RB7 (portB)
RS =>RD7
E =>RC7

THerefore, i edit the codes to look like this,
//==================include=================================
#include<pic.h>

//===============configuration==============================
__CONFIG (0x3F32);

//===============define IO port=============================
#define lcd PORTB //RB1-RB7
#define RS RD7
#define E RC7

//==============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================================
unsigned short result;
unsigned short temp,tempA;tempB

void main(void)
{
ADRESH=0; //clear A/D result
ADRESL=0; //clear A/D result

//setting ADCON1 Register
ADCON1=0b11000101; // A/D result right justified,
// configure RA2 and RA5 as digital I/O

TRISA=0b11011011; //configure PORTA I/O direction
TRISB=0b00000000; //configure PORTB as output
TRISC=0b00000000; //configure PORTC as output
TRISD=0b00000000; //configure PORTD as output
TRISE=0b00000000; //set portE as output

PORTA=0;
PORTB=0;
PORTC=0;
PORTD=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(' ');
send_char('T');
send_char('E');
send_char('M');
send_char('P');
send_char('.');
send_char('=');
.........................................................
I check the datasheet and it state that port B has a weak pull up, do i need to add extra code to disable it? The cades are the same, but I don't know why the LCD can't show anything. :(
Thanks.
Cloud9
Fledgling
 
Posts: 1
Joined: Sat Nov 28, 2009 1:52 pm

Re: PR 11

Postby sich » Sun Nov 29, 2009 3:32 pm

The weak pull-up is automatically turned off when the port pin is configured as an output.

Since your code writes " TEMP.=" to the first row of the LCD and you said the LCD shows grey at the first row, can you try to tune the contrast of the LCD? Hopefully it can be solved as simple as that :roll:

If that doesn't solve your problem, try check your schematic. Make sure every connection is correct. Since you said you're using 16F877A, so means that you're not using PR11 circuit board. So it's a very common where we might soldered the connections wrongly.

Then take out the analog function from your code to make your code simpler and easier to troubleshoot. Add additional functions after the LCD can display correctly.
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm


Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 6 guests