It is possible to do. I saw some tutorials online of how to send data to a serial port via via C++ and some other languages. Possible with VB6 I guess. But not sure if lynx might be happy about that lol, jp.
ya, i was going to say, it is possible with C++ I have a 500 pg book on it, but never go into it (basic C). Im sure it will work if it is able to send data to a serial port. Most commands should be recieved ok.
You just need the code to send a data string to the COM port that your bot is hooked up to. And as You set up the macros you can assign them to the buttons.
I’m not familiar with VB6, but I assume that it’s similar to VBE.NET 2005.
Here’s a simplified VBE.NET example of SSC-32 communication:
First open up the Visual Studio and add a SerialPort and three buttons to Form1.
Then configure the added SerialPort using the Properties box for the necessary specifications: 115200 baud (if that’s what your SSC-32’s jumpers are set up for), 8-bit, no parity, no flow control, 1 stop bit.
And, of course, select the proper COM port that your DB9 cable is attached to.
Then open up the code editor and paste the following:
Imports System
Imports System.IO
Public Class Form1
Dim servoposition(4) As String
Dim i As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
servoposition(1) = "#0P1268#4P1035#13P1912#15P1342#16P1203#17P1963#18P1266#20P1718#29P832#31P1682T510"
servoposition(2) = "#12P1896#13P1553#16P1466#17P1879#18P1687#19P1608#20P1851T510"
servoposition(3) = "#0P1408#1P1441#3P1966#4P1134#12P1770#13P1870#15P1511#16P1559#17P2048#18P1285#19P1397#20P1889T510"
End Sub
Private Sub MoveBiped()
SerialPort1.Open()
'vbCrLf = carriage return and line feed
SerialPort1.Write(servoposition(i) & vbCrLf)
SerialPort1.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
i = 1
MoveBiped()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
i = 2
MoveBiped()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
i = 3
MoveBiped()
End Sub
There’s a lot of room for improvement here, since I kept it as simple as posible for clarity’s sake.
For one, making “MoveBiped” a function, so that “i” could be directly passed to it would help.
Also, it might be necessary to use a timer to make sure that multiple button presses doesn’t send multiple servo instructions too quickly.
I actually used a textbox as an input stimulus (the way that buttons above are now used), so I wouldn’t need to look at the screen when moving my bot around.
A second read-only textbox was useful to display the last string sent to the SSC-32.
If you want to start out super simple, you should be able to make macros to operate your arm just by making batch files using notepad. You can also make web based applications just using the apache web server and notepad so you or anybody else on the net can operate your arm. I’ve made an application to control my servo based pan/tilt webcam using a joystick and a cheap gamepad connected to my computer using justbasic/libertybasic. You should be able to do much the same for your arm as the programming is simple if i can do it.
Your code actually didn’t work for me in VB6, But based on your code and ‘cwkoehler’
Code I wrote this which is working just fine:
Private Sub Command1_Click()
MSComm1.CommPort = 1
MSComm1.PortOpen = True
MSComm1.Output = “#0 P1000 T3000 #1 P2100 T3000 #2 P2100 T3000” + Chr$(13)
MSComm1.PortOpen = False
End Sub
Private Sub Command2_Click()
MSComm1.CommPort = 1
MSComm1.PortOpen = True
MSComm1.Output = “#0 P1000 T3000 #1 P1800T3000 #2 P1800 T3000” + Chr$(13)
MSComm1.PortOpen = False
End Sub
Private Sub Command3_Click()
MSComm1.CommPort = 1
MSComm1.PortOpen = True
MSComm1.Output = “#0 P1000 T3000 #1 P1600 T3000 #2 P1800 T3000” + Chr$(13)
MSComm1.PortOpen = False
End Sub
Private Sub Form_Load()
End Sub
I noticed that after each ‘MSComm1.Output’…. I need to put a
‘MSComm1.PortOpen = False’
I am not a programmer and I know this code doesn’t look sophisticated. Do you guys have any suggestion at least to improve the look of this code. Again the code does what
I want . But I have a feeling that it can be more sophisticated.
By the way I need help for the next step. I need to control my arm from my work through
Internet connection . Do I need a special software or hardware to do this ?
Any suggestion.
Indeed, your code is not sophisticated, but that’s definitely not a bad thing.
You might want to use a textbox as an input, so you don’t have to look at the screen.
Or, you could bypass the textbox and read all keypresses in the form directly and act upon them.
You could create a function that handles all of the sending for you as well as an array to store all of your strings in, as I have done.
But, that’s not really necessary.
I did it simply because that’s the way that I’ve learned to code.
In other instances it’s helpful, but with a simple program, there’s really no need.
One level of sophistication that might actually be helpful would be implimenting IK.
RIOS is a really great piece of software that does just that.
There’s also a bunch of tutorials for doing likewise in your own code on the LM main site.
About the internet, zoom mentioned something about an apache webserver and notepad.
Below are my setups for operating my servos over the net. In each case two servos are moving a web cam around. The same can probably be done for a servo based arm. On the bottom link, the video source needs to be selected to the pan/tilt cam so the movements selected in the control drop downs can be seen. From this you can see that simple control panels can be made without extensive programming involvement.
Geocities just serves up the basic web page and every thing else comes from my computer. Below is the setup for one of the cams. The bottom link is the home page with info on other stuff. Some of the stuff is a bit dated and is more like a 5 year tinkering blog.
Here are some changes to your code that will improve it’s efficiency.
Private Sub Command1_Click()
MSComm1.Output = “#0 P1000 #1 P2100 #2 P2100 T3000” & vbcr
End Sub
Private Sub Command2_Click()
MSComm1.Output = “#0 P1000 #1 P1800 #2 P1800 T3000” & vbcr
End Sub
Private Sub Command3_Click()
MSComm1.Output = “#0 P1000 #1 P1600 #2 P1800 T3000” & vbcr
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.PortOpen = True
End Sub
Private Sub Form_Unload()
MSComm1.PortOpen = False
End Sub
You only need to open the port once and this is done in the Form_load and then it is closed in the Form_unload. I believe the T3000 needs to only be applied once per command string. Instead of Chr$(13) I used the VB constant vbCr which is the same thing but more readable. Let me know if you have any other VB6 questions.
Good point.
I kept opening and closing the COM port each time I sent a string in the above example because it kept things fool-proof.
If the servos overdraw the battery and reset the SSC-32, the COM connection is interupted, which does funny things.
For an example’s purpose, it’s a clean way to do it, but it’s indeed much more efficient Scott’s way.
I wasn’t doing anything other than sending strings in my program and displaying some text, so it didn’t really matter.
If you’re going to be doing other things in the background, definitely go with Scott’s method.