Parallax Servo Controller (#28023) serial communication
Hello! I have a question about your Parallax Servo Controller (#28023). I am very pleased with the product and I'm currently using four of them in a interactive sculpture I'm installing at the Tang Museum in Saratoga Springs, NY. My question is this: Is there a way to send position data to the PSC without using the word variable? For instance, this it the code you provide:
pw = 1250
ch= 0
ra = 4
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
PAUSE 1000
what I'd like to do is something like this:
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", 0, 4, 1200, CR]
PAUSE 1000
Basically bypassing the variables from the command. Replacing the variables for channel (ch) and ramp (ra) worked, but since the position variable is a word, it must be sent in pieces, which makes the above code incorrect (I tried it and, as expected, it trucated the number)I'm trying to save space in the BS2 and do not want to upgrade chips for more memory. Since I make several position calls in my program, removing all the PW calls would save a BUNCH of space. Making it a constant will not work either since there are different position through-out the program.
Any help would be great!
pw = 1250
ch= 0
ra = 4
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
PAUSE 1000
what I'd like to do is something like this:
SEROUT Sdat, Baud+$8000,[noparse][[/noparse]"!SC", 0, 4, 1200, CR]
PAUSE 1000
Basically bypassing the variables from the command. Replacing the variables for channel (ch) and ramp (ra) worked, but since the position variable is a word, it must be sent in pieces, which makes the above code incorrect (I tried it and, as expected, it trucated the number)I'm trying to save space in the BS2 and do not want to upgrade chips for more memory. Since I make several position calls in my program, removing all the PW calls would save a BUNCH of space. Making it a constant will not work either since there are different position through-out the program.
Any help would be great!
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
-Phil
I’m not sure of the way your program is organized but if you need to use SEROUT many times I would recommend putting it into a subroutine an simply passing the parameters to it each time it is called. First I thought you were lacking variable space, but the latter part of your message makes me thing you’re lacking program space and SEROUT commands can use up memory very quickly. By consolidating the command into a subroutine you can save a lot of space. If your positions, channels and ramping are all fixed (the same each time the program is run) then you could just create a DATA table and grab the information from there and send it to the subroutine as needed. We have a lot of examples of doing something like this. I hope this helps. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support