- This topic has 3 replies, 3 voices, and was last updated 1 year, 11 months ago by Ken S.
- May 8, 2019 at 4:42 am #4113Arun Kumar DaraParticipantKarma: 28Rank: Padawan
Here is the present statement used in code:
INPUT_DATA_SYNC_OUT := AENTR1:2:I.Ch0Data;
How do I use an indirect address in “AENTR1:2:I.Ch0Data”.
I wanted to use an indirect address like this “AENTR1:[yVar]:I.Ch[xVar]Data”. Is this possible?
Arun Kumar DMay 8, 2019 at 8:50 am #4114David TiptonParticipantKarma: 26Rank: Padawan
What are you trying to accomplish with the indirect addressing? Looks like you want to turn on bit 24 of your output array when Aentr1:module 2: input 0 turns on, is this correct?
David TiptonMay 10, 2019 at 12:20 am #4128Arun Kumar DaraParticipantKarma: 28Rank: Padawan
Actually, In my application, I need to send all the Analog Input Values from one controller to another controller. Presently I have 40 Analog Input and I wrote 40 lines of code to copy the data into an array of DINT. So I thought of using indirect addressing and a FOR..LOOP to copy all Analog Input values into an array of DINT. After this by using a message instruction, I can transfer the DINT array to another controller.
I’m just curious to learn how to implement the indeirect method and For Loop.
Arun Kumar DMay 13, 2019 at 12:04 am #4144Ken SParticipantKarma: 35Rank: Padawan
The problem you have is really indirect access of the property which to my understanding you cannot do.
So basically you seem to want to iteratively assign an actual Tag to an Indexed Variable.
If I was writing code in .NET I would need to form the object name and then get a reference to the actual object.
You are building a name with a string , but your assignment needs a literal .. Reason being is you have the difference between a run time and a design time compile operation as your code executes on an indexed variable it is a run time (the index is not known until the code runs) , if it is literal it is design time and the way that compiles to the processor is different.
I am not aware of any way that this works in structured text or in ladder , I know you can pass an object by reference for example in a GSV command but it is limited to certain parameters of status and not the actual tag data such as what you are trying to acquire.
You could try to Alias but again this is not code , perhaps if you write an external application to create your tags for you and then you can import them .. Not sure if that is something viable for you – just a suggestion.
- You must be logged in to reply to this topic.