Help! Using Servo controller with a PC
DumB
Posts: 8
Hi
Can you guys offer some help on sending commands to the 'Parallax USB Servo Controller' from a PC, without using the PSCI Application?
I'm Using C#.Net for developing the custom application for PC.
Thanks in Advance
Binesh
Can you guys offer some help on sending commands to the 'Parallax USB Servo Controller' from a PC, without using the PSCI Application?
I'm Using C#.Net for developing the custom application for PC.
Thanks in Advance
Binesh
Comments
send commands to the USB version of the PSC.· Here is a link for the serial documentation:· http://www.parallax.com/detail.asp?product_id=28023·.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
Http://www.parallax.com
·
Thanks for the link.
Now, I'm able to get the PSC Version and the Servo Position thru Hyper Terminal. But unable to set the position.
Still i need help on the syntax to use the following at hyper terminal:
!SC C R pw.LOWBYTE, pw.HIGHBYTE, $0D
Kindly suggest a example for the above command. Do i need to send as HEX / DEC ? Is the Comma (,) separater required?
Thanks,
Binesh
I'm using HyperTerminal and the following two commands gives me response.
!SCVER?
1.4
!SCRSP0
0
the hex values you are using look good for the position and byte order, but they have to be single bytes, to get hyperterminal to work, you would have to figure out a way to enter characters with the proper ascii(byte) values
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
Post Edited (CJ) : 7/26/2006 11:12:57 AM GMT
All are small files, and if there's any interest in this I may look into creating an executable file that will just take in a file that pushes out the commands. This python program is still in development, and will be improved upon(there's not a whole lot of error catching).
So if you're familiar with C# you shouldn't have much of a problem with this. So here's my attempt at explaining how all of this works:
The psc.py file has a class called Psc. Psc has 3 methods and a constructor. 1 method gets the version from the psc 'getVer()', 1 method will send commands to the psc 'moveServo()', and 1 closes the connection 'cleanup()'(just started learning python, so I haven't looked into a destructor yet). When you create an instance of the psc class you supply the com number only. Make sure that before your program exits it calls cleanup() to close the com port(though I haven't seen any il-effects of not doing so). When calling moveServo() you supply in this order: the channel, the ramp rate, and the desired position. You will cause an error if you pass in values that are out of spec(too high, or too low) according to the psc(serial) documentation on parallax's site. If you pass in erroneous values the program will not send the data, only cause the error. If you read through the method you'll find what the values are if you don't feel like reading through the psc(serial version) manual.
So without further delay here is a quick example!
#################
#file name is test.py ||| must be in same directory as the psc.py file
import psc
import time #used for pausing between sending commands
myPsc = psc.Psc(3) #creates a new instance of the Psc class on com 3
print myPsc.getVer() #prints out the version of the psc
myPsc.moveServo(3, 10, 1325) #moves the servo on channel 3 with a ramp rate of 10 to position 1325
time.sleep(1) #pause execution for 1 second allowing servo to move to desired position before sending it another command
myPsc.moveServo(3, 0, 750) #moves the servo on channel with with no ramp rate to position 750 (center)
myPsc.cleanup()
###################
Note: no hex needed!
So there's a very basic example. I've also attached the project I've been working on. The leg.py file contains a class that represents a leg of my robot, and the movement.py creates 4 legs and issues commands to make it walk.
The other option instead of creating a sperate file, you can just edit everything under the "if __name__"... statement, and run the actual psc.py file. Follow the example included under that statement as it is a working example if you run the file by itself.
I hope I haven't just confused you, and I hope that you will find this useful(and maybe some other members here). Let me know what you think.
Will