Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 4 Next »

(blue star)

This section gives an illustrative example of using an animation bitmap. Settings may differ depending on your project’s configuration.

Exercise: Playing an animation bitmap object

The following example displays a conveyor belt which carries a box. The animation plays only when it is turned on by a button.

a) Create two tags: a digital tag for controlling the conveyor belt and an analog tag for controlling the box position. Name the tags “CONVEYOR” and “BOX”, respectively.

b) Go to [Edit] – [Insert Animation Bitmap] and select a conveyor belt object. Insert 2 of these objects into the graphic page.

c) Configure the tags for both objects as shown below.

d) During the animation, we want the conveyor belt to appear to rotate clockwise. For the chosen animation, this means we need to select the left-side object and press [Arrange] – [Filp(M)] – [Vertical], then select the right-side object and press [Arrange] – [Flip(M)] – [Horizontal]. Then, position the objects so that they appear to form a single conveyor belt as shown.

e) Go to [Draw] – [Rectangle] and insert a rectangle object in the graphic page. Place the object directly above the left conveyor object, as shown.

f) Select the ‘H-Move’ function in the rectangle’s [Object Configuration] window. Enter the name ‘BOX’ in the tag field and assign the data range from 0 to 30.

g) Set the base position as ‘Left’ under the [Horizontal Move] tab. Set the distance to 380.

h) Create a new ‘Start Up’ script called “script” in the [Tools] – [Script] editor. Edit the contents of the script as shown below. This script will constantly increase the value of the ‘BOX' tag by one (“BOX = BOX + 1“). If the box moves too far to the right (“if (BOX > 30)“), then the box will be moved back to the left (“BOX = 0;“). This is performed in a loop (“while (1) {<script contents>}”) so that the motion appears to be continuous.

i) Go to [Draw] – [Switch/Lamp] and create a bit switch to control the ‘CONVEYOR’ tag. Configure the object as shown below.

j) Launch the project in Xpanel or the simulator. When the switch is pressed, the conveyor belt and box will begin moving. The rectangle object moves from the left of the belt to the right side. When the ‘BOX’ tag value becomes greater than 30, the analog value will be reset to 0 and the box will move back to the left side.

  • No labels