PDA

View Full Version : Code Problem - Strings/ LCD/ internal EEPROM



jorge
- 1st October 2006, 22:00
hi everybody ,
I am using this forum for the last 2 years and i ve always encountered good technical info and fantastic answers with the "search" option...but this time unfortunately no...
So i am posting for some help for me or others that came across with a problem like my own in the future:


I developing a bit confusing program, meteorological station with lots of info, temperature, humidity , etc etc, and everything works ok.
But now i ve to create a way to the user insert the name of the city/country , record it in the internal PIC eeprom and after display it ...with 2 buttons ( right ,left - change a letter & press both it records it in the EEPROM....
The commands itself - accessing the eeprom, write /reading it is a walk in the park with PBP, reading from buttons also , lcd , ok , …but in a “global view” how to with 2 buttons and LCD can i do such a simple task that is a user to record a Country or city name ( and not from a pre-existent table) and after be able do display it directly from the eeprom in the LCD...

Any “wiz kids” over there ;-) ?
Thanks a lot for any help as i am going crazy by the "no Strings available in PBP"

best regards,
JPin

PS: i ve tried array & ASCCI table and lookdown routines , etc ,etc , but always a not working routine so , any hint/advice/code by the pros ( and we always know their names (Melanie, Darrel , etc …) would be amazing for everyone that’s struggling with user defined messages to be stored and retrieved/displayed in the Lcd (Darrel already has great code for predefined messages , but those are pre-stored in the eeprom of the Pi c, with no user directly access/alter)

mister_e
- 1st October 2006, 22:24
For the buttons stuff, you may find some tips on the following thread
http://www.picbasic.co.uk/forum/showthread.php?t=3423&highlight=single+button+function

For the strings... no need for that, just place the characters in a array, then send the whole array content to the internal EEPROM at a specific adress.

Once you know where the data is located... you can access, read, write, modify etc etc.

jorge
- 1st October 2006, 22:41
yep, as you say “part by part” it is easy , but when you need to have to scroll with 2 buttons ever the alphabet and send one by one the user selected character to eeprom , this isn’t as easy as it seems … this is where things get “dirty”.
As for the rest, for example:

Write:
DATA $00,"Switch01",0
Reading:
For CounterA = 0 to 16
Read CounterA,value
If CounterA=0 then goto Main
LCDOUT value
Next CounterA

Works ok , but as a whole …i´ve not been able and not seen anything working …
The code for strings by Darrel is absolutely brilliant but it misses one point … all the strings are predefined ….not a single one can be user “ personalized”/edit/create (when pics´s in runtime) …this is where I am searching an answer.

Anyway thanks a lot Mister_E :-)

sayzer
- 2nd October 2006, 03:34
y....

Write:
DATA $00,"Switch01",0
Reading:
For CounterA = 0 to 16
Read CounterA,value
If CounterA=0 then goto Main
LCDOUT value
Next CounterA

Works ok , but as a whole …i´ve not been able and not seen anything working …

How could that work? it would exit the loop the first time it starts running.
CounterA=0 and then it exits FOR loop when CounterA=1.

Any missing condition there? or was it supposed to be like If Value=0 then goto Main ?

jorge
- 2nd October 2006, 11:08
you are right but this was only a "coderip" out off context.
the main problem was the one in the main post.
rgds,
Jorge

BigWumpus
- 2nd October 2006, 19:18
What is the problem ?

String in an array ?

Username var Byte(size_of_username)

Writing to LCD ?

LCDOUT STR Username\size_of_username

Writing to EEPROM ?

For I=0 to size_of_username:Write EEProm_Adress+I,Username[I]:Next I

???

jorge
- 2nd October 2006, 22:14
First of all thanks for your valuable hints.
:-)
I will sure try your approach
Although, i was thinking about Darrel’s approach to strings and a way of manipulate , edit/create them...
See the Darrels great post:
http://www.pbpgroup.com/modules/wfsection/article.php?articleid=10
but it lacks user defined messages to be stored in EEPROM...like cruising the alphabet and selecting/creating letter by letter the new text....or something like that.

Darrel Taylor
- 2nd October 2006, 23:37
Thanks jorge,

But, as you've already noticed. They are two different things entirely.

I think you should stick with BigWumpus' idea for getting things in and out of the EEPROM, but the editing of the text is going to be a bit harder.

And, like Melanie said in the post that mister_e pointed out. It's going to be easier with 3 buttons.

Sorry, not much help.
<br>

jorge
- 3rd October 2006, 01:20
Thanks a lot for every post !
One more question:
can i increment letters as I do with numbers ( using ASCII & char vars...?)
for example if had to select number i could cycle between then like
if keypress = 1 then
number = number +1 ,
….
but with letters " letter = letter +1 " would it give me "D" char if it was in the "C" before pressing the button ? using the reference ASCII number?
Or is there another and more efficient way ?!?

sayzer
- 3rd October 2006, 03:20
Check Lookup & Lookdown examples.


-------------------

Archangel
- 3rd October 2006, 03:48
hi everybody ,

But now i ve to create a way to the user insert the name of the city/country , record it in the internal PIC eeprom and after display it ...with 2 buttons ( right ,left - change a letter & press both it records it in the EEPROM....
The commands itself - accessing the eeprom, write /reading it is a walk in the park with PBP, reading from buttons also , lcd , ok , …but in a “global view” how to with 2 buttons and LCD can i do such a simple task that is a user to record a Country or city name ( and not from a pre-existent table) and after be able do display it directly from the eeprom in the LCD...


jorge,
<h3>Hi, I'm not an expert of any kind, or a whiz kid.</h3> I too have attemped to use 2 buttons held down for a third effect and concluded it was not something to be done with a PIC, what I did was go back to discrete logic using a BCD decoder, as I remember a 7442 I think. to give 3 outputs with 2 buttons. Yes it requires 3 pic pins this way but still only 2 switches.
Joe

jorge
- 3rd October 2006, 09:46
The button select & save problem is already working ( there ´s a post by Melanie with good info and a single button  …) so with I feel almost “over button” with 2…
Now I am battling with the scrolling routine to select the letters & after recording them is EEPROM using ASCII…lets see what happen.
Thanks for your advice although!

kindred22
- 4th February 2008, 14:55
i cannot read or write on the internal eeprom

is there a need of interrupt disable to access the eeprom?

skimask
- 4th February 2008, 15:05
i cannot read or write on the internal eeprom
is there a need of interrupt disable to access the eeprom?

So, what time of day is it? The internal EEPROM of a PIC only works on NON leap years during a full moon on wednesday nights with 3 pineapples within 200 meters and a fork standing on one tine......................................

If you would like some REAL help, you may want to post some code, maybe a quick description of something like, oh I don't know----which compiler/assembler you are using, etc.etc...

And also, have you read the datasheet concerning the internal eeprom of the PIC you are using? Pretty much every PIC out there has the same types of restrictions when using the internal EEPROM (except for a couple of examples) as far as interrupts go. There is a need to do some disabling...the datasheets will tell you when...

jorge
- 4th February 2008, 20:24
So, what time of day is it? The internal EEPROM of a PIC only works on NON leap years during a full moon on wednesday nights with 3 pineapples within 200 meters and a fork standing on one tine......................................

If you would like some REAL help, you may want to post some code, maybe a quick description of something like, oh I don't know----which compiler/assembler you are using, etc.etc...

And also, have you read the datasheet concerning the internal eeprom of the PIC you are using? Pretty much every PIC out there has the same types of restrictions when using the internal EEPROM (except for a couple of examples) as far as interrupts go. There is a need to do some disabling...the datasheets will tell you when...

well when i begun this thread it was like 3 !!! years ago !!!! even i dont know how i make it work...but the RFM seems to be the best help now ;-) as skimask said ...or at least print an exemple of your code to others chk it out ...