RobotStudio event

Group Digital Input value as a declarated variable

Hello,

i'm working on my own project and i get some troubles.

The main idea in my project is to get some randomness so i used Random option using SmartComponent tool to generate random number in defined range.I used Converter, made necessary connections, crossed SC and system signals, and in result value of Group Digital Output is my random number.

Unfortunately i need this value to bo declareted as a variable in RAPID - when i doing this i have info that my signal is not constant expression and cannot be declareted. 

Is there any posibility to declare this as a variable?
If isn't, how can i use Random function in other way?

Thanks in advance for your help,
Mikołaj

Comments

  • Hello,

    You can define a persistent numeric data and write that numeric data continuously in background task.


    Background task

    PERS num nRandom:=0;

    WHILE TRUE DO

        nRandom := GOutputDnum(goRandom);
        WaitTime 0.1;

    ENDWHILE

    You can use nRandom variable anywhere you want at motion task.

    BR.

    Erdem