Saving variable space while using the Pocket Watch B
Hi,
I've spent about a year on a tide prediction program using the Pocket Watch B. It wants a byte for mm/dd/yr and hr[noparse]:mn:[/noparse]ss for a total of 6 bytes! I was looking for a way around this using scratchpad ram but realized that as you pass or read a date to the pocket watch, it expects 6 variables so you can't store and retrieve it from ram as it expects separate variables to exist.
I will be shocked if anyone figures out how to save variable space using the pocket watch but if you can point me in the right direction, I'd really appreciate it.
Thanks in advance,
Engin
I've spent about a year on a tide prediction program using the Pocket Watch B. It wants a byte for mm/dd/yr and hr[noparse]:mn:[/noparse]ss for a total of 6 bytes! I was looking for a way around this using scratchpad ram but realized that as you pass or read a date to the pocket watch, it expects 6 variables so you can't store and retrieve it from ram as it expects separate variables to exist.
I will be shocked if anyone figures out how to save variable space using the pocket watch but if you can point me in the right direction, I'd really appreciate it.
Thanks in advance,
Engin
Comments
I read the datasheet on the pocket watch B. It uses 7 bytes as the year is high and low bytes
How much space do you have and how much space do you need to save?
The scratchpad ram, is that in the stamp of the device, I don't see any reference to ram or memory in the datasheet on the device.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
Thanks for the reply. I need to save about 4 bytes or 2 words so I was looking for a trick to interfacing with the pocket watch. The scratchpad ram is in the basic stamp SX itself. I've used that in order to save on variable space on other projects but it does no good here since the pocket watch is waiting for 6 seperate variables for reading and storing time. I'm hoping that someone can prove me wrong.
Engin
You mean you want to read 6 bytes from the device store it in 4 bytes in basic stamp II ram and convert it on the fly for ss[noparse]:mm:[/noparse]hh DD:MM:YYY format?
or you want to just be able to send and receive 4 bytes to the device because you don't have 6 bytes of free variable space to work with?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
I don't blame you for being perplexed.
This is the way I receive (and send) time info to and from the pwb.
SERIN 9,1021,[noparse][[/noparse]ss,mm,hh,dd,mo,yl,yh] 'READ time from pwb
Notice that there are 6 variables. I'm just complaining that my program has to have a whopping 6 variables
ss VAR Byte
mm VAR Byte
hh VAR Byte
dd VAR Byte
mo VAR byte
yl VAR Byte
yh VAR Byte
in order to read and write to the pocket watch. I was wondering if I could use scratchpad ram to my advantage and only have one variable within the running program so I could save on variable space.
Engin
There is nothing stopping you from using the same varable in another section of program for something different
So once the user keys in the time, the program loops through like this:
1) read time from pocket watch
2) calculate number of hours since January of the year. This is floating point and I'm using the um-fpu coproccesor to handle a number like 8543.2354.
3) based on the time, calculate height using a sine wave formula.
4) show height and time on lcd
5) loop back to 1
So each time I read from the pocket watch, I have to ask for all 6 variables from the pocket watch (I think). This is my question, how can I get around that without using up 6 variables? It seems to me that it wants to read all 6 values at once. Therein lies my problema.
Thanks,
Engin
If you're hurting for Variable space, you might want to reduce some of the byte variables to nibbles, i.e.
this saves 1 byte of space...? Of course, with the yl value maxing out at 15, you would have to update the firmware for all your customers by 2015.. of course, by then you would have the entire project ported to Spin, right?
Vern
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ok, based on this description, it appears you are not using the year in your calculations, or the year is assumed to be the year in which the person is entering data? If this is the case, you could use a "disposable" variable to "catch" the data you dont need. i.e. :
So this saves what 2.5 bytes or so? If you can make assumptions about other unneeded data, for example, the # of seconds you can save a bit more like this :
So now we've saved 3.5 bytes?
Vern
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Vern) : 10/15/2006 5:13:48 PM GMT