Visual basic 6.0?

hello,

I just recieved my ssc-32 and servo’s. For a project on school I wanna make a Robot Arm so in the time I had to wait for the parts to be deliverd I made a control program in visual basic but when i made a test program to control the servo it didn’t work. So i tried the LynxTerm to test and it did work. I use the MSComm to send date with my com port
If I use a command button to execute
MSComm1.output= "#0 P2000 "

when it is click. But when I click I only se the green led light up for a short while but nothing happens.
I checked the port and baud settings and they are all oke.
So is it possible to send it with VB or did I make my control programm for nothing :frowning:?

thnx,
Rik

Provided that you have access to the full .NET framework, it’s definitely possible to use visual basic to talk to your SSC-32.

In fact, I plan on doing just that (well, using VB Express) as soon as I get my WiPort.

Could you please post your full code that your having a problem with?

try changing

MSComm1.output= "#0 P2000 <cr> " 

to

MSComm1.output= "#0 P2000" & vbCrLf 

Oh, duh!
I should have noticed that…
:blush:
Visual basic uses “vbCrLf” as a carraige return…
I suppose that Microsoft felt that they had to make it all fancy to confuse us (no suprise there, eh?).
Incidentally, does anyone know what that stands for?
“Visual Basic Carriage Return L-something f-something”, I suppose.

The lack of a carriage return sounds like it’s your problem.
When I forget to type “” in the LynxTerm, my SSC-32 lights up, but does nothing, as well.

Good eye, Andy.
:smiley:

At the end of every command, the SSC-32 wants not just the carriage return, but a line feed as well. They are not the same thing (as I found out while writing my Java SSC-32 terminal). :slight_smile:

Mike

I just tested it and it worked, I would never had come up with that!!!
You just saved my whole project (and a new hobby)

I wanna thank you very much andylippitt!!!

Thnx again!

greetings Rik

Glad to be able to help… I think you’ll find everyone here is trying to help everyone else out, so if you run into something else that looks like a showstopper, it’s not. We’ll all help you get through it. :slight_smile:

vbCrLf is Carriage-Return, Line-Feed.

It’s the combination of two ascii chars 13 and 10. Although I remember the conversations with mwgemini suggesting that the ssc32 is only looking for the LF. If so, you might try just vbLf.

No, Andy, you were right the first time. I originally thought it was just the line feed that the SSC-32 needed, and wrote my code accordingly. It was you who pointed out my error. I can check my code again, but I am almost positive that it requires both, though the manual led me to believe otherwise originally, if I recall correctly.

Mike

well here I have a other problem not really much with the ssc-32 but with my program. I tested my HS-475HB and HS-81 servo’s and they work great with the commands, but when i tested the Continuous Rotation servo I noticed that the pulse lengt determines the speeds in which it turns. I wanna use the CR servo to make the base of my arm rotate. But I don’t want it to be able to turn more then 2 rounds(because of the cables) . The problem is not to stop the CR from keep turning when I release the mouse button from the command button, but the problem is the limit of 2 rotations.
I use a command button with mouse_down en up, it sends a pulse when mouse is down and a pulse when mouse up to stop the rotation. But when the mouse down function is being execuded it only reads the code in its sub once, so even if I use If and Then function ( like when a timer counts +1 to a label and when the label is 5 the output of the puls would change so that the servo stops) it doesn’t read it for a second or third time to check if the label is already at 5.
So does do you think it is still possible to make a command button like that or do I have to do it without the limitation.

If I understand what you want correctly you have a function you want to run repeatedly while the command button is depressed.

Create a timer. Set it’s interval to the number of milliseconds you want between calls to the repeated function and default enabled = false.

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer1.Enabled = True
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
    'This code runs once every timer1.Interval ms while the button is depressed
End Sub

I knew that but that isn’t really my problem, (my english ain’t so good :unamused: )

for the Command1_mousedown I’ve something like that, The timer starts and counts +1 to a label. and then I want if the label has a value of lets say 5 I want the MSComm1.output of the Command1_mousedown to change But i can’t do that with an If Then function because it only reads the code in the mousedown once. And if I loop the If Then function It freezes up.
this is what I have

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Timer1.enabled ' timers adds +1 to a label if label1.caption <5 then MSComm1.output= "#1 P1500" & vbCrLf ' makes the CR servo to rotate at a certain rate elseif label1.caption=5 then MSComm1.out= "#1 P1525" & vbCrLf ' stops the servo end if End Sub

is there anyway to make a sort of loop in it?

Did you try executing the program step by step?
Can you show the code for the timer sub?
And, can you show the code for the MouseUp?

From the sound of it, it looks like (sorry, that’s a mixed metaphor) your using the MouseDown to add 1 to a label every time you depress the mouse.
So, if your label is zeroed, you would have to click the mouse five times in order for the = 5 to be true.

It sounds like all that your timer is doing is the same as:
labell.caption = labell.caption + 1

Yes you can solve this the way you want but I’d advise against it. The fix is to include DoEvents in your loop. What DoEvents does is releases the currently executing thread back into the message processing loop so that it can dispatch other windows messages (timers among them). I think it will solve your immediate problem, but will cause all sort of unexpected things to happen. When you do this, it not only allows timers, but other button clicks. So you can be in the middle of that loop, click another button, have all that buttons code execute, then return to your loop to finish. If you’re comfortable with such possibilities, go for it. I’d suggest however that you rework the code more along the lines I was suggesting and put everything you would have wanted inside the loop, instead into your timer handler.

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Timer1.Enabled = True ' timers adds +1 to a label
    MSComm1.output = "#1 P1500" & vbCrLf  ' makes the CR servo to rotate at a certain rate
End Sub

Private Sub Timer1_Timer()
    label1.Caption = Val(label1.Caption) + 1
    If Val(label1.Caption) = 5 Then
        MSComm1.out = "#1 P1525" & vbCrLf ' stops the servo
        Timer1.Enabled = False
    End If
End Sub

I changed a few things of significance: First, I’m only outputting “#1 P1500” one time, instead of each time through the loop, which should work just fine as far as the SSC32 is concerned. Secondly, I’m disabling the timer once it reaches 5. But the end result is that is an event driven version of that loop you wanted to put in the button handler. While this seems a bit clumsy, it will behave much more along the lines that you’d expect in terms of dealing with other, simultaneous events then if you were to use DoEvents.

at NickReiser, when I pressed the mousedown it would start the timer, the timer would ad +1 every 500ms (interval) so that wasn’t the problem. For mouseup I made the timer.enable= false and changed the output of the MSComm to stop the servo. The problem was to make a change of output, to stop the servo, when the label was 5 even when I was still pressing on the button.

so the code from Anylippitt worked by letting the timer change the MSComm output. I never thought about that option, I thought the mousedown function had to do that.

thnx for all the support!