parallax servo controller USB(28830)
Gautam
Posts: 5
I have recently got this 32 servo controller USB of Parallax. When I tried to test it, it replied its version correctly but after that none of the commands (for reading servo positions, for setting servo position, etc) worked. I have a stingray also with which I want to control the servos by sending commands to the servo controller also. Neither I got any document on what commands to send nor I got any example program which interacts the servo controller with the propeller microcontroller I am trying to get it working from last few days but getting nothing.
I am loosing interest in propeller. Please help me in working out this problem.
I am loosing interest in propeller. Please help me in working out this problem.
Comments
if you have a separate USB to serial convert or an old PC with a serial port you can use the PC-demo-software
PSCi Software for PC
one port is sending the data and a second port (or PC) is listening to the PSCi-Software with br@y's terminal software to analyse byte for byte what it is sending
you can use this program too to once send the commands with the PSCi-Software to brays terminal with showing the received bytes as hexadecimal values
and then program the propeller and send the commands to brays terminal to compare your bytesequence with the PSCi-bytesequence
But you seem to be a guy that wants it up and running.
So I call @Parallax: do you happen to have some kind of practicant right now who could develop a demo-program in SPIN?
or does anybody of the staff have two hours time to write a SPIN-demo?
I would like to but I don't have the time in the moment and I don't have a servo-controller to do the REAL testing
There was another thread just a few days ago about this servo-controller
propeller USB servo controller HELP
I will explain there how I ASSUME how it should work
best regards
Stefan
www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/595/Default.aspx?txtSearch=servo+controller
The documentation shows examples for the Stamps. For the Propeller, you'd use a serial driver like Simple_Serial from the Propeller Object Exchange and use the .TX and .STR method calls to transmit single characters or strings respectively to the servo controller
The Stingray has its own Propeller and can control up to 32 servos by itself using the Servo32v7 driver from the Object Exchange. This driver is essentially the same as the driver used in the Propeller Servo Controller's firmware.
can u pls tell me how the servo controller board program differentiates between a character value sent or an integer value sent?
The firmware interprets the bytes in different ways depending on the position of the byte in the command-string.
quoting from the servo-controller-board manual
Position Command – Set the Position of a Servo Channel
Syntax: “!SC” C R pw.LOWBYTE, pw.HIGHBYTE, $0D
The first three bytes are as ACII-characters "!SC"
you could also send #033 #083 #067
serial.str(string("!SC"))
and
serial.tx(33)
serial.tx(83)
serial.tx(67)
does the same
or as a complete commandstring you could send
serial.tx(33) 'ASCII-code for "!"
serial.tx(83) 'ASCII-code for "S"
serial.tx(67) 'ASCII-code for "C"
serial.tx(12)
serial.tx(43)
serial.tx(250)
serial.tx(0)
serial.tx(13)
this does the same as sending
serial.tx("!")
serial.tx("S")
serial.tx("C")
serial.tx(12) 'channel
serial.tx(43) 'ramp-value
serial.tx(250) 'lowbyte of servoposition
serial.tx(0) 'highbyte of servo position
serial.tx(13) 'terminating carriagle return
quote from the manual
Position Command – Set the Position of a Servo Channel
Syntax: “!SC” C R pw.LOWBYTE, pw.HIGHBYTE, $0D
Reply: none
To control a servo, you must write a position command to the PSC. Each position command is comprised
of a header
three parameters: C, R, and PW, and a command terminator.
The Header: “!SC” is the header. The header signifies to all devices on the same wire that this is a
command for a Servo Controller.
The C parameter is a binary number 0-31 corresponding to the servo channel number. The servo
channel number should be 0-15
The R parameter is a binary number 0 – 63 that controls the ramp function for each channel. If the ramp
parameter is set to 0, ramping is disabled and the pulse width will be set to the P parameter sent
immediately. Ramp values of 1-63 correspond to speeds from ¾ of a second up to 60 seconds for a full
500uSec to 2.50 mSec excursion for standard servos. This correlation is rather linear though no equation
presently exists.
The P parameter is a 16-bit Word that corresponds to the desired servo position. The range, (250-1250),
corresponds to 0 to 180 degrees of servo rotation with each step equaling 2 uSec.
the "16 bit integervalue" for servoposition is divided into a lowbyte and a highbyte
The command terminator, $0D, (CR), must not be omitted.
I recommend you start experimatation a little bit to understand how it works
best regards
Stefan
I have started little experimentation .
i have got a problem. can u pls tell me that as connect the servo controller with the stingray with a 3 pin header(vcc, signal, gnd), will the stingray be able to receive any data from the servo controller? Because I think that for transmitting and receiving data, 2 pins are required-Tx and Rx.
i am using the following program in my propeller to control the servos thru the servo controller
OBJ
serial : "simple_serial"
pst : "Parallax Serial Terminal"
var
byte ch
byte cr
byte ramp
byte lowbyte1
byte highbyte1
byte lowbyte2
byte highbyte2
con
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
pub main
ramp := 56
ch:=48
cr:=13
lowbyte1:=250
highbyte1:= 9
lowbyte2:=250
highbyte2:= 1
serial.init(-1, 18, 2400)
pst.Start(2400)
repeat
waitcnt(clkfreq * 1 + cnt)
serial.tx(33)
pst.Char("!")
serial.tx(83)
pst.Char("S")
serial.tx(67)
pst.Char("C")
serial.tx(0)
pst.Char(ch)
serial.tx(20)
pst.Char(ramp)
serial.tx(250)
pst.Char(lowbyte1)
serial.tx(1)
pst.Char(highbyte1)
serial.tx(13)
pst.Char(cr)
waitcnt(clkfreq * 3 + cnt)
serial.tx(33)
pst.Char("!")
serial.tx(83)
pst.Char("S")
serial.tx(67)
pst.Char("C")
serial.tx(0)
pst.Char(ch)
serial.tx(20)
pst.Char(ramp)
serial.tx(250)
pst.Char(lowbyte2)
serial.tx(1)
pst.Char(highbyte2)
serial.tx(13)
pst.Char(cr)
The main problem is that when i sent commands from matlab serially, the servo responded correctly but when i sent them thru propeller, they didn't worked. Under my thinking, it is because i am unable to send the commands in ascii format which is required by servo controller. the same thing is easily done through matlab.
But i am supposed to use propeller only to send commands to the servo controller.
Please help
2) You're confusing things by sending different values to PST and to the servo controller. If you want to see what's going on, send the same things to both devices. For example, you could use:
pst.char("!")
serial.tx("!")
pst.char("S")
serial.tx("S")
pst.char("C")
serial.tx("C")
pst.char(ch)
serial.tx(ch) ' note: ch normally has to be defined in the range of 0 to 31
pst.char(ramp)
serial.tx(ramp)
pst.char(lowbyte2)
serial.tx(lowbyte2)
pst.char(highbyte2)
serial.tx(highbyte2)
pst.char(cr)
serial.tx(cr)
If you want to look at the byte value you're sending out (and make sense of it), you can use pst.dec instead of pst.char. This will take the supplied value and translate it into a series of digits for display. For example, if you put
pst.dec(250)
This will transmit the characters "2", "5", "0" to the display and you'll see "250" instead of some funny symbol.
you can analyse much better as brays terminal allows to show each byte as ASCII-Code as decimal value and as hexdecimal value
f.e. if you send serial.tx(17) in PST you will see one of these funny symbols or something else
in brays terminal you can switch on show decimal values and there you will see "17"
best regards
Stefan
I got that the pst can not show all the commands i am sending but still my problem is not solved because the servo controller must be receiving and interpreting those commands. Pls tell me there is any mistake in the sequence of commands sent through that program.
As I don't have a servo controller board handy I can only help by pointing to a more detailed analyse that YOU can do.
This case seems to develop in the typical matter of something should go superfast and right because of wanting it superfast it turns out superslow.
I'm asking you EXPLICIT do you have a second PC? answer with Yes or No.
Or do you have a second serial port? answer with Yes or No.
Did you do tests the servos with the PSCi Software for PC ?Answer Yes or No
If your servos work with the PSCi Software take Br@ys Terminal NOT PST.EXE to analyse BYTE FOR BYTE what the PSCi Software is sending
PC1 PSCi Software
PC2 running Br@ys Terminal
Then let the propeller send to PC2 running Br@ys Terminal
Propeller
PC2 running Br@ys Terminal
and compare BYTE FOR BYTE if your spin-program sends the same bytesequence
If there is no difference in the bytesequence it might be a hardware-related problem.
To do the most DETAILED analyse of your SPIN-code ATTACH the whole SPIN-code to a posting instead of cut and paste a part of it.
If I write the WHOLE code I mean the WHOLE code. The bug could hide in a codeline that you never think of that the bug is there.
best regards
Stefan