Skip to main content
Skip table of contents

Macros

The so-called macros are sets of instructions completely defined before their execution that are stored in NVM. The instruction set available for macros is composed by basic operations as arithmethical and logical operations, flow control operations, and object access. Macros can be thought as assembly routines, and as such they can be called by other functions. EMCL can store up to 64 macros of up to 128 instructions each. Macro execution is launched through the macro call instruction of the Macro command - 0x2C04 register, and whenever a macro is called from another macro, the current macro being executed and that macro status registers (the ACCUM register, see below) are stored into the so-called macro stack, allowing nested macro execution.

The macro with macro number '0' is always executed after power-up. This macro can be thought as the boot sector of the NVM: if it is empty, the controller waits for external instructions after power up. If it is not empty, the macro programmed in the 0 slot is executed. Notice that with the macro call instruction, it is possible to divert the execution code to the desired macro right after power up, wasting only one instruction cycle.

 Once a macro is called, its instructions are called sequentially. Each instrucction contains:

  • Index and SubIndex of the object of the dictionary to be read or written.
  • Length of the object data.
  • Read or write flag.
  • If applicable, data to be stored in the write operation.

For further information about the instruction structure, refer to the register Macro access - 0x2C05

Hence, macro instructions are able to read or write the value of dictionary objects (regular R/W restrictions are applicable). In addition, certain objects have been added to the dictionary to provide the macro system with additional programming capabilities:

  • General purpose registers - 0x2C00: The set of general purpose registers act like program memory in general programming languages, where the desired values can be stored during macro execution processing. The first two registers, ACCUM and W2, work akin to data registers in microprocessors, containing the results of immediate operations. Registers from W3 to W95 work like a heap, and, unlike ACCUM and W2, data stored in those registers is guaranteed to not be overwritten implicitly. At last, registers from W96 to W100 work exactly like registers from W3 to W95, but, in addition, they are non-volatile, hence maintaining its value even after a power down.
  • Register commands - 0x2C01: This object contains the arithmethic and logic instruction set that can be applied to the registers of the object dictionary.
  • Sequence commands - 0x2C02: This object contains the execution flow control instruction set at the intra-macro level.
  • Macro commands - 0x2C04: This object contains the execution flow instruction set at the inter-macro level.

The combination of these objects allows to create complex functionalities for the Ingenia motion controllers to work without a master.

 All macros should be terminated in a Return from macro call instruction.

By default, Ingenia drives reserve the 4 last macro slots (63, 62, 61 & 60) to store a set of special instructions called BIOS. These macros contains the management of the state machine and some mode of operation, so it is easier to develop complex sequences based on this special instructions.


To aid in the development of stand-alone applications, the special register Macro debug - 0x2C0A is available. As the name implies, it is an object that contains useful information for macro debug purposes.

Related objects

0x2C00 - General purpose registers

0x2C01 - Register commands

0x2C02 - Sequence commands

0x2C04 - Macro commands

0x2C05 - Macro access

0x2C0A - Macro debug

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.