PLUS+1 Hardware > Controllers

Read multiple Can messages same ID

(1/3) > >>

F.M.Elettromeccanica:
Dear all,
I have to read a Can message on attached CAN trace. I’m using MC024_130, the problem is that I can receive 8 bytes every loop , my TimeLoop is 5mS, but I tested 1..10..15.
I have to rebuilt a 80 U8 byte Array, but every way I try I can only read first 8 and I’m not able to copy into an array all data I received.
Is there a way to do it in Guide? Looking at timestamp you can see that this messages are sent every 1Sec a 10 packet. D0 is SID, so, for example, D0=109 means that I have to copy all 10 messages that contains D0=109 in a 80 byte array.
I tried many way, using Copy of array, but with no success. Could I try using POU? Have you got an example code ?
Many thanks

FluidPowerTom:
I'd definitely use a ST POU for that.  The output from the CAN Rx is an array which you could use as an input variable to your POU.  It'd probably take me 20-30 min to type out some code that'd do this though.  Array operations, while nowhere near as powerful as with MATLAB, are still pretty sufficient in ST.

F.M.Elettromeccanica:
Thanks for your reply FluidPowerTom.
So youbmean to connect to a POU inputbus, the Array [8] U8 fron CanRx block? I'm just trying to do this,but seems that only first or last packet sent from my the device is cought in MC controller. Basically yes,i have to built an Array larger than 8. If uou will back with an example i'll can see where i'm doing it wrong
Thanks in advance

F.M.Elettromeccanica:
What i'm doing is this in pictures. Trying Protected T or F, trying to play with ExcecTimeOut with no success. Seems that every messages are absorbed from controller and only first or last are visibles. If it's so i think is a very bad limit for plu+1 controllers.

this is what's in the POU (a very easy test) :

FUNCTION_BLOCK GGA_Decoder
VAR_INPUT
  Data : ARRAY[0..7] OF USINT;
  Length : USINT;
END_VAR
VAR_OUTPUT
  Arr0 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
  Arr1 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
  Arr2 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
  Arr3 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
  Arr4 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
  Arr5 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
  Arr6 : ARRAY[0..7] OF USINT := [0, 0, 0, 0, 0, 0, 0, 0];
END_VAR
VAR
  Index : USINT;
END_VAR

// Extract Identifier
Index := Data[0];

CASE Index OF
  160, 192, 32, 0, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240:
    Arr0 := Data;
  161, 193, 33, 1, 65, 81, 97, 113, 129, 145, 161, 177, 193, 209, 225, 241:
    Arr1 := Data;
  162, 194, 34, 2, 66, 82, 98, 114, 130, 146, 162, 178, 194, 210, 226, 242:
    Arr2 := Data;
  163, 195, 35, 3, 67, 83, 99, 115, 131, 147, 163, 179, 195, 211, 227, 243:
    Arr3 := Data;
  164, 196, 36, 4, 68, 84, 100, 116, 132, 148, 164, 180, 196, 212, 228, 244:
    Arr4 := Data;
  165, 197, 37, 5, 69, 85, 101, 117, 133, 149, 165, 181, 197, 213, 229, 245:
    Arr5 := Data;
  166, 198, 38, 6, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214, 230, 246:
    Arr6 := Data;
 
END_CASE

in the recent past I struggled badly with Danfoss displays trying to acceptably capture an NMEA string on RS232,but ExcTimeout always effect the result, now we can't get the positioning data correctly read even on Can.
Once again I'm afraid we should change Hardware. But in 2023, almost 2024, with many blocks for Autonomous Guide developed, at least something to manage the data of a standard GNSS would have expected. It's a real shame, because the displays and controllers are
very good.

F.M.Elettromeccanica:
And this is the Trace

Navigation

[0] Message Index

[#] Next page

Go to full version