Confused as Usual
Guido
Posts: 195
I am having some real trouble with read and write. I know how to do it with a numberic varable, but have no·idea where to start here. I am trying to save the current time from this statement. I would appreciate a sample program of this, as I do learn from them.
DEBUG DEC2 12-(24-(Hours.HIGHNIB*10+Hours.LOWNIB)//12),":",HEX2 Minutes,":",HEX2 Seconds LOOKUP Hours/$12,[noparse][[/noparse]AM,PM],Idx
Thank You
Guido
·
DEBUG DEC2 12-(24-(Hours.HIGHNIB*10+Hours.LOWNIB)//12),":",HEX2 Minutes,":",HEX2 Seconds LOOKUP Hours/$12,[noparse][[/noparse]AM,PM],Idx
Thank You
Guido
·
Comments
· WRITE Location, hours, minutes, seconds
Later, you can read the values back like this:
· READ Location, hours, minutes, seconds
Location can be a constant or variable -- but needs to be the same for the two lines of code above. And note that you must specify PBASIC 2.5 syntax to WRITE or READ multiple values.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Thank You for your information. Still working on it. I do have one more question for you. I have for the first time downloaded and using ver. 2.5. I can run the program on any other version and work on the debug scree, but when I use 2.5
nothing, like it is not communicating????
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
You are never CONFUSED!!! Just me. I found out the problem....simple after about an hour or so......I changed the Do and loop per new 2.5, but I did not include the exit statement....Even though·it tokenized ok, there was no debug...! see who really is confused.
Getting back to my original question, looks simple but I still don't have success as of yet. I think part of my problem is that the hours,minutes,seconds etc are displayed in hex format, and is a variable byte.·I have tried changing the debug function to dec, but it seems strange numbers...matter of fact I tried everything I could come up with including saving as a hex, but you can not read as a hex. won't take the command.·Any Ideas.....
In the end, though, a number is a number to any microcontroller. If you now that a number is in BCD, you can convert it to decimal like this:
decValue = (hexValue.NIB1 * 10) + hexValue.NIB0
Now, when you want to send information back to an RTC or other device that uses BCD numbers, here's the formula to go back:
hexValue = (decValue / 10 << 4) + (decValue // 10)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
I really do appreciate your help. Dang don't you ever go to sleep? I am going to take a couple of days off playing with this, so my wife won't divorce me. I will be back on it monday and hope I can find some kind of results....
Thank You Again for helping newbee's like me. It shows a lot of class as I want to learn, but hard without examples
Guido
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Between me and you I have downloaded and read more Basic Stamp information then you could imagine! Does it makes sense? some of it. Can you look at this short program and figure out what the heck I am doing wrong....
Thanks Again
Guido
Jon,
Between me and you I have downloaded and read more Basic Stamp information then you could imagine! Does it makes sense? some of it. Can you look at this short program and figure out what the heck I am doing wrong....
Thanks Again
Guido
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office