brandon1967

Help with structures

10 posts in this topic

Hi I am very new to programming (3 weeks using sysmac and less than 1 year plc programming) so I apologise if I am a bit slow on the uptake.

I am trying to group variables by program sections as I didn't want to scroll through the entire global variables to find one I am looking for, so I created a few structures to house these variables. However I cant see any way to map the structure members to a HMI variable so I can display it on screen. Is there a way to do this. I apologise if this is a stupid question but like I said I am very new to this. Thanks.

Share this post


Link to post
Share on other sites

No, there is not a way to do this.  To map a variable to the NA, the variable needs to be global (or a system variable).  

Share this post


Link to post
Share on other sites

Thanks for the reply, I figured as much was just wondering if there was something obvious I had overlooked.

Share this post


Link to post
Share on other sites
8 hours ago, brandon1967 said:

Hi I am very new to programming (3 weeks using sysmac and less than 1 year plc programming) so I apologise if I am a bit slow on the uptake.

I am trying to group variables by program sections as I didn't want to scroll through the entire global variables to find one I am looking for,...

I always add prefix in the beginning of my tags.

Inputs: i_MyTag

Outputs: o_MyTag

From HMI: h_MyTag

Timer: t_MyTag

etc...

This way, I know in advance where to find them in the table, when sorted by name. And when adding a variable or contact in the program, I know what to type first.

Edited by pfort
1 person likes this

Share this post


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

I always add prefix in the beginning of my tags.

Inputs: i_MyTag

Outputs: o_MyTag

From HMI: h_MyTag

Timer: t_MyTag

etc...

This way, I know in advance where to find them in the table, when sorted by name. And when adding a variable or contact in the program, I know what to type first.

Yeah I try to do that where I can however it starts to get a bit cluttered as I have lots of water related tags so I end up with lots of variables like "Water_temp_x" "Water_press_x". So far I do prefer the tag based names as it means more to me than a data area but I would be lying if I said I dont miss the ease/neatness of cx-programmer in this aspect.

Share this post


Link to post
Share on other sites

@brandon1967

I take your question is whether a custom Structure variable can be accessed via the HMI, isn't it?
That's actually possible.

Say you create a Structure Data Type like so :

st_Water
   Pressure         Type: REAL
   Temperature  Type: REAL


You then assign a Global Variable in the PLC program like so : plcWater     Type: st_Water
Then, in your NA project, you can map it the Variable Mapping section like so : User Variables: plcWater      Type: st_Water    Variable: hmiWater

Now, say you want to display the Pressure, put a DataEdit control, then under the Variable property, just type in hmiWater.Pressure
Similarly for Temperature, in the Variable property just type hmiWater.Temperature

The auto-complete feature will actually shows you those structure members after you key in the dot.
While clustering by PLC Program (as in Local Variables) is not possible, this method already helps a lot, rather than mapping each members one by one.

1 person likes this

Share this post


Link to post
Share on other sites
7 hours ago, innoaloe said:

@brandon1967

I take your question is whether a custom Structure variable can be accessed via the HMI, isn't it?
That's actually possible.

Say you create a Structure Data Type like so :

st_Water
   Pressure         Type: REAL
   Temperature  Type: REAL


You then assign a Global Variable in the PLC program like so : plcWater     Type: st_Water
Then, in your NA project, you can map it the Variable Mapping section like so : User Variables: plcWater      Type: st_Water    Variable: hmiWater

Now, say you want to display the Pressure, put a DataEdit control, then under the Variable property, just type in hmiWater.Pressure
Similarly for Temperature, in the Variable property just type hmiWater.Temperature

The auto-complete feature will actually shows you those structure members after you key in the dot.
While clustering by PLC Program (as in Local Variables) is not possible, this method already helps a lot, rather than mapping each members one by one.

Thanks for that it helps a lot. I was unsure how to map the structure and how it related to the HMI so this is definitely a big help and will make sure I can keep things organised.

Share this post


Link to post
Share on other sites

Oh, I misunderstood.  I thought the question was, "Is there a way to map local variables to the HMI?"  My apologies.  Yes, as long as the variable that uses the structure data type is global, it can indeed be mapped to the HMI.  My apologies.

Share this post


Link to post
Share on other sites

Hi,

i try to do almost the same but my structure are an array of struct and it doesnt seams to work. My variable name are OutCarr.Unit[1].bEngageCarr; (in the PLC) .

I Created my variable in the HMI.

2020_01_21_14_11_07_C_1221_Carrousel_V01

and thats are my struct in my plc AAAAA.png.60ba9cf177d8e428607aa46383167a

My problem is that in my HMI i want to use PLC_DebugCarr.Unit[1].MOT1Start but when i try to specify a unit it put an error. Can you help me ? Sorry for bad english :( not my first language.

 

 

 

Edited by Jamesthai514
Wrong picture

Share this post


Link to post
Share on other sites
17 hours ago, Jamesthai514 said:

PLC_DebugCarr.Unit[1].MOT1Start

The PLC requires [x]. The NA requires (x) as per DotNet rules.

In the future, please start a New Topic in the forums.

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