Skip to main content

Application Note: GetData()/SetData() and Error C45 in EasyBuilder Pro (EBPro)

You can read this post on LinkedIn as well.

Introduction:

I started my PLC and HMI programming journey with Allen-Bradley products in 2020. Due to a career change, I landed in the Greater Boston Area in 2021 and launched an excursion to learn the Maple Systems HMI (and how powerful a Macro function can be).

However, learning Macro isn't all that bright and shiny. I ran into a problem when using PLC tags (still an Allen-Bradley CompactLogix controller). When I compiled the Macro, it gave me a C45 error message saying "The tag can't be found." What? I SUCCESSFULLY imported every single tag already! That burning feeling brings me back to the objected-oriented programming class in 2013.

I struggled and couldn't make any progress. Later, my colleague told me why that happened when he checked in with me. So here we go to learn what was the root cause!

Section 1: Understanding the Controller and Program Tags

For a 5000 series controller from Allen-Bradley, you use Logix Designer to do your tag-based programming. In the Controller Organizer panel, you have a MainTask in default and can add Event Tasks and Periodic Tasks based on your need. And under each Task, you can create Programs.

Section 2: The Trap: Global Tags vs. Local Tags

Here comes the trap! A controller has its own Controller Tags and a program has its own Program Tags. Controller Tags are Global Tags while Program Tags are Local Tags. When you use GetData() and SetData() in Macro, you don't have to place any prefix on an importer Controller Tags. However, you have to add a prefix when you are targeting Program Tags. Below is a Macro example to illustrate my point.

macro_command main()
 
  // measure protein on average in different food sources per 100 gram
  int animal = 0, vegan = 10, chicken = 0, whey = 25
  
  // PLC_Animal and PLC_Vegan are Controller Tags
  GetData(animal, "CompactLogix", "PLC_Animal", 1)
  SetData(vegan, "CompactLogix", "PLC_Animal", 1)
  
  // PLC_Chicken and PLC_Whey are Program Tags in MainTask/MainProgram
  GetData(chicken, "CompactLogix", "Program:MainProgram.PLC_Chicken", 1)
  SetData(whey, "CompactLogix", "Program:MainProgram.PLC_Whey", 1)
  
end macro_command   

Section 3: Using GetData() and SetData() in Macro

Here I use two tags in MainProgram for illustration purposes. If you create other program names like Beef_Jerky_Packaging, be sure to change "MainProgram" in your Macro to Beef_Jerky_Packaging to accommodate your setting.

Conclusion:

Use your PLC controller to create and manage Tags. Don't do it on your Maple Systems HMI because it's not user-friendly.

Complaints:

In the end, I have some complaints about Maple Systems after playing with it for two days. First, Macro doesn't support String data type. You have to create a Character array instead. Second, when it comes to Macro, Macro Reference Manual for EZWarePlus is the first Google search result. But the EasyBuilder Pro manual should be the first go-to. If they solve these two issues, that would be great.

Comments

Popular posts from this blog

[申辦綠卡] EB-2 NIW 國家利益豁免綠卡申請教學(一)找合作的律師事務所

Image by  David Peterson  from  Pixabay

[申辦綠卡] EB-2 NIW 國家利益豁免綠卡申請教學(零)名詞解釋 Petitioner vs Applicant

Image by  David Peterson  from  Pixabay

[申辦綠卡] EB-2 NIW 國家利益豁免綠卡申請教學(七)組裝 NIW I-140 申請文件包

Image by  David Peterson  from  Pixabay