ADC input reading on LCD without flicker

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

ADC input reading on LCD without flicker

Post by fotios »

Forgive me if this topic has been resolved already. Please don't get me like arrogant, i am novice in FlowCode and i know few things about. This is a sample code for which helped me medelec so the half of idea belongs to medelec. Normally, i had to post this code in other topic in which medelec asked me for the method that i use but this topic has an unfit title "Problem....etc" thus i decided to open a new topic because this code it is a solution.
The code example, permits to we convert the ADC input reading as integer from 0 to 1024, to a number in the scale of 0 to 100%. There is a routine as well, which prevents the indication on the LCD from flicker. Because my ignorance of how to use C code, i selected the easy way of using the EEPROM for asistance in the relativelly simple calculations. I tried the code not only in simulation mode, but as well in practice by programming a P16F887. It works just fine.
Thank you medelec.
Fotios
Attachments
ADC_reading.fcf
(11 KiB) Downloaded 258 times
Best Regards FOTIS ANAGNOSTOU

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times
Contact:

Re: ADC input reading on LCD without flicker

Post by wayne millard »

This should fix the proplem.
zero was not display on power on fix that.
the flicker is fixed by puting a large delay after writing to display this will keep display on
of longer before clearing the display.
Attachments
ADC_reading v2.fcf
Try this see if this fixs the problem
(11 KiB) Downloaded 252 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: ADC input reading on LCD without flicker

Post by medelec35 »

Hello fotios.
No one would think you are arrogant. If you have tried something and does not work the way you have intended, then we welcome posts about it.
Any way I have corrected minor errors. I am assuming you have not tried the version you posted on real hardware since you have also left out LCD Display start macro. That is vital for LCD initialization on hardware, not needed on simulation only.
Any way, I have tried this on real hardware and there is no flickering at all. You also need to remember that LCD refresh on simulation is much slower than on real hardware. So if you see flickering on simulation, that does not necessary mean you will see flickering on your hardware, due to persistence of vision.

Hope this is what you are after.
Attachments
ADC_reading_Modified.fcf
(15.5 KiB) Downloaded 278 times
Martin

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: ADC input reading on LCD without flicker

Post by fotios »

@ wayne millard
Thanks Wayne for the suggestion. I am not sure that i have understood why the second "calculation" box in the main routine where all variables are zeroed, but... i will try it in actual hardware. Maybe i am missing something that i haven't noticed yet. Please see in my next post (to medelec) some further explanations.
Greetings
Fotios
Last edited by fotios on Sat Jul 31, 2010 8:31 pm, edited 1 time in total.
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: ADC input reading on LCD without flicker

Post by fotios »

@ medelec
Thanks medelec for your attention and the assistance in my effort. Yes, you are right, i haven't tried this sample code on real hardware. I forgot to refer that it is only a partial code which i developed thru "copy and paste" from the real code of my project. You may know, that i decided from the begining to not use the ICD of FlowCode. Instead this, i made first the actual hardware setup around the EB006, and when a part of the code of project is completed, after a simulation, i compile the code in the actual P16F887 and i try in real mode. If there are errors, i correct those in Flowchart and then recompile the actual PIC. So, when i said that the code is working properly in real mode that was true. In the main routine of my real code there is the command "Start LCD" of course. BTW, you are very observing!
If you remember from my previous posts, i refer that the code which i develop is to control a Hi-Fi Preamplifier. For this, i was based on the ready project of Matrix, a "Simple Hi-Fi". This project, presents flickering of number either in simulation or in real mode. Up to now, i have abolished the TMR0 interrupt which used to update the volume indication. Instead this, i have included in the main loop the "Call macro ADC_READING". I have two interrupts already, the PortB IOC and the PortB0 for the IR receiver
As for your corrections, i have to admit that you resolved a minor problem that i noticed during the real mode execution. Although i haven't flickering, when i turn the potentiometer (1KΩ lin) by hand, there are mid places of pot. where the indication flickers from e.g. 47 to 48 continuously. Obviously, during the ADC convertion and the calculations the equation of difference that i use (VOL_DIFF = VOLUME - VOLUME_SCAN) may result in a non integer number (i.e. fractional like 47.5). Thus the expresion that i use in the decision "If VOL_DIFF = 0" it is changeable - or very sensitive - in these negligible variations of potentiometer. Moreover the potentiometer is a passive part with analog output, thus be it so has not touched, a litle dirt on its wipper can change a little the voltage which is injected in the ADC input of MCU. Thus, i suppose that in such a case the resulted number it confuses the MPU of LCD which can't decide definitelly to write a number either 47 or 48 on the display.
Instead, the expression that you use in the decision "If (VOL_DIFF>0) OR (VOL_DIFF<0)" it takes into account only integer numbers thus slight variations of pot. are rejected. Nice mathematical trick! I did the modification in the concrette decision of my code, and the problem resolved.
I would like to upload the code (better what i made up to now) but is incomplette. I have 2 days of work to finish it, and after this i will upload the whole *fcf project.
Thanks again medelec and have a nice weekend.
Fotios
Best Regards FOTIS ANAGNOSTOU

User avatar
Dutchie_World_Wide
Posts: 31
Joined: Thu Jul 08, 2010 8:52 am
Location: The Netherlands, or Thailand, or Gabon West Africa
Has thanked: 4 times
Been thanked: 3 times
Contact:

Re: ADC input reading on LCD without flicker

Post by Dutchie_World_Wide »

Hello Fotios,

My upload is pretty much the same as the one from Wayne Millard.
Accept that I change the positions of the VOLUME_SCAN you write to the display, if the VOLUME_SCAN gets smaller then 100 or smaller then 10.
This way if the number gets smaller then 100 or 10, the number written to the display, stays next to the % sign.

Dutchie_World_Wide
Attachments
ADC_reading v2_2.fcf
VOLUME_SCAN smaller then 100 or smaller then 10
(12.42 KiB) Downloaded 302 times
Dutchie

"This is not a bug, this is a feature!"

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: ADC input reading on LCD without flicker

Post by fotios »

@Dutchie
Hello Dutchie and thanks a lot for your interesting.
Wow! Very nice the trick with the sequential decision branches. Yes, the Volume number appearance is more elegant with your way than mine. It is exactly as it should be for the view in which we are used, i.e. the tenth and hundred digits of a number when it goes increased must be added from right to left and when it goes decreased the digits must be subtracted from left to right. The unit digit should be stay beside the % allways. Thanks for the trick. I will apply it in my code imediatelly!
Greetings from Greece, and have a nice weekend
Fotios
Best Regards FOTIS ANAGNOSTOU

Post Reply