Blinking the ADC output on LCD 16x2

Status
Not open for further replies.

ecaits

Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
579
Dear Friends,

I am getting proper output on lcd as per my ADC program.

But after every few microseconds, it blinks and take new value of ADC. I want to show continuous, i mean smooth change in ADC output on LCD.

How can I do that???
 

Filtering. A few microfarad capacitor at the input will do it..
 

Is it possible to do it by changing something in program???

- - - Updated - - -

Is it possible to do it by changing something in program???
 

I have connected one capacitor of 4.70 uf, 16 V between input and ground, but the capacitor charged by 5 V and that voltage given to input. What i do next??? plz suggest.

I have also attached program code file and video of lcd blinking for reference.
 

Attachments

  • lcd blinking.txt
    4.9 KB · Views: 72
  • LCD Blinking.rar
    11 MB · Views: 66
Last edited:

I just checked the .txt file. I didn't download the .rar file.

PORTA is set a output but RA0 is used for ADC and so TRISA should be 0x01.
In LCD strobe define add 500 us delay between

Code C - [expand]
1
LCD_EN = 1 and LCD_EN = 0


I didn't check ADCON0 and 1 configuration as you have not mentioned the PIC and Fosc you are using.

If only RA0/AN0 is used for ADC then you have to choose ADCON1 option such that all other PORTA pins are digital I/O type because you are using other pins for LCD (RS, RW, EN).

Your code executes only once and stucks in empty for(; loop and so ADC value is read only once and displayed once. ADC read and LCD display related codes should be inside for(; loop.

Also the CONFIG words are not set in code and it is set in IDE and I am sure WDT is enabled which is resetting the microcontroller and hence the display flickers and it is also the reason you are able to read the ADC value if it changes (when you change ADC input the MCU resets due to WDT and then new ADC value is being read otherwise the ADC value would never change after stucking at empty for(; loop). In IDE disable WDT and see - your ADC value will not change after reading once.
 
Last edited:

Dear Milan.Rajik,

Thank you very much for your valuable suggestion.

First of all, I am using PIC16F877 microcontroller and I have use ADCON0 = 0x41 to initialize the ADC module. I dont know which Fosc I should use. In current program, I have not use any Fosc in program.

I have checked that when I am disabling the WDT, at that time ADC value is not changing after reading once.

One more thing, I have also not used CONFIG word so how I need to use it?

Will you please suggest me in brief that what I have to make necessary changes in my program so that I can get the output on LCD without flickering???

Looking for your valuable support.
 

Zip and post your complete MPLAB HI-Tech C project files. What is the crystal frequency you are using (FOSC = Frequency of OSC)?

CONFIG bits can be set in IDE. Go to COnfigure > Configuration Bits... Menu item. Uncheck Configuration bits set in code and enable Power on Timer, disable WDT, enable BOR, OSC type to XT if 4 MHz or HS if > 4 MHz.

Go to docs sub folder of Hi-Tech C compiler folder and view the .html file for your device regarding setting CONFIG words in code.

See example Hi-Tech PICC projects at these links.

https://saeedsolutions.blogspot.in/2013/02/pic16f877-adc-code-proteus-simulation.html

https://saeedsolutions.blogspot.in/2012/11/pic16f877-lcd-code-proteus-simulation.html
 
Last edited:

Dear Milan.Rajik,

Plz find the rar file of my whole project.

I have not used any of crystal frequency.

Waiting for positive feedback.
 

There is no file attached. I have provided two links for Hi-Tech C code for ADC and LCD. Use them.
 

Dear Milan.Rajik,

Ohhh sorry, plz find attached file.
 

Attachments

  • Try Code.rar
    171.6 KB · Views: 60

Hi there is no termination in your program try to use a while(!); loop.

After your LCD and ADC initializations
pur
while(1)
{
LCD print code
}
That will avoid multiple time calling the initialization sequence
 

Dear Venkadesh_M,

I have tried it, but not getting the value. LCD just shows 0.000 value. I dont know why???
 

Dear Venkadesh_M,

Plz find the altered code...
 

Attachments

  • work.txt
    4.9 KB · Views: 79

If ADCON1 = 0x06 then ADC result is left justified. Change ADCON1 to 0x86;

Use the code at the link given in post #7.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…