I have a programable gateway with RFID, and RS232 modul. I would like to send the RFID data to PLC on RS232. In the FB of the RFID In/Output has a 'ARRAY [1..1024] OF BYTE' variables and the RS232 input has 'POINTER TO ARRAY [0..7] OF BYTE'. Can I send the data between this 2 module with any byte converter?
Does anyone have any experience?
Greetings,
Dokee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I do not quite get what you are looking for, do you want to convert an ARRAY [1..1024] OF BYTE to a POINTER TO ARRAY [0..7] OF BYTE ?
in that case it is not just a conversion, a pointer is not a type its a link to another variable so it only holds the memory address of the variable that it links to.
(isnt it possible to change the array 0..7 to 0..1023 or 1..1024?)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
this is only one way!!!!, you have to rewrite a part to do it the other way as well
you can use a conversion function block like this:
(warning test this extensively, it worked when i tested it)
FUNCTION_BLOCKConvert(*ConvertionFB*)VAR_INPUT
  abyInput:ARRAY [1..1024] OFBYTE; (*a = array by = byte for easyer reading code*)
  byCounter:BYTE; (*possible values 0..127  0 represents the first 8 bytes of the 1024 array and 127 represents the last 8 bytes of the 1024 array*)END_VARVAR_OUTPUT
  abyOutput: ARRAY [0..7] OFBYTE;END_VARVAR
  i:INT;END_VAR(*enddeclaration*)FORi:=0TO7DO(*0..7toread8bytesoutofthe1024array. Therearealsodirtytickstogetridofthefor-loop, butthissolutionistheeasyesttoread*)
  abyOutput[i]:=abyInput[(byCounter*8)+i+1];          (* byCounter*8 calculate the offset with the given 8 bytes to read +i is to cycle though the 8 bytes in the array +1 is to compensate for the startposition of 1*)END_FORPROGRAMPLC_PRG(*MAINPROGRAM(JUSTFORATEST)*)VAR
  conv:Convert;
  byaTest: ARRAY[1..1024] OFBYTE;
  pbyaTest: POINTERTOARRAY[0..7] OFBYTE;
  i:INT;
  j:BYTE;
  iState:INT:=0;
  str:STRING(1024);END_VAR(*enddeclaration*)CASEiStateOF
  0: (*somedataitothetestarray*)
     FORi:=1TO1024DO
      byaTest[i]:=INT_TO_BYTE(i); (*values will get strange after 255*)
    END_FOR
    iState:=1;
  1: (*readdata(ireaditbackintoan1024array*)
    FORj:=0TO127DO(*1024bytes/8bytes=128setsof8bytes(0..127=1..128)*)
      conv(abyInput:=byaTest,byCounter:=j);
      pbyaTest(*thisisthepointeroftheFB*):=ADR(conv.abyOutput); (*set the pointer to the address of the output*)
    END_FOR
    iState:=2;
  2:
    ;END_CASE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tested the program, and it worked alone. After I imported to my project, and make a program onject from the FB (when you sent).
This prg name is CONVERT2. I set up the convert2 input to [CH_0_TXREF] adress (than I want to be send), and output to [RStxData] memory adress.
This adress type is ARRAY [0..7] OF BYTE, like the abyOutput type. But the FB (BLxx1RSxxx_FB) input seems to be like a POINTER OF ARRAY... type adress.
I send it to my screenshot about the program, I'll hope you look averything, that you need. If you have any time to look this, than I 'll thank you so much.
Best regards,
Dokee[/img]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
edit: I didn't see the image the first time I looked, the poblem is you try to convert a 0..7 array to a 0..7 pointer array.
the solution is to send the address of the 0..7 array to the FB.
in structured text it lookes like this: ptTXdata:=ADR(RStxData);
Is it possible to get the program including the function blocks you use (or the library), so i can take a crack at it
I still don't know in what direction you want to send the data, from 1..1024 array to 0..7 array, the other way around or both ways. The function block i send you is only for 1..1024 array to 0..7 array
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank You, durring I fix the variables, because I gave a wrong value of the output variable, and now fine. Just I don't near at net, and don't answer for u.
Thank you again,
Dokee
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oh, yes, the image. I see in my pc, but don't found in other pc. Sorry, that was a screenshot from the plc_prgogram trunk, visibles the in/out variables. Never mind!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a programable gateway with RFID, and RS232 modul. I would like to send the RFID data to PLC on RS232. In the FB of the RFID In/Output has a 'ARRAY [1..1024] OF BYTE' variables and the RS232 input has 'POINTER TO ARRAY [0..7] OF BYTE'. Can I send the data between this 2 module with any byte converter?
Does anyone have any experience?
Greetings,
Dokee
Hello,
I do not quite get what you are looking for, do you want to convert an ARRAY [1..1024] OF BYTE to a POINTER TO ARRAY [0..7] OF BYTE ?
in that case it is not just a conversion, a pointer is not a type its a link to another variable so it only holds the memory address of the variable that it links to.
(isnt it possible to change the array 0..7 to 0..1023 or 1..1024?)
I see, thx.
That case, have I chance to fix this problem?
Because the FB, like BLxx_1RSxxx_FB, TX and RX type 're "POINTER ARRAY [0..7] OF BYTE" types. Can I modify any types or that FB inputs 're fix?
Sorry for my questions, it possible not correct, but I'm a new in this theme.
this is only one way!!!!, you have to rewrite a part to do it the other way as well
you can use a conversion function block like this:
(warning test this extensively, it worked when i tested it)
I'll test it, and very thanks for your help, and time.
Regards,
Dokee
I tested the program, and it worked alone. After I imported to my project, and make a program onject from the FB (when you sent).
This prg name is CONVERT2. I set up the convert2 input to [CH_0_TXREF] adress (than I want to be send), and output to [RStxData] memory adress.
This adress type is ARRAY [0..7] OF BYTE, like the abyOutput type. But the FB (BLxx1RSxxx_FB) input seems to be like a POINTER OF ARRAY... type adress.
I send it to my screenshot about the program, I'll hope you look averything, that you need. If you have any time to look this, than I 'll thank you so much.
Best regards,
Dokee[/img]
Hello,
edit: I didn't see the image the first time I looked, the poblem is you try to convert a 0..7 array to a 0..7 pointer array.
the solution is to send the address of the 0..7 array to the FB.
in structured text it lookes like this: ptTXdata:=ADR(RStxData);
Is it possible to get the program including the function blocks you use (or the library), so i can take a crack at it
I still don't know in what direction you want to send the data, from 1..1024 array to 0..7 array, the other way around or both ways. The function block i send you is only for 1..1024 array to 0..7 array
Thank You, durring I fix the variables, because I gave a wrong value of the output variable, and now fine. Just I don't near at net, and don't answer for u.
Thank you again,
Dokee
Oh, yes, the image. I see in my pc, but don't found in other pc. Sorry, that was a screenshot from the plc_prgogram trunk, visibles the in/out variables. Never mind!