CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problems in LCD 16x2 showing..

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
matcobra



Joined: 14 Feb 2011
Posts: 8

View user's profile Send private message

problems in LCD 16x2 showing..
PostPosted: Tue Mar 08, 2011 6:20 pm     Reply with quote

hello, anyone can help my problem where in the simulation part I can show the lcd showing but in real part there are still problems where lcd is blinking not functional well...

Here my code:
Code:

//////////////////////////////////////////////////////////////////////
//
// File: coding3.c
//
// Description:
//
//   Uses the ADC displaying results on the LCD.
//
// Compiler :CCS C complier v.4
//       
// 
// Note Testing:
//
//   Tested on 16F877A
//
//   Target : 16F877A
//
// Accuracy : Not very accurate.
//
// Writer:Ahmad Kamil Bin Mat Hussin a.k.a mat cobra (A122459)
//
//////////////////////////////////////////////////////////////////////

#include <16F877A.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=2400, xmit=PIN_C6, rcv=PIN_C7, PARITY=N, BITS=8)

#include <lcd.c>
#define x input (pin_b0) // pH output
#define y input (pin_b1)// voltage output

void main()
{

int16 adc_value;
setup_adc_ports(ADC_CLOCK_INTERNAL);
setup_adc(ADC_CLOCK_DIV_8);

while(1)

{
float volt;
lcd_init();
set_adc_channel(0);

adc_value=read_adc();
volt=((float)(adc_value*10)/1023.0);
lcd_putc("\f   PHi\n");   

if(x==1)
{
   if ((volt>5.00) && (volt<=7.50))
      printf(lcd_putc,"PH:%3.2fsweet",volt);
   else if((volt>3.00) && (volt<=5.00))
         printf(lcd_putc,"PH:%3.2fsweetsour",volt);
   else if((volt>0.00) && (volt<=3.00))
         printf(lcd_putc,"PH:%3.2fsour",volt);
   else {printf(lcd_putc,"NULL");}
}
if(y==1)
 {
   printf(lcd_putc,"voltage=%f\n",volt);
 }
}
}
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Mar 08, 2011 7:58 pm     Reply with quote

Hi,

Without studying your code too closely, my guess is that you are encountering a button "bounce" problem. When a physical button is pressed, it has a tendency to "chatter" (open and close repeatedly) for a time before becoming stable. There are numerous hardware and software methods to "debounce" a pushbutton, but I prefer the software method. I use the "button" function that has been posted here on the forum previously.

How are your pushbuttons wired? The most common use of a button input uses a NO (normally open) pushbutton with one side directly wired to an input pin on the PIC, and the other side connected to GND. The input pin of the PIC should have a pull-up resistor to Vcc. The input pin therefore will normally be "high", and go "low" when the button is pressed. Don't forget, you still need to debounce the input!

One other thing. You already had a thread going on this project, so you should use the original, rather than creating a new one!

Good Luck!

John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group