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.
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.