RobotStudio event

robot tracks part

Options

I have making a Vba macro that moves a part in one direction. I want to the following:

1)move the robot to a position close to the part

2)start the macro to move the part.

3)start the robot to move sync with the part, by moving the robot to a point. The robot motion is implemented in the robot controller.

 

Regards Michael

Michael

Comments

  • John Wiberg
    Options

    Question:
    Should the part follow the robot or should the robot follow the part or are they moving seperately?

    If the part should follow the robot motion then I can see two simple solutions. Either make an attachment or adjust the parts transform to the current TCP. To do the latter one you will need to create a RobotStudio Controller Class which you add to the simulation so that you can get the simulation.beforetick event.

    If you want the robot to follow the part then you are in for trouble since it is hard to send positions to a running virtual controller. You would end up having to cheat in some way.

    If they are just going in the same direction but with seperate motions then again you would have to create a RobotStudio Controller Class to get the simulation.beforetick event.

  • Hello again

    The robot are intended to follow the part. The robot grips the part which are placed in a stepwise moving fixture. So when the part moves the robot need to follow the motion (use of softservo and moveL).

    In my implementation i start the partmotion with an I/O instruction through the eventtable. The next instruction in the robot controller is a moveL instruction. But that don't work (the parts move first and the robot afterwards).

    I try to find an intruction i VBA to reach the robottarget but it is hard to find.

    Regards

    Michael

    Michael
  • John Wiberg
    Options

    If you just execute a macro from the eventtable the VBA engine will take over until the macro is finished.

    One way of getting around this is by adding a "DoEvents" line in your code, but that will give erratic behaviour.

    If you truly wish to get the robot and the part to move at the same time then you need to put the motion in the simulation events.

    So you need to add a Controller Class to your module (right click).

    Here is some sample code you can play with:
    (In this example the Controller Class is named "Movement".)
    (It moves two parts and a mechanism, make sure to change names and remove the ones you are not using.)

    Code in the RSproject

    Sub startingCtrl()
        Dim x As Movement
        Set x = ActiveStation.CreateController("Movement")
        x.Name = "JohnWiberg"
        ActiveStation.Simulations("Simulation1").Controllers.Add x
    End Sub
    Sub stopCtrl()
        ActiveStation.Simulations("Simulation1").Controllers("JohnWiberg").Delete
    End Sub
    Sub scan()
        Dim x As Controller
        For Each x In ActiveStation.Simulations("Simulation1").Controllers
            ActiveStation.PrintLog "Log", x.Name
        Next 
    End Sub

    Code in the Controller Class:

    Dim velocity As Integer
    Private Sub Controller_AfterTick(ByVal Time As Double)
        ActiveStation.Parts("Part1").Transform.x = ActiveStation.Parts("Part1").Transform.x + UnitToAPI(rsQuantityLength, velocity * 10)
        ActiveStation.Parts("Part2").Transform.z = ActiveStation.Parts("Part2").Transform.z + UnitToAPI(rsQuantityLength, velocity * 10)
        ActiveStation.Mechanisms("turning").Joints(1).JointValue = ActiveStation.Mechanisms("turning").Joints(1).JointValue + UnitToAPI(rsQuantityAngle, velocity)
    End Sub
    Private Sub Controller_Create()
        velocity = 1
    End Sub

     

    I'm sorry but I don't have the time to properly comment the code.

    image