Servo Control Education Request
PoorYuppie
Posts: 13
So go easy on the new guy.... I could use some help and I think this is the right forum.
I'm basically building a remote camera,· which will always be controlled by a pc/user via the mouse.· I know there is stuff out there like this, but nothing with an interface I want to work with so I'm building my own.
I'm using the following:
-Futaba servos
-USB Parallax 16 servo controller
-VB express(not a requirement, but it's what I have right now)
I've searched this forum and the crust crawler forums.· I understand how to open and write to the comm port, but that's where everyones examples seem to break down.· The actual syntax and commands that drive the servos always seem to be missing or burried under a mountain of code and multiple piles of over complicated/redundant variables to where I can't understand what the programmer is doing.·
I never plan on using a stamp or anything like that, I'm just trying to build the link between the mouse and multiple axis' of servos at the same time.
I learn best by example, so if anyone has simple snipits of code for connecting to a comm port and driving a servo in VB Express I would really appreciate the help.
Thanks,
I'm basically building a remote camera,· which will always be controlled by a pc/user via the mouse.· I know there is stuff out there like this, but nothing with an interface I want to work with so I'm building my own.
I'm using the following:
-Futaba servos
-USB Parallax 16 servo controller
-VB express(not a requirement, but it's what I have right now)
I've searched this forum and the crust crawler forums.· I understand how to open and write to the comm port, but that's where everyones examples seem to break down.· The actual syntax and commands that drive the servos always seem to be missing or burried under a mountain of code and multiple piles of over complicated/redundant variables to where I can't understand what the programmer is doing.·
I never plan on using a stamp or anything like that, I'm just trying to build the link between the mouse and multiple axis' of servos at the same time.
I learn best by example, so if anyone has simple snipits of code for connecting to a comm port and driving a servo in VB Express I would really appreciate the help.
Thanks,
Comments
http://www.parallax.com/Store/Robots/RoboticAccessories/tabid/145/List/1/ProductID/376/Default.aspx?txtSearch=PSC++USB&SortField=ProductName%2cProductName
See the bottom of the page for the PDF link.
OK, now the examples on the non-USB version expect you to be using a BS2, but instead you're using the PC.· This is not a problem.
So, VB Messages example:
DIM MyStr as STRING
Dim GetVer as String
Dim ReplyStr as String
Dim ChanStr as String· ' Is the Servo 'Channel Number' string.· With one PSC, will be CHR(0) through CHR(15)
Dim RateStr as STring· ' Is the Servo 'Ramp rate' value string.· CHR(0) == fast as possible, CHR(63) == slowest
Dim PosVal as Long····· ' Is the desired position -- 16 bits unsigned.
Dim PosLow as BYTE, PosHigh as BYTE
GetVer = "!SCVER?" + CHR(13)· ' Chr(13) is the ending "$0D" from the examples.
MSComm.Send(GetVer)· ' Or something like this...
MSComm.Get(ReplyStr)· ' Or something like this -- should have "1.3" or similar.
ChanStr = CHR(0)· ' Command channel zero
RateStr = CHR(0)· ' Move as fast as possible
PosVal = 1500
PosLow = PosVal & $FF
PosHigh = PosVal >> 8
MyStr = "!SC" + ChanStr + RateStr + CHR(PosLow) + CHR(PosHigh) + CHR(13)
MSComm.Send(MyStr);
Post Edited (allanlane5) : 1/8/2008 8:47:49 PM GMT
I'll try and post a video when I get it up and going.
None of these lines from the code above work in Express for me.
MSComm.Send(GetVer)· ' Or something like this...
MSComm.Get(ReplyStr)· ' Or something like this -- should have "1.3" or similar.
PosLow = PosVal & $FF
PosHigh = PosVal >> 8
The "MSComm" and· "$FF" throw errors.· I figured out how to send stuff to the controller, and I'm sending the closest thing to the controller I can, it just repeats everything back to me and does nothing.· So I'm just trying to get it to reply to the request for version that I'm sending.· I'm sending the following:
·"!SCVER?" + CHR(13)
and all I get back is "!SCVER?· "
Any ideas on what I'm doing wrong?
http://www.awce.com/pak11.htm
http://www.awce.com/pak6.htm
BS2 code is provided with the application notes. These co-processors allow you to hook a PS2 mouse and or keyboard to the basic stamp.
I use one to control two servos X and Y motion and I am also using one as an infrared remote in an assisted living facility. Move the mouse to change the volume and or select a channel.
I use the servos and RANDOM to move a laser pointer to keep my dog busy.
I hope this helps.
SJW
$FF is VB6-ism for a "hexadecimal literal". You can replace it with 255, if that helps.
If you're using the right baud-rate, serial port, and USB driver, then you should get back "1.3" or so. But you need to verify baud-rate, serial port, and USB driver.
First thing i would do is open HyperTerminal it is a program on your PC its under START>ALL PROGRAMS>ACCESSORIES>COMMUNICATIONS>HYPERTERMINAL this program allows you to set up a connection to your serial port on the PC and send command via text to the servo controller.·Set the device to what Com port you are using then 2400 baud, no parity, eight data bits, two stop bits and no flow control.
Second you can just type in !SCVER? and press enter and it should return the Firmware # say...1.3
If it works in hyperterminal then you can start on a VB.net program.
I will work on a simple VB.net program and hope this helps.
Post Edited (bennettdan) : 1/28/2008 5:42:46 AM GMT
Now I can query the PSC and get the version back. I can also get the position of the servos but that's the next piece of the puzzle. They come back as squares(unknown characters). I have an array of characters 10 places long, and I need to change the last two(position high and low bytes) from unknown characters into something usable. If I could figure out how to do that, I think I could do the same in reverse to drive the servos. Any ideas?
Public sData As Byte() = New Byte(7) {&H21, &H53, &H43, &H0, &H0, &H0, &H0, &HD}
······· sData(3)=channel
······· sData(4) = ramp
······· sData(5) = lo_byte
······· sData(6) = hi_byte
If SerialPort.IsOpen Then
··········· SerialPort.Write(sData, 0, 8)
End If
the first three bytes represent the ASCII codes for " !SC·", then come the parameter bytes terminated with &HD (CR), obviously you will have to determine how and where to fill in the other parameters.
perhaps you could try·placing it in·bennettdan's example,·I'm not sure whether this is the answer but from looking at other PSC code it seems like it would·work.
Jeff T.
Just wondering if you got this working or if you still need help?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Robot vision is the the future, and Vision will take us there.
http://www.youtube.com/watch?v=gbf0zaxWjvI
(If so: how? )