SEROUT to send strings, rather than bytes, from EEPROM DATA
xanatos
Posts: 1,120
Hi there,
I'd like to be able to send a string to a device using the SEROUT command. I've been doing so quite successfully using
SEROUT pin, baud [CR, "some string stuffed in here", CR]
But I'm wanting to store larger strings in EEPROM. Problem is that those strings read back byte by byte, and so rather than the string I want flowing smoothly, it comes out a character at a time.
I know I can use an array with the STR command ( STR myArray\10 for example), but the array would need to be partitioned to 60 bytes, which of course is far too huge for the EEPROM, and intuitively, it just feels wrong... :-)
So - the question is, is there a way to output a DATA string read in from EEPROM, using the SEROUT command, where the strings can be as long as 60 characters?
Ultimately I will want to do this with an external EEPROM such as the 24LC32A. I am using the BS2SX, but can also use the BS2P40.
Ideas?
Thanks,
Dave
I'd like to be able to send a string to a device using the SEROUT command. I've been doing so quite successfully using
SEROUT pin, baud [CR, "some string stuffed in here", CR]
But I'm wanting to store larger strings in EEPROM. Problem is that those strings read back byte by byte, and so rather than the string I want flowing smoothly, it comes out a character at a time.
I know I can use an array with the STR command ( STR myArray\10 for example), but the array would need to be partitioned to 60 bytes, which of course is far too huge for the EEPROM, and intuitively, it just feels wrong... :-)
So - the question is, is there a way to output a DATA string read in from EEPROM, using the SEROUT command, where the strings can be as long as 60 characters?
Ultimately I will want to do this with an external EEPROM such as the 24LC32A. I am using the BS2SX, but can also use the BS2P40.
Ideas?
Thanks,
Dave
Comments
Here's a snippet of the code I'm using now:
IF CTS = 0 THEN
SELECT cmd
CASE 0
SEROUT VTX, Baud, [CR, "System initialized and online.", CR]
CASE 1
SEROUT VTX, Baud, [CR, "Guydance systems initializing.", CR]
CASE 2
SEROUT VTX, Baud, [CR, "Guydance systems online.", CR]
CASE 3
.........
Gotta love the creative spelling required! :-)
The problem is that as the message count increases, the space available for the program decreases.
I'm thinking that this project may require a dedicated stamp for just the messaging system, with another stamp or propeller actually running the show. Unless you have a brainstorm... :-)
Thanks for your input,
Dave
THANKS MIKE! You got me thinking! :-)
Now I can store wads of strings off-chip on an external EEPROM like I was originally wanting, and save the BS2's EEPROM for program code!
'
[ Previous thinking that led to my enlightenment ]
That's a cool function and since I have a few BS2P40s sitting around looking for work, I will play with that - but the issue of the characters being delivered as bytes vs. strings still exists with this method, am I correct in that?
Basically, looping through EEPROM DATA with a string stored as "Testing", for example, yields, on SEROUT to the V-Stamp, the speech "t, e, s, t, i, n, g", whereas the same string delivered directly within the SEROUT line yields the speech "testing".
What I can't figure is why I was able to store speech phrases in EEPROM with the old EMIC module, and loop through them and have it actually speak the phrase, identically to the speech generated if the same phrase was included directly within the SEROUT command to the EMIC.
Unless there's some oddity about how I am storing the phrases in EEPROM... The Emic had everything stored prefixed with the constant "say", which was $00, and suffixed with EOM ($AA):
Phrase0 DATA Say, "System ready. ", EOM
In the case of the EEPROM data for the V-Stamp, I was using just the phrase itself in the EEPROM:
Phrase0 DATA "System initialized and online"
And in the looping structure, the SEROUT command was structured to contain the requisite functionalities:
SEROUT VTX, Baud, [CR, char, CR]
Where char is the character indexed by eePntr...
I'll be playing with all this later this evening, hopefully I can get it figured out soon, but I can survive if I need to dedicate a stamp for speech operations...
Thanks again,
Dave
Phrase0 DATA 00, "System initialized and online.", CR
Here's the SEROUT generation:
DO
READ eePntr, char
PAUSE 10
SEROUT VTX, Baud, [char]
eePntr = eePntr + 1
LOOP UNTIL (char = CR)
PAUSE 50
I currently have 30 (relatively long) phrases in EEPROM and that occupies a little under 40% of EEPROM, with program code being about 10% of that. These being just demo phrases for development, the actual phrases will likely be shorter, and I really don't need much more than 50 or 60 phrases max. This is working quite well now, thanks everyone for your input and willingness to look at my questions and contribute your ideas.
Dave
Dave,
Did you ever code this to use the external EEPROM? I looked over the most recent 3-Slot code for your Home Automation System but didn't any reference to an external EEPROM.
I have a number of SEROUT text string phrases I would like to save to a 24LC16B but am not sure about how to get them to it without taking up a lot of BS2 EEPROM space in the process. Won't the I2COUT code with the various phrases use up a lot of memory in the process of being sent to the EEPROM?
As far as the external EEPROM address for each phrase, would I just find the longest phrase and increment the address variable that number of bytes each time to keep it simple?
falcon
I tend to "cycle" on these projects, and what I have up here historically so far is version 1.0. Version 2.0 will blow 1.0 away. Leveraging the power of the BS2px and the Spinnerett web server will be a quantum leap over v 1.0. I can only imagine what the Propeller versions will be like! :-)
Best,
Dave