Set a specific digital output from a function given a numeric ID

  • Hi all,


    I need to activate a digital output every time I call a function, when I am doing the first point, I want to activate the doPoint1, when I am doing the second point the function should activate the doPoint2 and so on.


    Late binding only work with procedures, it would be super easy with an array, but I don't know of any way to make an array to share the same memory space than a list of outputs.

    AliasIO does not seem the way to go either... as I would have to define an alias for each signal...

    A group output could be the way, setting it to the same address than all the DO bits, but I would have to calculate the right bit and make an bitwise OR with that,,,


    Something like this pseudocode:

    Code
    InitialValue = GOutput(groupOutuput);
    bitActiveValue = calculateValueWithOnlyOneBitActive(5);
    setGO groupOutuput, calculatedValue OR InitialValue; // BitOr seems only to work with BYTES not bigger groups.


    But as said in the comment, BitOR seems only to work with 8 bits at once...


    Apart of doing something like (PseudoCode again):


    Code
    CASE i:
      1: setDO doPoint1,1;
      2: setDO doPoint2,1:
    ...
    ENDCASE


    Not a big deal doing this... it would work and I have to do it only for 32 signals, but it's super ugly... :nauseated_face:


    How would you solve this small issue?


    Thank you all in advance.

  • When robot arrives at a taught point it calls a function and inside that function, it activates the right output related to that point...


    After the robot reached point 1, that function will have to activate the bit do1, after the robot reached point 2, that function will have to activate do2 and like this for all 32 points.


    :smiling_face:

  • That would not be enough, there is a full function that does several things before the do must be activated or not at the end.


    In any case, given it's a matter of only 64 signals, I can do it easily in Excel using a couple of concat formulas... ugly as @#$%, but it will work.

  • Yes, but then the problem is the same than at the beginning, I need to activate do1, or do2, or do3 and I know only the number 1, 2 or 3 when I call the function.


    I'd like to know how to do something like setDO(%do%3,1); to activate the 3rd do.


    That's my problem, in fact MoveLDo would be great if I could activate the output directly, but I can't as the programmer could just add the right output to the movement, but in my case, I need to activate a bit from a auxiliar function that is called when I stop in all the different work points. Then that function is a general one and I want, from that general function to activate the right output.


    Code
    TEST nID
      CASE 1: SetDO do1 , 1;
      CASE 2: SetDO do2 , 1;
      CASE 3: SetDO do3 , 1;
      ...


    BitOr would be wonderful with a GO signal linked to the same address than the normal digital outputs are, but it does not work with more than 8 bits.

    And, if I need to do a special process 4 times, I prefer to do a simple assignment 32 times and keep it easier to understand, with a comment explaining there is an Excel file that makes the job.


    As always, thank you very much for your time Lemster!

  • Hi again,


    It's a procedure call.

    It's called after some movements.

    Its a general procedure which receives some parameters, but the important one now it's a num variable which is the point identifier (a simple numeric ID).

    With that identifier, let's say 3, I must activate a digital output do3.

    Those outputs are defined correlative:

    do1, do2, do3, do4 .. do32.

    If the ID is 31 I need to activate the do31 if some conditions are met during the execution of the procedure. If the ID is 4 I will have to activate the do4 if those conditions are met.

    I don't know of any good method to go from ID 5 to setDO do5, 1;


    Again, thanks for your time.

  • A parameter for a procedure call can be of type signaldo. See an example here:

  • Yes, that would do it... wanted to avoid it because I have to check one input (di3) and activate an output (do3) but that would work without jumping to other functions to convert from an ID to a signal.


    Will take a look at it and check if it would suit all my cases.


    Thanks! :thumbs_up:

Advertising from our partners