RobotStudio event

SetDO problem

Hey all,

I am trying to add counter to my SetDO signal so that i can change 10 digital outputs inside the loop by using only one SetDO command. I can't get it to work and I haven't found solution from rapid refrence(or im just getting tired now :))
.
.
.
FOR i FROM 1 TO 10 DO
SetDO dotest + numtostr(i),1; ! this dont work
SetDO dotest + i,1; ! This either don't work :(
ENDFOR

Is they a way to add num variables to your signal name? Hope you get the idea what im after from above.

- Marko
-once i thought i was wrong but i was mistaken-

Comments

  • Hi Marko
     

    It is not possible to add num variables to a signal.

     

    One way is just to write directly:


    SetDO dotest1,1;
    SetDO dotest2,1;

    ...

     

    Another way is to define a groupe of signals in the EIO.cfg like: goTest that includes Signal dotest1 up to dotest10. To set all 10 signals you do:


    SetGO goTest,Pow(2,10)-1;

     

    Best regards

     

    Marcel
  • Hi Marko,

     

    It is possible to add num variables to the name of a data signal.

     

    Try This:

     

    MODULE ModuleIOTest

      VAR signaldo doTest;

     

      PROC Set10DOs()

     

        FOR i FROM 1 TO 10 DO

          GetDataVal "doTest"+NumToStr(i,0), doTest;

          SetDO doTest, 1;

        ENDFOR

      ENDPROC

     

    ENDMODULE

     

    doTest1 thru doTest10 must be defined in EIO.CFG.

     

    Have a look at GetDataVal - Get the value of a data object in the RAPID Reference Manual - it is not real clear in the documentation that you can also use this on IO signals, but it seems to work. (Maybe the manual needs some more examples)


    GetDataVal (Get Data Value) makes it possible to get a value from a data object that is specified with a string variable.
    Thomas J2011-12-19 20:49:57
    Thomas H. Johnston
    PACs Application Engineer
  • Hi,

    I tested how Thomas suggested and it worked great! Thanks both of you. Awesome help here.

    -Marko
    -once i thought i was wrong but i was mistaken-