Page 1 of 1

EEPROM

Posted: Tue Apr 26, 2011 11:52 pm
by electron67
I want to make a counter LCD, but want store the last number, when off the counter; the problem is the eeprom, only accept 3 digit (255). The counter is of 0-9999. I use Flowcode4.

Re: EEPROM

Posted: Wed Apr 27, 2011 12:31 am
by medelec35
Hi electron67
You can store numbers form 0 to 32767 by using two EEPROM locations, which will be high bytes(0 to 255) and low bytes (0 to 255).
you can also retrieve the high and low bytes and convert back in to integer (0 to 32767)
For formulas see:
http://www.matrixmultimedia.com/mmforum ... igh#p20779
electron67 wrote:I use Flowcode4.
For your version of Flowcode, you should be asking questions in the correct Flowcode 4 topic area.
To do that see:
http://www.matrixmultimedia.com/support ... =602#p1235

Martin

Edit: If you get stuck, I can post a sample Flowchart for you.

Re: EEPROM

Posted: Wed Apr 27, 2011 3:21 pm
by electron67
THANK YOU, please you can post a sample Flowchart.

Re: EEPROM

Posted: Wed Apr 27, 2011 6:54 pm
by medelec35
Here is sample flowchart.
Hope it helps

Martin

Re: EEPROM

Posted: Wed Apr 27, 2011 9:10 pm
by electron67
Hello Martin
Thanks, but not is very clear; in my case, I have a display lcd, need have 2 counting in the same display......... I send you the flowchart. (speak spanish?)






ContadorLCDv9.fcf
(12.5 KiB) Downloaded 366 times

Re: EEPROM

Posted: Wed Apr 27, 2011 9:13 pm
by medelec35
electron67 wrote:Hello Martin
I send you the flowchart. (speak spanish?)
Sorry only speak english.......just :P :lol:

Re: EEPROM

Posted: Wed Apr 27, 2011 9:52 pm
by Spanish_dude
Hi, I could help you :mrgreen:

----

Hola, yo podria ayudar le :mrgreen:

Re: EEPROM

Posted: Wed Apr 27, 2011 10:03 pm
by medelec35
Here is your flowchart altered to store and retrieve numbers from 0 - 9999 as you required.

Note when you first run Flowchart EEPROM will have random numbers stored within it.
If the High bytes (locations 1 and 3) are to high, then you will get a negative number.
So you must change it's contents.
What I do in my software, is when I write to EEPROM, I write 2 different default numbers to 2 locations.
E.G 22 to loc 10 and 65 to loc 11.
Then If I need to read EEPROM ,if value of loc 10 = 22 AND value of loc 11 = 65 THEN I read EEPROM knowing its been previously wrote to.
If the two values at loc 10 and 11 are wrong, I know EEPROM has not been wrote to therefore will not read from it.

I use two locations since chance of both locations have two random numbers that match the correct numbers is very low indeed.

Martin

Re: EEPROM

Posted: Wed Apr 27, 2011 10:05 pm
by electron67
Te agradezco la ayuda; estoy tratando de llevar 2 cuentas en un display LCD; pero por lo que veo las variables las tomo como byte, las cambie a INT y perfectamente realizo la cuenta hasta 9999; pero pense en grabar la cuenta que lleva cada contador utilizando la memoria EEPROM pero solo llega el conteo hasta 255; hize los cambio que me señalo Martin pero no logro grabar mas de 255. Te envio el diagrama de flujo, a ver si detectas donde me estoy equivocando.

Re: EEPROM

Posted: Wed Apr 27, 2011 10:27 pm
by electron67
Martin

Thank you, I understand in I was wrong. :idea:



Spanish_dude

Te agradezco la ayuda con la ultima respuesta de Martin comprendi donde me equivocaba. Es de gran ayuda que alguien entienda el español en el foro; en algunas ocaciones no se puede expresar como uno quisiera en ingles. :)

Re: EEPROM

Posted: Wed Apr 27, 2011 10:28 pm
by medelec35
Hi electron67,

What I have posted (ContadorLCDv10.fcf) does what you want it to do.
You have to use two EEPROM locations to store numbers above 255, since 255 is the maximum value of each location.
so to store two interger numbers you must use 4 locations.

for a int number e.g 3456 put 128 in the low bytes (loc 0 and 2 of EEPROM) and 13 in the high bytes (loc 1 and 3 of EEPROM)

Then 3456 will be stored in EEPROM for both variables
Press buttons to increase numbers.
Then you can stop flowchart and restart it.
You will then find numbers 3456 will be read from EEPROM and displayed on your LCD.

The flowchart you posted will not work since you are only using 1 EEPROM to sore a number, so the maximum number you can store is 255 as stated above.

Martin


Edit: electron67,
We most have posted at the same time. but will leave this post for reference.

Re: EEPROM

Posted: Wed Apr 27, 2011 11:27 pm
by electron67
Hi Martin

One question more; if I want reset the EEPROM to 0, when the counter is 9999; But not programming another the PIC ? :idea:

Re: EEPROM

Posted: Thu Apr 28, 2011 12:00 am
by Spanish_dude
You'll need to check the value of your variable and do something like this:

Code: Select all

if (variable >= 9999)
{
    // write 0 to EEPROM on address 0, 1, 2 and 3
    variable = 0; // reset variable
}
----

Tendrá que comprobar el valor de la variable y hacer algo como esto:

Code: Select all

if (variable >= 9999)
{
    // escribir 0 en la memoria EEPROM al sitio 0, 1, 2 y 3
    variable = 0;
}
Best regards / Saludos,

Nicolas L. F.

Re: EEPROM

Posted: Thu Apr 28, 2011 3:55 pm
by electron67
Spanish_dude

No conozco el lenguaje C, pero trate de intercalar el procedimiento que me diste en el archivo .c, me marco 128 errores y no lo pude convertir a .hex. En que forma puedo intercalar el procedimiento en flowcode por medio de diagrama de flujo ?



I want reset the EEPROM to 0, when the counter is 9999; But not programming another time the PIC ? utilize flowchart.