Merging DI to GI

Hello,

I am trying to make a record with 8 signaldis, which I want to split from an signalgi. In PLC code, I often make a word with handshakes and I assign values to the individual bits (e.g. handshake.%X0 := TRUE;).

Is it possible to do anything like this in the robot? I was thinking maybe you could use AliasIO (e.g. AliasIO BitInByte(Handshake,1), Handshake.X0;) but with no luck...

Comments

  • lemster68
    lemster68 United States ✭✭✭
    Are you wanting the record to be like 0,1,0,0,1,0,0,1?  or to hold the actual value of the group?
    Lee Justice
  • Paba
    Paba Germany
    edited October 2019
    Did you took a look at "BitSet"/"BitClear" Instruction?

  • VictorAx
    VictorAx Sweden
    lemster68 said:
    Are you wanting the record to be like 0,1,0,0,1,0,0,1?  or to hold the actual value of the group?
    Yes I want to split the signal without having 8 individual bits in the IO configuration.
    So for example the input Handskake should be an GI which holds the value 20, and then I want my record to hold the values [0,0,0,1,0,1,0,0].
  • VictorAx
    VictorAx Sweden
    edited October 2019
    Paba said:
    Did you took a look at "BitSet"/"BitClear" Instruction?
    Yes, but I'd like to be able to use Set/Reset "Handshake.X0" instead to make it more "readable"...
  • Slokko
    Slokko Jönköping, Sweden
    If you want to assign individual bitvalues with Set/Reset, then you will have to define them as individual DOutputs in the IO-config.

    Also with some clever named Constants, and a wrapper-routine, how much less readable is
    SetBit HANDSHAKE, X0;
    to
    Set Handshake.X0
    ?



  • Here's a low tech start for parsing the GI to get discrete 1's & 0's [ in a string  :s ]

    VAR num nDataConversion;
    VAR byte by_dataStorage;
    VAR stringdig stBytes;

    nDataConversion:=gi_BitExtract;
    by_dataStorage:=nDataConversion;
    stBytes:=ByteToStr(by_dataStorage\Bin);


  • EricH
    EricH Germany
    For readability, you can use a Routine
    For example:
    PROC Set_Handshake_X0()<br>  BitSet ...<br>ENDPROC
    PROC SetHandshakeX0()<br> BitSet ...<br>ENDPROC<br><br>OR<br><br>