BS2P-40 program slots
Jon Williams answered the hard question.
The easier question:
> and my data statement would need to be...
>
> 201 DATA 12,14,16,65,"Gutun tag",0
> 202 DATA 12,16,66,"Maintenance",0
> 203 DATA 12,16,66,"Test I/P's?",0
> 204 DATA 12,16,65,"Testing I/P's?",0
>
> The problem is the 201 reports an error 'symbol is already defined'
> WHY?
This is the editor doing a very poor job of telling you that it
doesn't like "201" as a label. "Names must start with a letter, can
contain a mixture of letters, numbers, and underscore (_) characters,
and must not be the same as PBASIC keywords ...".
Auf wiederstampen,
Steve
The easier question:
> and my data statement would need to be...
>
> 201 DATA 12,14,16,65,"Gutun tag",0
> 202 DATA 12,16,66,"Maintenance",0
> 203 DATA 12,16,66,"Test I/P's?",0
> 204 DATA 12,16,65,"Testing I/P's?",0
>
> The problem is the 201 reports an error 'symbol is already defined'
> WHY?
This is the editor doing a very poor job of telling you that it
doesn't like "201" as a label. "Names must start with a letter, can
contain a mixture of letters, numbers, and underscore (_) characters,
and must not be the same as PBASIC keywords ...".
Auf wiederstampen,
Steve
Comments
New programming task for newly designed PLC project. I am using a
serial LCD from Scott Edwards, with some of the messages below.
beginn DATA 12,14,16,69,"Hello",0
maintenance DATA 12,16,66,"Maintenance",0
test DATA 12,16,66,"Test I/P's?",0
testing DATA 12,16,65,"Testing I/P's?",0
languages DATA 12,16,67,"Language",0
startsw DATA 16,85,"START",0
stopsw DATA 16,86,"STOP",0
I then call the messages using the subroutine .....
displayit:
READ addr, char
IF char=0 THEN printitdone
SEROUT 0,N9600,[noparse][[/noparse]char]
addr=addr+1
GOTO displayit
printitdone:
RETURN
By...
addr=beginn
GOSUB displayit
This works fine, BUT, I have 2 problems....
1.
One of the operator options is to change the language, which I
want to be able to do by setting a number (0 for english, 100 for
French, 200 for German etc.) then add this to the addr of the message
required so if the messages are required in german then I would need
the following....
language=200
.
.
.
addr=1+language
GOSUB displayit
and my data statement would need to be...
201 DATA 12,14,16,65,"Gutun tag",0
202 DATA 12,16,66,"Maintenance",0
203 DATA 12,16,66,"Test I/P's?",0
204 DATA 12,16,65,"Testing I/P's?",0
The problem is the 201 reports an error 'symbol is already defined'
WHY? Is there a better way of doing it?
2.
With all these messages in several languages, I am running out of
room in the program slot. Is it possible to use the STORE command
and put my data statements in another slot, and then READ them from
my main program? If so how?
I hope you clever people out there can help this British numb-nut
solve another probably really easy problem!
cheers for now
Jon
On Tue, 17 Jul 2001, Jon wrote:
> Hi everybody,
>
> New programming task for newly designed PLC project. I am using a
> serial LCD from Scott Edwards, with some of the messages below.
>
> beginn DATA 12,14,16,69,"Hello",0
> maintenance DATA 12,16,66,"Maintenance",0
> test DATA 12,16,66,"Test I/P's?",0
> testing DATA 12,16,65,"Testing I/P's?",0
> languages DATA 12,16,67,"Language",0
> startsw DATA 16,85,"START",0
> stopsw DATA 16,86,"STOP",0
>
> ...snip...
>
> 2.
>
> With all these messages in several languages, I am running out of
> room in the program slot. Is it possible to use the STORE command
> and put my data statements in another slot, and then READ them from
> my main program? If so how?
I have used a serial EEPROM (using I2C) and stored all of my text
messages in it. Each text message is trerminated with a NULL (00 hex).
When I wish to send a message to the serial LCD I address where the
message starts in the EEPROM, pull it out one byte at a time, test for
NULL (to detect when the message is finished), then send it out to the
serial LCD.
You can get ALOT of canned messages into an inexpensive 8k serial
EEPROM. But it can be a bit slow when sending long messages to the LCD
and this delay is visible to the eye. But it's a great way to save
program space and still have very verbose messages and menus displayed
onto the LCD :-)
--- Jay
+
+
| Jay Nugent jjn@n... (734)971-1076 (734)971-4529/Fax |
| Nugent Telecommunications [noparse][[/noparse]www.nuge.com] (734)649-0850/Cell |
| Internet Consulting/Linux SysAdmin/Engineering & Design/ISP Reseller |
| ISP Monitoring [noparse][[/noparse]www.ispmonitor.net] ISP & Modem Performance Monitoring |
| Web-Pegasus [noparse][[/noparse]www.webpegasus.com] Web Hosting/DNS Hosting/Shell Accts|
| LinuxNIC, Inc. [noparse][[/noparse]www.linuxnic.net] Registrar of the .linux TLD |
+
+
6:00am up 11 days, 5 min, 5 users, load average: 0.08, 0.06, 0.01
A very simple strategy -- using STORE -- would be to put each set of language
strings in a separate program slot. Your code becomes easy. Just before you
start accessing strings, you use STORE to point to the slot that contains
your language.
Perhaps like this:
English CON 1
French CON 2
German CON 3
Lang CON English
' othe program stuff
Display_Msg:
STORE Lang ' point to language EE
Get_Char:
READ addr,aChar
IF (aChar = 0) THEN Print_Done
SEROUT pin,baud,[noparse][[/noparse]aChar]
addr = addr + 1
GOTO Get_Char
Print_Done
STORE 0 ' return READ/WRITE to main slot
RETURN
When using this technique I'd recommend that you define some maximum length
for each string so that you can lay them into memory at specific locations
making your addressing very easy. Then you can define a table that is a
message pointer table. This would abstract your addresses, so your code
would look something like this:
msg = MStop
GOSUB Display_It
MStop would have been previously defined as a CONstant with address value of
your stop message -- for any language.
You can place data at specific addresses with the @.
MsgLen CON 16
Msg0 DATA @(0*MsgLen),"Stop!",0
Msg1 DATA @(1*MsgLen),"Go",0
Msg2 DATA @(2*MsgLen),"Testing",0
In the DATA strings above, the first number in the parenthesis is the actual
message number. The constant, MsgLen, defines how much space to set aside
for each string. This isn't the most efficient use of memory for strings
(possible wasted space between strings), but it GREATLY simplifies your
overall program development. What you need to do is find your longest
string, add one (for the terminating zero) then assign this value to MsgLen.
In my experience, German has the longest strings.
I hope this helps. When the BS2p first came out and the STORE command was
functional, I felt like multi-lingual apps would be possible using the
techniques I've described here. Good luck with your project.
-- Jon Williams
-- Applications Engineer, Parallax
In a message dated 7/17/01 5:17:06 AM Central Daylight Time, jonm@p...
writes:
> New programming task for newly designed PLC project. I am using a
> serial LCD from Scott Edwards, with some of the messages below.
>
> beginn DATA 12,14,16,69,"Hello",0
> maintenance DATA 12,16,66,"Maintenance",0
> test DATA 12,16,66,"Test I/P's?",0
> testing DATA 12,16,65,"Testing I/P's?",0
> languages DATA 12,16,67,"Language",0
> startsw DATA 16,85,"START",0
> stopsw DATA 16,86,"STOP",0
>
> I then call the messages using the subroutine .....
>
> displayit:
> READ addr, char
> IF char=0 THEN printitdone
> SEROUT 0,N9600,[noparse][[/noparse]char]
> addr=addr+1
> GOTO displayit
> printitdone:
> RETURN
>
> By...
>
> addr=beginn
> GOSUB displayit
>
> This works fine, BUT, I have 2 problems....
>
> 1.
>
> One of the operator options is to change the language, which I
> want to be able to do by setting a number (0 for english, 100 for
> French, 200 for German etc.) then add this to the addr of the message
> required so if the messages are required in german then I would need
> the following....
>
> language=200
> .
> .
> .
> addr=1+language
> GOSUB displayit
>
> and my data statement would need to be...
>
> 201 DATA 12,14,16,65,"Gutun tag",0
> 202 DATA 12,16,66,"Maintenance",0
> 203 DATA 12,16,66,"Test I/P's?",0
> 204 DATA 12,16,65,"Testing I/P's?",0
>
> The problem is the 201 reports an error 'symbol is already defined'
> WHY? Is there a better way of doing it?
>
>
> 2.
>
> With all these messages in several languages, I am running out of
> room in the program slot. Is it possible to use the STORE command
> and put my data statements in another slot, and then READ them from
> my main program? If so how?
>
> I hope you clever people out there can help this British numb-nut
>
[noparse][[/noparse]Non-text portions of this message have been removed]
My setup is as follows in program slot 1....
lang=2 ' this is first available program slot
.
.
.
addr=maintenance ' message address
GOSUB displayit
.
.
.
displayit:
MAINIO
STORE lang
read_msg:
READ addr,char
IF char=0 THEN printitdone
SEROUT 0,N9600,[noparse][[/noparse]char]
addr=addr+1
GOTO read_msg
printitdone:
STORE 0
RETURN
In program slot two I have my data messages
maintenance DATA 12,16,64,"Service Menu",0
The problem is that when I check syntax I get error 'Undefined symbol'
PLEASE PLEASE PLEASE help again, thanks in advance
Jon
--- In basicstamps@y..., jonwms@a... wrote:
> Since you're using the BS2p, you're in luck, mate.
>
> A very simple strategy -- using STORE -- would be to put each set
of language
> strings in a separate program slot. Your code becomes easy. Just
before you
> start accessing strings, you use STORE to point to the slot that
contains
> your language.
>
> Perhaps like this:
>
> English CON 1
> French CON 2
> German CON 3
>
> Lang CON English
>
> ' othe program stuff
>
> Display_Msg:
> STORE Lang ' point to language EE
> Get_Char:
> READ addr,aChar
> IF (aChar = 0) THEN Print_Done
> SEROUT pin,baud,[noparse][[/noparse]aChar]
> addr = addr + 1
> GOTO Get_Char
> Print_Done
> STORE 0 ' return READ/WRITE to
main slot
> RETURN
>
>
> When using this technique I'd recommend that you define some
maximum length
> for each string so that you can lay them into memory at specific
locations
> making your addressing very easy. Then you can define a table that
is a
> message pointer table. This would abstract your addresses, so your
code
> would look something like this:
>
> msg = MStop
> GOSUB Display_It
>
> MStop would have been previously defined as a CONstant with address
value of
> your stop message -- for any language.
>
> You can place data at specific addresses with the @.
>
> MsgLen CON 16
>
> Msg0 DATA @(0*MsgLen),"Stop!",0
> Msg1 DATA @(1*MsgLen),"Go",0
> Msg2 DATA @(2*MsgLen),"Testing",0
>
> In the DATA strings above, the first number in the parenthesis is
the actual
> message number. The constant, MsgLen, defines how much space to
set aside
> for each string. This isn't the most efficient use of memory for
strings
> (possible wasted space between strings), but it GREATLY simplifies
your
> overall program development. What you need to do is find your
longest
> string, add one (for the terminating zero) then assign this value
to MsgLen.
> In my experience, German has the longest strings.
>
> I hope this helps. When the BS2p first came out and the STORE
command was
> functional, I felt like multi-lingual apps would be possible using
the
> techniques I've described here. Good luck with your project.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
One approach would use the LOOKUP command. Number the messages from
0 to 6, and the languages from 0 to whatever, and then address them
by index:
' this program for bank 1, to be RUN from some other bank
' crossbank call mechanism must be in place
' enter with language (0-2) and message (0-6)
language var nib ' global (crossbank) variable
message var nib ' ditto
addr var word ' local variable
beginn DATA .... etc etc
lookup
7*language+message,[noparse][[/noparse]beginn,...,stopsw,frenchbeginn,...,frenchstopsw,ge
rmanbeginn,...,germanstopsw],addr
gosub displayit
read stack,sxgo ' using simple stack mechanism
run sxgo ' return to calling bank
This approach requires that both the data and the display routine be
in the same bank (here bank 1), so the compiler can determine where
the strings are located in eeprom. (The compiler does not keep track
of data assignments and addresses across project banks). The calling
program sets the language and the index for the appropriate string.
The good alternative that Jon Williams suggested requires that you
allocate a fixed address for the corresponding language strings in
the different banks. Or else you have to declare the data addresses
(in one bank) as constants in the bank where the display routine is
located.
-- best regards
Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...
To access that in another program slot
At 9:33 AM +0000 7/17/01, Jon wrote:
>Hi everybody,
>
>New programming task for newly designed PLC project. I am using a
>serial LCD from Scott Edwards, with some of the messages below.
>
> beginn DATA 12,14,16,69,"Hello",0
> maintenance DATA 12,16,66,"Maintenance",0
> test DATA 12,16,66,"Test I/P's?",0
> testing DATA 12,16,65,"Testing I/P's?",0
> languages DATA 12,16,67,"Language",0
> startsw DATA 16,85,"START",0
> stopsw DATA 16,86,"STOP",0
>
>I then call the messages using the subroutine .....
>
> displayit:
> READ addr, char
> IF char=0 THEN printitdone
> SEROUT 0,N9600,[noparse][[/noparse]char]
> addr=addr+1
> GOTO displayit
> printitdone:
> RETURN
>
>By...
>
> addr=beginn
> GOSUB displayit
>
>This works fine, BUT, I have 2 problems....
>
>1.
>
>One of the operator options is to change the language, which I
>want to be able to do by setting a number (0 for english, 100 for
>French, 200 for German etc.) then add this to the addr of the message
>required so if the messages are required in german then I would need
>the following....
>
> language=200
> .
> .
> .
> addr=1+language
> GOSUB displayit
>
>and my data statement would need to be...
>
> 201 DATA 12,14,16,65,"Gutun tag",0
> 202 DATA 12,16,66,"Maintenance",0
> 203 DATA 12,16,66,"Test I/P's?",0
> 204 DATA 12,16,65,"Testing I/P's?",0
>
>The problem is the 201 reports an error 'symbol is already defined'
>WHY? Is there a better way of doing it?
>
>
>2.
>
>With all these messages in several languages, I am running out of
>room in the program slot. Is it possible to use the STORE command
>and put my data statements in another slot, and then READ them from
>my main program? If so how?
>
>I hope you clever people out there can help this British numb-nut
>solve another probably really easy problem!
>
>cheers for now
>
>Jon
>
>
>
>
>
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the
>Subject and Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/