lcd refreshing

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Darren.Smith
Flowcode V4 User
Posts: 38
Joined: Thu Feb 24, 2011 4:38 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

lcd refreshing

Post by Darren.Smith »

high guys, just written this piece of code, basically it is a counter which is displayed on an lcd display, then when a button is pressed it captures the time it occured to the internal eeprom, i have never used the lcd component or the eeprom component so have a couple of questions, the first being when running the simulation the lcd seems to be very flashy, would i need to put a delay in maybe to slow it down to smooth it out? second question is a random one, is it possible to reset the program to a set point, or does the reset always take you to the beginning of the code, what i would like to be able to do is to keep the timer running while the data that is stored in the eeprom is displayed, then to be able to jump back to near the start of the code, but not actually to the beginning....


cheers
Dazza
Noc Temp.fcf
(39.68 KiB) Downloaded 251 times

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: lcd refreshing

Post by DavidA »

For your first question a delay does help if the lcd is refreshing too fast, or careful use of the cursor macro can be used to provide a consistent display depending on the code.

Ive not looked at the fcf file but if you want to have the code start at different positions on reset you could potentially have a section in eeprom that acts like a "save point" at different parts of the code, loading a value into eeprom and having the code "jump" to that "save point".

Im sure someone else has a more elegant solution!

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: lcd refreshing

Post by JonnyW »

Hi. Yes, it is possible to create a 'save point' but essentially what you are saving is your data. It is relatively easy to get back to a point in your code near the start if it is designed to do so but your start point is always the same. Restoring your 'persistent' data is the key.

You would not want to start from any other point than the start of Main() anyway, as this is usually where your initialisation code is - claim interrupts, start the LCD, etc.

Don't store the EEPROM data too often, as I think you will eventually wear it out, though there are ways to store regularly without wearing it out. It also increases the chance of your system rebooting half way through an EEPROM write, which is never good. Again, there are ways to avoid this, or at least minimize the chances.

Typically what you would have is code like:

Code: Select all

Main()
  Initialise_Global_Variable_Defaults()
  Setup_HW_And_Interrupts()
  Load_Data_From_EEPROM()
  Enter_Program_Loop()

On_Data_Changed_Macro()
  Store_Data_In_EEPROM()
What version of Flowcode are you using, out of interest?

Jonny

Darren.Smith
Flowcode V4 User
Posts: 38
Joined: Thu Feb 24, 2011 4:38 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: lcd refreshing

Post by Darren.Smith »

hi there, i am currently using version 14, if you have looked at the fcf file i uploaded, i must first apologise as it is not the correct file, i wrote alot more code and for some reason it has not saved it....doh

Darren.Smith
Flowcode V4 User
Posts: 38
Joined: Thu Feb 24, 2011 4:38 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: lcd refreshing

Post by Darren.Smith »

right i did manage to get everything working using the flowcode attached. i changed it from eeprom to using variables, which i believe get stored in ram on the chip, is there anyway to see how much ram is left or is it about making a calculation and adding up....?????

Next problem i have got is that i did have it working on the eboo6 with lcd, keypad, leds, and switchs attached... the problem is that now the lcd does not seem to work at all. i can adjust the contrast and all i can see is nothing going to black squares as it is adjusted...

another quick question is does anyone know about setting the offset on timer 0 on a 18f46k20...normally i would use tmr0 = 6; in c code block but when compiling it says unknown identifier are these chips alot different to 16f series? i only chose this pic as it seemed to have alot more ram than the 16f series


cheers
dazza
Data Logger.fcf
(55.78 KiB) Downloaded 218 times

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

Re: lcd refreshing

Post by medelec35 »

Darren.Smith wrote:normally i would use tmr0 = 6; in c code block but when compiling it says unknown identifier
Hi Darren,
Timer0 on different chips can be 8bit or 16bit
So if tmr0=6; does not work then try tmr0l=6; (l = lower case L)
Martin

Darren.Smith
Flowcode V4 User
Posts: 38
Joined: Thu Feb 24, 2011 4:38 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: lcd refreshing

Post by Darren.Smith »

cheers martin,
can now compile to hex with that chip, did wonder what the high and low bit was, next prob is when using ppp3 it does not recognize the chip and a new box pops up asking for id...
what a day today is being one problem after the other..
sorry gonna try and pick your brains, am wondering if there is a bit or address where you can read to see how full the ram is, way above my level i think but would be nice for this little project as am going to be storing data after data so at some point i will reach a limit, would be good to know before i get to that limit...

cheers again for the reply a simple explanation and everything becomes clear..


cheers
dazza

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

Re: lcd refreshing

Post by medelec35 »

Your welcome ~Darren.
one comment about using tmr0=6; or tmr0l=6;
Sean suggested using tmr0l += 6 or (tmr0 += 6 of course)
See:
http://www.matrixmultimedia.com/mmforum ... 859#p15859


Martin
Martin

Post Reply