loading
 
Changing Servo speed from VBScript
Ariel Sandez from Argentina  [1 posts]
6 years
HI, Iím working with VBScript module sending variables to Lynxmotion_SSC but I donít know how to change the servomotor speed from VBScript. Iím only able to modify the speed from the Lynxmotion_SSC interface for every motor. My objective is to accelerate the arm at the beginning of the movement and slowdown before the tip reaches the target.

-    Is it possible to modify the servo speed programmatically in VBScript module?

Let me know if you have any advice.

Thank you.
Anonymous 6 years
Ariel,

If you download 2.37.5 you will be able to use the

[variable]

expression in the rate field (and the min/max too) to get that value from a variable. So if you want to control the rate of channel one put in something like

[channel_1_rate]

and set that variable to the rate that you want to send to the board.

The next question you will have is how to alter that variable at specific times. You'd have to use one of the programming modules like the VBScript module and enter

if GetVariable("servo_1_pos") <> 2500 then
  ' set the servo position to extreme
  SetVariable "servo_1_pos", 2500
  SetVariable "channel_1_rate", 5000
  SetTimedVariable "channel_1_rate", 2000, 500
  SetTimedVariable "channel_1_rate", 100, 1000
end if

which will set the servo position to the max and start out really fast. 1/2 second later (500ms) it will slow to less than 1/2 speed and finally after 1 second (1000ms) it will really slow down till completion.

The trick here is the timing.

IF you have feedback turned on that is can be more automatic.

if GetVariable("end_servo_1_pos") <> 2500 then

  ' set the servo position to extreme ... this will CHANGE with feedback
  SetVariable "servo_1_pos", 2500
  SetVariable "end_servo_1_pos", 2500
  SetVariable "channel_1_rate", 5000

else

  ' adjust rate
  diff = GetVariable("servo_1_pos") - GetVariable("end_servo_1_pos")
  if diff < 0 then diff = - diff
  if diff < 1000 then
    SetVariable "channel_1_rate", 3000
  elseif diff < 500 then
    SetVariable "channel_1_rate", 2000
  elseif diff < 100 then
    SetVariable "channel_1_rate", 100
  end if

end if

which will set the rate based on how far the servo has to go. You can play with the actual distance to speed values (or even create a formula which will transform distance into speed) to get the right ones for you.

Hopefully this gets you along the desired path.

STeven.
Ariel Sandez from Argentina  [3 posts] 6 years
Thank you Steven for the detailed example. This is valuable information for the arm movement. Great software!

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index