Tick problem
Hi, I'm trying to use the tick system but it's getting me crazy. I just want show every second a message in the log when simulation is running, to know how the ticks work.
Also I've tried to run this example from the robotstudio help, getting the same results: nothing.
Thanks!
'In TheRoborStudioProject
Dim WithEvents sim As Simulation
Sub InitBoxCtrl()
Set sim = ActiveStation.Simulations(1)
'Set the resoluition of the Simulation to 0.5 seconds
'The simulation will generate a Tick event every 0.5 seconds
sim.Resolution = 0.5
' Create and add a contoller to the simulation
Dim BoxCtrl As BoxController
Set BoxCtrl = ActiveStation.CreateController("BoxController")
Call sim.Controllers.Add(BoxCtrl)
BoxCtrl.IOs.Add
'Start the simulation
sim.Start
End Sub
Sub sim_Tick()
'For instance do collision detection
End Sub
'** This is the Controller class called BoxController, used above
Dim myPart As part
Dim speed As Double
Private Sub Controller_AfterTick(ByVal Time As Double)
myPart.Transform.x = Time * speed
myPart.Entities(1).Color = Array(Int(Time * 100) Mod 255, Int(Time * 200) Mod 255, Int(Time * 300) Mod 255)
End Sub
Private Sub Controller_BeforeTick(ByVal Time As Double, MaxTime As Double)
'Do test if possible to have stepsize Time otherwise
'return max step size in MaxTime
End Sub
Private Sub Controller_Create()
'Called when a controller instance is created
Set myPart = ActiveStation.Parts.Add
Call myPart.CreateSolidBox(New Transform, 0.2, 0.3, 0.4)
End Sub
Private Sub Controller_Start()
speed = 0.5
End Sub
Private Sub Controller_Stop()
'Do tidying up
End Sub
Comments
-
Hi
The way to do this is to insert a controller class (in VBA menu insertcontroller class)Name it "myController"
The open up the code window for that controller class and select the After_Tick event and add your code.
Example:
Private Sub Controller_AfterTick(ByVal Time As Double)
ActiveStation.PrintLog "Time", CStr(Time)
End SubThen open the code window for this station and add following
Dim m_controller As Controller
Sub Start()
Set m_controller = ActiveStation.CreateController("myController")
ActiveStation.Simulations(1).Controllers.Add m_controller
End SubThen execute the Start sub and after that press play in RS.
The controller class should write the time to the log window every tick.
Hint
To be able to see what simulations and controllers you have in RS uncheck prune subtree in menu
SettingsBrowser settingsPrune subtreeYou will now have more information visible in the browser.
Per Svensson
Company Specialist
ABB Automation Technology Products0 -
Thanks for your fast repply, I was suspecting that the problem came this way.... but the next problem is: What I must do to change the name of a "controller class"?
And regarding your hint, You were referring to the Robotstudio Window or the VBA window?, sorry, I can't find it.
Thanks!
0 -
Hi
To change the name of a controller class just select the class and change the name in the property browser. (VBA Window)
The hint refer to the RS Window menu View (sorry forgott View)
Per Svensson
Company Specialist
ABB Automation Technology Products0 -
Thanks for your time, your replies was very usefull for me.
See you!
Alfredo
fredomon38673,05638888890
Categories
- All Categories
- 5.5K RobotStudio
- 395 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings