How to best assign Beckhoff EL6851 DMX channels

Viewed 29

on Beckhoff's EL6851, to assign DMX channels to the variables I can either do this :

Option1

bEL6851_DmxChannels             AT %Q* : ARRAY[1..512] OF USINT;

or this Option2 :

bEL6851_DmxChannelsChunk1               AT %Q* : ARRAY[1..64] OF USINT;
bEL6851_DmxChannelsChunk2               AT %Q* : ARRAY[65..128] OF USINT;
bEL6851_DmxChannelsChunk3               AT %Q* : ARRAY[129..192] OF USINT;
bEL6851_DmxChannelsChunk4               AT %Q* : ARRAY[193..256] OF USINT;
bEL6851_DmxChannelsChunk5               AT %Q* : ARRAY[257..320] OF USINT;
bEL6851_DmxChannelsChunk6               AT %Q* : ARRAY[321..384] OF USINT;
bEL6851_DmxChannelsChunk7               AT %Q* : ARRAY[385..448] OF USINT;
bEL6851_DmxChannelsChunk8               AT %Q* : ARRAY[449..512] OF USINT;

Option1 means I need to double click 512 times to assing every variable - not an option. Option2 meansI get 8 arrays instead of 1. How can I now make this into a single array that works as standard 512 elements array in Option1.

I tried this but simple copy doesn't work. I guess some references or pointers ?

FOR counter := 1 TO 64 BY 1 DO
    bEL6851_DmxChannels[counter] := bEL6851_DmxChannelsChunk1[counter];
END_FOR
...
bEL6851_DmxChannels[counter] := 255; // this won't work.

2 Answers

Turns out that all you have to do to make it work with 512 elements array is tick the "All Types" after you right click each 64 channels chunk. Hope that saves someone few headaches !

enter image description here

I am not sure it will work in your case (i mean if you can assign it to module vars) but one of the ways is to create multiple level array.

VAR
    DmxChannels  : ARRAY[1..512] OF USINT;
    DmxChannelsM AT %Q* : ARRAY[1..8,1..64] OF USINT;
    i,j:INT;
END_VAR

FOR i := 1 TO 8 DO
    FOR j := 1 TO 64 DO
        DmxChannels[((i - 1) * 64) + j] := 
           DmxChannelsM[i,j];
    END_FOR
END_FOR

Related