VARiValue: INT :=511; //Value to be split or you could do wValue AT %IW1: WORD;pValue: POINTERTOBYTE; //Address of iValuebyValue1: BYTE; //LSB for iValuebyValue2: BYTE; //MSB for iValueEND_VAR//SetpointerpValue :=ADR(iValue);//GetLSBbyteinintvaluebyValue1 :=pValue^; //Value would be 255//IncrementtonextbyteinintvaluepValue :=pValue+1;//GetMSBbyteinintvaluebyValue2 :=pValue^; //Value would be 1
There are a lot of ways to approach this so it would help if you showed an example using sudo code to help show what you are trying to accomplish. You could also use a UNION to split values up into smaller data types.
Last edit: Lo5tNet 2020-06-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This should be enough to get you started and you can build off of this.
******************************************************FUNCTIONMyFunction : WORDVAR_INPUTpValue : POINTERTOWORD; //Pointer to start address. In your case it would be %IW0wIndex : WORD; //Index above start address to go to. 0 = %IW0, 1 = %IW1, 2 = %IW2.....END_VARpValue :=pValue+(wIndex*SIZEOF(WORD)); //Set pointer to desired indexMyFunction :=pValue^; //Get value from pointer and return******************************************************//Thencallitlike:
PROGRAMPLC_PRGVARwIndex : WORD; //Index value to get. 0 = %IW0, 1 = %IW1, 2 = %IW2.....wReturnValue : WORD; //result from function call for testEND_VARwReturnValue :=MyFunction(pValue:=ADR(%IW0), wIndex:=wIndex);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
wIndex doesn't work. For pValue := %IW8 : when wIndex = 0 I have the good result of %IW8 but if I put wIndex:=1; I haven't got value of %IW9. Result is 0.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It enables you to graphically map IO to an FB 'on the fly' or do it programmatically.
Plus this example is open-source, so if you want to know how it works or modify it for your own needs you can do that.
Good luck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That is the standard/normal/vanilla symbolic way of coupling IO...
In general there are 2 vanilla flavours (there are way more options but those aren't exactly vanilla anymore);
1 Declare variables in your IO point and reference that variable in your POU (program, FB, Func, whatever)
2 Declare variables in your POU and couple them to an IO point.
PS: I never use hardcoded IO adresses in my code (%I, %Q, %M etc) .
Last edit: aliazzz 2020-06-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to create my own ethernet ip device ? I have x same device, I/O are mapped on table, just number of ligne change. Could I create my special device with special parameter which defines number of line in the table, I could win a lot of time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is any solution to cal physical , example: %IW1
like this:
Thanks for your answers.
Bests regards.
Is it possible to make POINTER move X byte from %IW1 to a numbrer of byte ?
This code work for several %IB (example %IB0 to %IB10) to position0 in 1 instruction if I set index to 10 ?
I want to put all data receive by ethernet IP in data by code, I don't want to use graphic interface.
Are you asking to do something like:
There are a lot of ways to approach this so it would help if you showed an example using sudo code to help show what you are trying to accomplish. You could also use a UNION to split values up into smaller data types.
Last edit: Lo5tNet 2020-06-11
I want to define on input of FB the address %IW1. Is it possible ? And after, by code incremente adress to %IW2, %IW3, etc...
The idea is create a function block with input the first address of %IW and the first address of %QW:
FB for Slave ethernet ip 1:
First_Input := %IW1;
First_Input[1]:= DATA[1].word_1;
First_Input[2]:= DATA[1].word_2;
First_Input[3]:= DATA[1].word_3;
....
FB for Slave ethernet ip 2:
First_Input := %IW10;
First_Input[1]:= DATA[2].word_1;
First_Input[2]:= DATA[2].word_2;
First_Input[3]:= DATA[2].word_3;
....
FB for Slave ethernet ip 10:
First_Input := %IW100;
First_Input[1]:= DATA[2].word_1;
First_Input[2]:= DATA[2].word_2;
First_Input[3]:= DATA[2].word_3;
Related
Talk.ru: 1
Talk.ru: 2
Talk.ru: 3
This should be enough to get you started and you can build off of this.
wIndex doesn't work. For pValue := %IW8 : when wIndex = 0 I have the good result of %IW8 but if I put wIndex:=1; I haven't got value of %IW9. Result is 0.
Maybe you should check out this store example: https://store.codesys.com/io-mapping-tool.html
It enables you to graphically map IO to an FB 'on the fly' or do it programmatically.
Plus this example is open-source, so if you want to know how it works or modify it for your own needs you can do that.
Good luck
I think it's not I want to do....
What do you think about this: https://help.codesys.com/api-content/2/codesys/3.5.13.0/en/_cds_configuring_devices_mapping_ios/#mapping-a-device-input-to-a-function-block-instance
That is the standard/normal/vanilla symbolic way of coupling IO...
In general there are 2 vanilla flavours (there are way more options but those aren't exactly vanilla anymore);
1 Declare variables in your IO point and reference that variable in your POU (program, FB, Func, whatever)
2 Declare variables in your POU and couple them to an IO point.
PS: I never use hardcoded IO adresses in my code (%I, %Q, %M etc) .
Last edit: aliazzz 2020-06-17
Is it possible to create my own ethernet ip device ? I have x same device, I/O are mapped on table, just number of ligne change. Could I create my special device with special parameter which defines number of line in the table, I could win a lot of time.