help with PSC interface
I would like to know what exactly the PSCI.exe servo control program is doing, I have gotten it to work correctly. I bought the USB version of the servo controller. I assume the interface is the same as ther serial servo controller but it doesn't actually say that anywhere in the documentation. I have also tried to connect to the servo controller via Hyperterminal and send it commands to move the servos but have not been successful. I am trying to build a web interface to control the servos.
any suggestions?
Thanks,
Nick
any suggestions?
Thanks,
Nick
Comments
·· The USB version functions just as the standard serial version does...Yous end the same commands as you would from a BASIC Stamp.· Have you checked your baud rate settings?· As for controlling from Hyper Terminal, my concern there is you won't be able to send a valid position value.· The same could be said for some of the other values that are sent.· You may need to write a VB application or similar.· Perhaps someone on here has already done this and can share their experience.· I know I have seen previous messages about it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I'm trying to control it in much the same way as this
http://www.geocities.com/zoomkat/byte.htm
all the solutions I have seen so far on the forum use a basic stamp.
Thanks,
Nick Sturm
·· That's kind of an interesting, if not round-about way to do something like this.· Most people have a language in mind, such as C++ or VB for doing this.· On the other have, you could just use the PSCI software and store your sequences for later playback.· What exactly are you trying to be able to do?· There might be a more elegant way to accomplish it than through re-directed DOS ECHO calls...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I think if I can get this figured out the only thing left is getting the laptop to run the web server, actually serve the web cam at a good resolution with as little lag as possible. I have pretty much used up my budget for hardware so I don't want to get into any more complicated hardware solutions since I have a laptp sitting here just collecting dust.
cmdstr = cmd + Chr(port).ToString + Chr(speed).ToString + _
Chr(pos Mod 256).ToString + Chr(pos \ 256).ToString _
+ vbCrLf
gMSComm.Output = cmdstr
You can figure that port, speed and pos are parms, and that gMSComm has been set up by the driver class, but this will format the command to be sent.
Let me know if this approach is of interest to you.
like I said, I have very little programming experience (some Basic and FORTRAN)...
So Rick, is this really what you use to output data directly to the servo controller? I expected to see the !SC preamble like it says in the instructions. unless cmd is set to "!SC", then I understand. also, I guess Chr turns a decimal number into hex? .ToString adds it to the end of cmdstr? vbCrLf is a variable set to $0D?
I am having trouble figuring out what lowbyte and highbyte are.
thanks,
-n
The Chr function converts an ascii code into a character.
ToString is vb.net's way of turning the resultant character into a string object on which the concatenation operator "+" will work. All of this is pretty basic VB - you might want to get yourself a vb6 or vb.net primer to guide you.
Oh, and vbCrLf is a constant in VB which gets converted to ascii 10 and ascii 13 (carriage return and line feed) - I just found this to work, honestly, as it's a common way to terminate a string·and don't remember if I tried the ascii or hex equivalent of "$0D". I did this several months ago.
If you really want to do without, though, here is a snippet from an early test program I wrote that shows what comes before the lines I gave you earlier:
NOTE: also note that this is for vb.net, not vb6. They're a little bit different, but the idea is the same. I didn't go much further than this with with the PSC, as I found a controller which better suited my needs. I can give you the actual class file for my PSC driver class, but that uses some conversions to go from degrees to PWM values, so I didn't want to confuse you.
This program takes the minimalist approach, which I've always found helpful.
'********************************************************************
'you can see that this is taking what's typed into two text boxes and using one for
'the port num and one for the position
'I created vars for the other parms like cmd and speed so I could easily change them
'as I was experimenting.
'********************************************************************
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim cmd
Dim port
Dim pos
Dim speed
Dim cmdstr
'initialize in case nothing in text boxes
cmd = "!SC"
port = 0
pos = 750
speed = 7
MSComm1.DTREnable = True
MSComm1.PortOpen = True
pos = CInt(TextBox1.Text)
port = CInt(TextBox2.Text)
cmdstr = cmd + Chr(port).ToString + Chr(speed).ToString + _
Chr(pos Mod 256).ToString + Chr(pos \ 256).ToString _
+ vbCrLf
MSComm1.Output = cmdstr
MSComm1.PortOpen = False
End Sub
Post Edited (Rick K) : 8/11/2005 1:41:37 AM GMT
I have the same problem. I would like to use C under Linux to do the communication with the serial controller. Somehow I can not figure out to generate the correct sequence in order to make any servo move. I attach a snipplet of the program with the hoe that someone could help me.
Cheers,
Gerhard
.
.
.
unsigned char getLowByte (unsigned int value);
unsigned char getHighByte (unsigned int value);
unsigned char getLowByte (unsigned int value)
{
unsigned char result = (unsigned char) value & 0xFF;
return result;
}
unsigned char getHighByte (unsigned int value)
{
unsigned int tmp = value;
unsigned char result;
tmp = tmp & 0xFF00;
tmp = tmp >> 8;
result = (unsigned char) tmp;
return result;
}
// this is the mainline thingee
int main(int argc, char *argv[noparse]/noparse)
{
if (OpenAdrPort("1") < 0)
{
printf ("konnte Port nicht oeffnen\n");
return 1;
}
int i;
int j;
unsigned int pw;
unsigned char ra ;
unsigned char ch ;
unsigned char cr ;
unsigned char cposh;
unsigned char cposl;
char preamble = "!SC";
pw = 300;
ra = 0;
ch = 1;
cr = 0x0D;
for (j = 0; j < 10; j++)
{
pw+=10;
cposh = getHighByte (pw);
cposl = getLowByte (pw);
for (i = 0; i < strlen (preamble); i++)
{
printf("%c", preamble);
WriteBinAdrPort(preamble);
}
printf("%c", ch);
WriteBinAdrPort(ch);
printf("%c", ra);
WriteBinAdrPort(ra);
printf("%c", cposl);
WriteBinAdrPort(cposl);
printf("%c", cposh);
WriteBinAdrPort(cposh);
printf("%c", cr);
WriteBinAdrPort(cr);
sleep (1);
}
CloseAdrPort();
return 0;
} // end main
it is my understanding that this is how it works
for
2000
the binary = 11111010000
0000011111010000
00000111 | 11010000
high byte | low byte
$07 $d0
is this wrong?
ok secondly in my ignorant wanderings I have downloaded a usb port sniffer to figure out how exactly "!SC" is turned into hex since echoo doesn't seem to be able to handle anything but hex numbers:
it appears that the preamble is translated into $f1, but I am not tottally sure about this. There is a bunch of other stuff going on that I have to sort through
I have gotten the servo to respond, a couple of times, but usually it just rotates to the stops and I have to shut it off and reset it using the parallax supplied software, here is what I have so far:
test.bat
@echo off
mode com3:2400,N,8,1 >nul
echoo $f1$01$00$5c$01$0d> com3
pause
echoo $f1$01$00$d0$07$0d> com3
pause
this attempt is to take servo 1 from 500 to 2000, and it doesn't work. I can see the green light flash and the past successes seem to indicate I'm doing everthing but the high byte and low byte right.
thanks in advance
-n
I honestly don't understand what ECHOO is supposed to do, but regardless of what it·is expected to do, a positioning command to the Parallax SSC looks basically like this:
···················· Preamble········· C············· P··········· R······· Terminator
Typical············· !SC···············1··········· 128·········· 7············ $0D
Type·············· ASCII·········· binary······ binary····binary······ binary
Size in bytes······ 3················· 1············· 1·········· 1·············· 1
Range·············· n/a············· 0-31······ 0-255····· 0-15·········· n/a
Where:············C = servo number, P = position, R = ramping
Thus, an SSC positioning command is a total of 3 + 1 + 1 + 1 + 1 = 7 bytes long. All of the commands you have shown above are 6 bytes long. Right there, I'd say there's a problem, if I understand the SSC syntax for a positioning command correctly, regardless of what the contents of those bytes turns out to be, after processing by the ECHOO program.
Regards,
Bruce Bates
thanks a lot! I thought !SC would be three bits but the usb sniffer said otherwise, but it was also giving me all kinds of wierd information.
I thought (and the documentation seems to support) that Position was a 2 byte word that was then split up into high byte and lowbyte
echoo is a program I got off of the zoomkat page
http://www.geocities.com/zoomkat/byte.htm
that explains, in a cookbook method, how to make a pan/tiltable web cam using redirected echo commands. The difference is he is using a mini-SCC which I guess, has a 3 byte format.
but like I said, it only handles hex information (or at least that is my understanding
http://www.lookuptables.com/
is where I got the info for turning !SC into hex
test5.bat:
@echo off
mode com3:2400,N,8,1 >nul
rem this is for position 700
echoo $21$53$43$01$00$5c$01$0d> com3
pause
rem this is for position 2000
echoo $21$53$43$01$00$d0$07$0d> com3
pause
note: position 2000 still seems to be high as it is still straining
but this makes servo 1 turn one way, then the other, whether or not it is actually position 700 and 2000 I don't know yet.
Woops:
Reading the servo controller instructions again, it appears that 1250 is the highest I can go. Since each step is 2 microsecs
Post Edited (grindel) : 8/21/2005 3:57:51 PM GMT