# How to simulate moving objects

**URL:** https://tech-community.robotics.abb.com/t/how-to-simulate-moving-objects/103
**Category:** RobotStudio S4
**Created:** [December 10, 2003, 8:37am UTC](https://tech-community.robotics.abb.com/t/how-to-simulate-moving-objects/103 "2003-12-10T08:37:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Martin](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Martin](https://tech-community.robotics.abb.com/u/Martin)
#### Post date: [December 10, 2003, 8:37am UTC](https://tech-community.robotics.abb.com/t/how-to-simulate-moving-objects/103/1 "2003-12-10T08:37:14Z")

</div>

Here is an example how to simulate moving objects, for instances, parts on a conveyor.

This is a VBA example that was used in a project. A timer (ccrpTmr6.dll) is also required. [818\_Ccrptmr6.zip](http://forums.robotstudio.com/webwiz/818_Ccrptmr6.zip)

This code defines a timer that calls a routine (that moves bottles) every 10th millisec:

Public WithEvents waitTime1 As ccrpTimer

Sub EnableBottlefeed()  
Set waitTime1 = New ccrpTimer  
waitTime1.Enabled = True  
End Sub

Private Sub waitTime1\_Timer(ByVal Milliseconds As Long)  
waitTime1.Interval = 10  
'Move the bottles  
BottleFeedIncrease  
End Sub

This code moves some bottles (along Y-axis) until it reaches an end-point. Then a signal is set and the timer is disabled:

Sub BottleFeedIncrease()  
Dim VC As Controller  
Dim dblBottlesYcord1 As Double  
Dim dblBottlesYcord2 As Double  
Dim dblBottlesYcord3 As Double

Set VC = ActiveStation.Controllers(“IRB640\_M2000”)  
dblBottlesYcord1 = bottles1.Transform.y  
dblBottlesYcord2 = bottles2.Transform.y  
dblBottlesYcord3 = attachBottles.Transform.y

'DoEvents  
dblBottlesYcord1 = dblBottlesYcord1 - 0.05  
bottles1.Transform.y = dblBottlesYcord1  
If bottles2.Transform.y \> 1.36 Then  
dblBottlesYcord2 = dblBottlesYcord2 - 0.05  
bottles2.Transform.y = dblBottlesYcord2  
Else  
bottles2.Transform.y = 1.36  
End If

If attachBottles.Transform.y \> 2.325 Then  
dblBottlesYcord3 = dblBottlesYcord3 - 0.05  
attachBottles.Transform.y = dblBottlesYcord3  
Else  
attachBottles.Transform.y = 2.325  
End If  
ActiveStation.Refresh  
If bottles1.Transform.y \< 0.05 Then  
bottles1.Transform.y = 0  
ActiveStation.Refresh  
ThisStation.waitTime1.Enabled = False  
VC.IOs.Item(“doBottleFeed”).Value = 0  
VC.IOs.Item(“doCCfull”).Value = 1  
End If  
End Sub

---

<div class="post-metadata">

### Author: ![John\_Wiberg](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/john_wiberg/32/1485_2.png) [@John\_Wiberg](https://tech-community.robotics.abb.com/u/John_Wiberg)
#### Post date: [December 11, 2003, 11:23am UTC](https://tech-community.robotics.abb.com/t/how-to-simulate-moving-objects/103/2 "2003-12-11T11:23:08Z")

</div>

Why wouldn’t you want to use a RS controller class instead?
