|
NB Macro FAQ's and Tips ObjectivesThis article addresses common questions when creating and using macros in the NB HMI.
IntroductionThe macro function of the NB HMI is a powerful tool that allows the user to create and execute simple and original programs. The macro function provides a programming method to expand the basic functions of the NB HMI as well as reduce the PLC data processing load. There are several common questions and tips included in this article that provide a better understanding of macro creation and processing.
This is not an exhaustive resource to all NB macro topics, but rather a collection of frequently asked questions and other related macro issues. Some content is subject to change upon newer software versions after 1.31.
ContentThis article contains the following topics.
Why do I see the message "Failed to set macro compiler path"?A message reading "Failed to set macro compiler path!" may appear when attempting to run NB-Designer. This occurs if the program has not been designated to run with administrator rights in Windows. It is recommended to run NB-Designer software in Administrator Mode. Right-click the NB-Designer.exe file in the folder specified during installation and either; select execute as administrator or set the Privilege Level to "Run this program as an administrator" in the compatibility tab of the file properties.
This message may also appear when using NB-Designer and/or saving projects over a network drive. If this occurs, try operating NB-Designer on the local machine.
Why am I experiencing problems with a ModBus macro?Creating a macro to communicate with ModBus slaves is possible* but there is a specific conditions that can cause communication problems. Calling addresses of slave units directly within the macro can cause slow communications and macro errors. If the NB cannot access a ModBus slave address, the macro will not be executed. Instead of directly referencing ModBus slave addresses within a macro, use the NB's internal addresses as variables for the macro. Then use the Data Transmission function or the Data Transmission option in the Timer for exchanging data. *NOTE: There are some limitations when using a macro to communicate to ModBus slaves. Contact your local Omron representative for more information.
Which macro is causing a macro error to appear?If there is a problem with the execution of a macro, a macro code error will be displayed.
The macro code error provides a reference to the macro number that caused the error (0002 above but this can be useless if the macro has been given a name that is missing the original macro number. It is recommended to leave the macro number in the name when renaming or creating a new macro. For example, a new macro file name is suggested by NB-Designer as "macro_2.c" as shown below.
It is acceptable to rename this, but leave the "_2" at the end of the name as a reference (i.e. "division_2.c"). This will aid in referencing which macro is causing the error.
What C libraries does the NB support?When a new macro is created, NB-Designer automatically embeds two default libraries into its code; "Macrotypedef.h" and "Math.h". "Macrotypedef.h" embeds functions and structured data such as memory access and graphic drawing and "Math.h" embeds fixed parameters and functions for mathematic calculation. These are the only two libraries that are supported by NB-Designer currently. There is some functionality when using standard C library files but this is not officially supported by Omron at this time. Contact your local Omron representative for more information.
Why is the WriteLocal macro function causing an error?The NB macro function WriteLocal causes the HMI to write values to a specified local address within the NB, such as the RW area. There is a known limitation to the amount of memory locations that can be written when using this macro function. If the number of addresses exceeds 4096, there can be a macro error as seen below.
The following macro function is problematic due to the value of 5000. WriteLocal("RW", 0, 5000, (void*)buf, 0); The following macro function will work when the nRegs parameter is less than 4096 as shown. WriteLocal("RW", 0, 4096, (void*)buf, 0);
Why do I get a "link macro file...failed" compilation error?The NB-Designer software uses a compiler to validate macro codes before transferring to the HMI and this compiler is installed with NB-Designer. If another GCC (GNU Compiler Collection) is present or added to the system, it may interfere with the normal compiler function of NB-Designer. In this situation, Windows may have an incorrect path setting for the required compiler. Examine the Environment Variables found in the Windows System Properties for interfering GCC libraries.
Why does my NB HMI freeze and become unresponsive? There is a macro implementation that may disrupt the responsiveness of the NB HMI. If a macro program uses the Real Time Clock (RTC) NB memory areas (10000-10006) as read/write variables, freezing or unresponsiveness may occur. This may also reduce the accuracy of the NB RTC.
For example, some applications require synchronization of the NB RTC with the host PLC. Rather than using a custom macro to achieve this, use the Data Transmission component instead. The "Use External Clock" option found in the PT property area may also be incorporated into this solution. Or, change the variable types to Read Only if a macro is required.
Other Tips
SummaryIn summary, the NB macro function is a powerful tool included in the NB-Designer software that provides an opportunity to add functionality to an NB application. This article provides tips and answers to frequently asked questions as a supplement to the NB-Designer Operation Manual for a better understanding of the macro function. *These details and references were made at the time of software version 1.31. Newer versions may operate and function differently. Contact your local Omron representative for more information.
Link: |
| Comments | ||
|
||



