Servo controller directly from pc
Hello, I am trying to control the PSC ( Servo controller USB) with vbs and I just CAN't get it to work.
I have tried all the combinations using the documentation of the protocol.
I noticed that it is USB which emulates serial so I tried the following code.
Set com = CreateObject ("MSCommLib.MSComm")
com.CommPort = 5
com.Settings = "2400,N,8,1"
com.PortOpen = True
com.Output = "33 83 67 0 0 222 4 13"
com.PortOpen = False
It flashes the green light, but it does not move the servo
I also tried putting "!SC 0 8 250 1240" I also used \r and all kinds of tricks, but to no avail.
Please guys ( especially the tech guru of parallax crew) help me how to command it with raw commands over the terminal.
I want to start development of a video software reacting to light and etc the project is really interesting and the only thing left is to inteface it with the servos.
Thanks in advance.
Best regards
Post Edited (f0xdude) : 1/20/2008 2:48:24 PM GMT
I have tried all the combinations using the documentation of the protocol.
I noticed that it is USB which emulates serial so I tried the following code.
Set com = CreateObject ("MSCommLib.MSComm")
com.CommPort = 5
com.Settings = "2400,N,8,1"
com.PortOpen = True
com.Output = "33 83 67 0 0 222 4 13"
com.PortOpen = False
It flashes the green light, but it does not move the servo
I also tried putting "!SC 0 8 250 1240" I also used \r and all kinds of tricks, but to no avail.
Please guys ( especially the tech guru of parallax crew) help me how to command it with raw commands over the terminal.
I want to start development of a video software reacting to light and etc the project is really interesting and the only thing left is to inteface it with the servos.
Thanks in advance.
Best regards
Post Edited (f0xdude) : 1/20/2008 2:48:24 PM GMT
Comments
com.Output = "!SC" &·ch·& ra·& low_byte & high_byte & 13
DIM ch As Byte·· (channel)
DIM ra AS Byte·· (ramp)
DIM position As Integer (16 bit integer)
The position values·you have in your code are out of limits, position needs to be within 250 to 1250. Also the 16 bit integer position is transmitted as high byte and low byte. Use the following to split position into high_byte and low_byte
low_byte=position AND &HFF
high_byte=position>>8
It's a long time since I messed with anything else but VB Express so you may have to juggle with this to get the syntax right.
Jeff T.
EDIT: BTW you might get more responses if you put a subject line to your post.·Edit 2: sorry I got high byte and low byte crossed I think one of your position values is just with the limits.
Post Edited (Unsoundcode) : 1/20/2008 2:28:18 AM GMT
In visual basic it reports an error here high_byte=position>>8
Can you give me some more info about the code or if you can a complete example.
I can use code on c++ also if a full example source code is present i should be able to modify it.
Does someone have examples in c or c++
Thanks a million in advance.
Best Regards
Post Edited (f0xdude) : 1/20/2008 2:49:01 PM GMT
DIM position As Long
DIM low_byte As Byte
DIM high_byte As Byte
DIM i As Byte
low_byte=position AND &HFF
position=position AND &HFF00
For i =1 to 8
position /= 2
Next
high_byte=position
Jeff T.
http://forums.parallax.com/showthread.php?p=546069
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
However, if someone has C or C++ code please share it here.
Best wishes!
http://forums.parallax.com/showthread.php?p=611904
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
However, I can see that they send raw data and I am now sure about the high_byte and low_byte.
Can anyone give a hint. Or more information about the high and low byte values themself. What exatly are they and how can they be emulated in the programming languages.
I am good at perl and c, but I do not have any experience in serial port communication and I find it very hard to understand how to write my own code to control the PSCUSB using c or perl.
Thanks in advance.
A 'byte' can go from zero to 255 (0x00 to 0xFF). A two-byte 'unsigned short int' (aka 'Word' on BS2) can go from zero to 65535 (0x0000 to 0xffff).
Now, serial communications using RS-232 can only send bytes. So, if you want to send a 16-bit value, you need to clip off the 'high' byte and the 'low' byte and send them as two separate bytes.
So, if you had a 16-bit value 0xC0ff, you'd send the low-byte 0xFF, then the high-byte 0xC0, .
Now, to convert 0xC0FF into those two bytes, you 'mask' off the top-bits, and keep the low byte.
$MyLow = $FullValue & 0xFF;
$MyHigh = $FullValue >> 8;
Yeah! Hey, allanlane5 thanks dude. I'll do some more reading on the topic.
However, I would like to leave this topic open for anyone who has developed projects regarding the PSC controlled from pc.
Greetings!
Who·can share the complete VB6 source code for me.
Thanks very much
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support