dannp

Populating a Structure Data Type from an Array of WORD

6 posts in this topic

Hi All,

I am Data Transferring Arrays of WORD's from a HMI to NX PLC.

DATATRANSFER.PNG.b063279b0026fe34cf95a94

This Transfer may be a variety of data types, Likely just UINT and STRING[20]. It will be Imported to NX as an Array of Word

GlobalVariables.thumb.PNG.56c18477ab33ed

What im trying to do is Populate my Structure from this Array of Word. I can do this by mapping them individually just fine. But i was hoping i could add them automatically. Much like when you assign EthernetIP tags and can link them to a structure and User Offset the Bytes. But i cant seem to Link the Array of Word to the Structure e.g. SENSORS_STORED:=DATA_2_IN; Says its impossible

Structure.thumb.PNG.0f7168fa8f34b37c0d4a

Anyone have any ideas how i could Populate this structure from a WORD Array without manually mapping and Converting Each?

SENSORS_STORED.Fixture_ID:=WORD_TO_UINT(DATA_2_IN[0]); For Example is a workable way but is long winded and was hoping there is a easier way

Thanks in Advance

Dann

 

Share this post


Link to post
Share on other sites

Does it need to map to an array of words or just a datatype that is equivalent in size to the array of words? Some devices only need the data size to match. Maybe you can create you your custom datatype structure that ends up 140 bytes. Alternatively create a union data type. 

Share this post


Link to post
Share on other sites

Enable the CJ-Series memory locations first. If the PLC is an NJ they are enabled by default, for NX controllers you'll find it in the multiview explorer. In the AT column assign an identical address to both variables and they will mirror one another.

Capture.PNG

1 person likes this

Share this post


Link to post
Share on other sites
3 hours ago, photovoltaic said:

Enable the CJ-Series memory locations first. If the PLC is an NJ they are enabled by default, for NX controllers you'll find it in the multiview explorer. In the AT column assign an identical address to both variables and they will mirror one another.

Capture.PNG

I too like this method, however as you can use AT % in program scoped data variables too, i find it can lead to problems very quickly. There is no way to cross reference, or a memory map to show what addresses have been allocated etc.

I use this method for making a program scoped tag available between programs without using a global variable.

1 person likes this

Share this post


Link to post
Share on other sites
4 hours ago, photovoltaic said:

Enable the CJ-Series memory locations first. If the PLC is an NJ they are enabled by default, for NX controllers you'll find it in the multiview explorer. In the AT column assign an identical address to both variables and they will mirror one another.

Capture.PNG

That's perfect thanks, such a simple solution

Although I've now found I don't have to do this, as I was Querying a SQL database via the HMI and writing to HMI memory then bulk sending that data down as array of words.

I found I can just do same query again but send direct to the PLC structure Variable members via tags. 

But definitely worth knowing this, thanks again

Share this post


Link to post
Share on other sites
2 hours ago, chelton said:

I too like this method, however as you can use AT % in program scoped data variables too, i find it can lead to problems very quickly. There is no way to cross reference, or a memory map to show what addresses have been allocated etc.

I use this method for making a program scoped tag available between programs without using a global variable.

You definitely need to exercise caution with this method. Personally I segregate the memory and only use certain banks for certain purposes. %W is for conversions, %D for everything else.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now