RobotStudio event

RAPID, Analog Input conversion into a Number

Hello Everybody, here's the question I'd like to solve:

- In a RC5 controller, I have an Analog Input signal (ai1) correclty configured (i.e. if i write "WaitAI ai1, \GT, 5;" and I point with the mouse in RobotStudio on the "ai1" name, I can see the values changing correctly)
- BUT i cannot figure out how to assign these values to a variable (i.e. a VAR num variable), since it is impossible to write something like

VAR num ai_num;
ai_num := ai1;

or 

TPWrite "my input signal now has this value: "\num:=ai1;

So, how can I assign an analog input value to a variable (and use that variable in TPwrite or somewhere in the program) ?
Have I to use complex switchcases and the ISignalAI command ?

Thanks a lot to everyone who will decide to help me with this question,
(and sorry if an answer is already existing on the forum, but I did not find it)
All the Best,
Paul


Comments

  • Hello
    I think you can do this
    ai_num := AInput(ai1);
    and for TPWrite you need to convert to string ValToStr ( ai_num )

    TPWrite "my input signal now has this value: "+ ValToStr ( ai_num );

    /Pavel

  • Hello Pavel,

    worked perfectly, thanks a lot!