PDA

View Full Version : alphanumeric string question



guydb
06-17-2005, 02:05 AM
here's my problem:

I am using a stamp (sx) to control professional pioneer dvd players and this works perfectly, but now, instead of lugging my computer over to the controller each time, I would like a small interface with numeric keypad and lcd display. the keypad and display are working perfectly as well and there would be no problem if I would only need to upload numbers to the dvd players, but the required code looks as follows:

SEROUT tx6,16624,1,["FR27657PL",CR] (indicating "play up to frame 27657")

What I want to do is implement (in the case of the example) 27657 with the keypad using 'write' to store it in the eeprom from where the stamp can read it at start up and send it to the dvd player. But how do I make 'FR27657PL" from 27657???

I guess either it cannot be done or it is very easy and I don't see it.

any help would be most welcome.

thanks

Guy

Chris Savage
06-17-2005, 04:59 AM
Hello,
·· Have you tried:


Codes DATA "FR27657PL", 13, 0

You could store strings in DATA statements, then send them out via SEROUT, one character at a time.· The 0 ends a particular string.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

allanlane5
06-17-2005, 05:05 AM
Couldn't he send the whole thing with:

SEROUT SerPin, SerBaud, STR Codes

If he put it in a DATA statement that way?

allanlane5
06-17-2005, 05:07 AM
And, you can also do:

FrameVal VAR WORD

FrameVal = 27657

SEROUT tx6,16624,1,["FR", DEC FrameVal, "PL",CR] (indicating "play up to frame 27657")

Chris Savage
06-17-2005, 06:26 AM
allanlane5 said...
Couldn't he send the whole thing with:
SEROUT SerPin, SerBaud, STR Codes
If he put it in a DATA statement that way?
Allan,

·· This won't work for two reasons...One, the data in a SEROUT statement needs to be inside [].· Second, the STR doesn't work on a DATA statement.· Only an array.· Anyway, after re-reading the original message, I see he wants to be able to input data in real-time...I thought he wanted presets originally, and thus the DATA statements.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Jon Williams
06-17-2005, 07:11 AM
If your player will tolerate leading zeros, you could modify the data statement with a numeric value should you need it.· Like this:

Msg··· DATA··· "FR00000PL", CR, 0

Here's a subroutine that updates the frame string with a number stored in "theFrame":

Update_Cmd:
· FOR idx = 0 TO 4
··· temp = theFrame DIG (4 - idx) + "0"·· ' extract digit, convert to ASCII
····WRITE (Msg + 2 + idx), temp·········· ' write to embedded command string
· NEXT
· RETURN

And, finally, to send the message:

Send_Cmd:
· FOR idx = 0 TO 15
··· READ (Msg + idx), temp
··· IF (temp = 0) THEN EXIT
··· SEROUT Tx, Baud, [temp]
· NEXT
· RETURN

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

guydb
06-17-2005, 03:54 PM
allanlane5 said...
And, you can also do:

FrameVal VAR WORD

FrameVal = 27657

SEROUT tx6,16624,1,["FR", DEC FrameVal, "PL",CR] (indicating "play up to frame 27657")


this would be perfect if it works, I have no idea how the players will like the original string ("FRxxxxPL") spelled as "FR",xxxx,"PL". Otherwise Jon's solution seems very elegant. As soon as I get back to the machines I will try it.
The general idea is:
I turn on the stamp, I get a little message on the display asking me whether I want to implement a new figure or just go ahead. If I choose to implement a new figure it write the new figure in the eeprom and will use it each time the stamp is started up and the user chooses to go on instead of implementing a new figure. and the real life situation is as follows: I put together the stamp for friends who show art videos on a continuous schedule, often on two players that have to be synched (hence the need for a controller instead of somebody that has to be around every 30 minutes). Every two or three months they change their program and I have to go up there with my computer to reprogram the stamp with the new figures and I figured it would be much easier if they could do it themselves with a little interface (they are computer illiterates).

Jon Williams
06-17-2005, 10:59 PM
If my version works, then Allan's should -- I would simply update it like this:

SEROUT Tx, Baud, 1, ["FR", DEC5 frameVal, "PL", CR]

This will give the same output as my verbose version, but with far less code.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

allanlane5
06-18-2005, 02:09 AM
If frameVal was 28999 THEN

what "SEROUT Tx, Baud, 1, ["FR", DEC5 frameVal, "PL", CR]" actuall puts on the serial line is:

FR28999PL<CR> -- Where <CR> is replaced by the character value ascii 13

The "FR"... etc are formatting indicators to the SEROUT command, the quotes are not actually sent.