Overview

Overview

The Modulo block calculates the remaining whole number of the division of the input by the divisor. The Modulo calculation (update rate) is determined by the Evaluate Block.

Example

The following example demonstrates how to implement a cyclic error compensation based on actual position. For example, an un-balanced pulley is spinning horizontally on a motor shaft. Gravity causes the imbalance to require more force to rotate the heavy side up and require less force as the heavy side makes its way down.

By using the Raw encoder feedback and setting the Modulo equal to the encoder resolution, the output of the Modulo will always be between Zero and the encoder resolution. A lookup table based on absolute motor angle can now be created and output an extra torque command based on what angle the motor is currently at.

The following parameters are used to configure this block:

 
Divisor

Divisor.

Output = Input % Divisor

Evaluate Block This block allows you to specify whether the block executes Every Sample, Every Other Sample (Odd or Even), or Every Fourth Sample (and specify the First, Second, Third, or Fourth). This provides greater flexibility in controlling the execution of a model and to preserve performance for other areas of motion control.
User Defined Block Priority When selected, allows you to enter a Priority Code to modify Execution Ordering of this block. For more information, see Block Execution Order and User Defined Block Priority.
Priority For an explanation of how the Priority field is used by the MechaWare Model Downloader, see Block Execution Order and User Defined Block Priority.
User Data 0 Application-specific data. See User Data Storage.
User Data 1 Application-specific data. See User Data Storage.

Matlab/Simulink

Simulink Interface

modulo_sim1

The Output of a Modulo block is the whole number remainder of the Input divided by the divisor.

The block has two user data fields (User Data 0, User Data 1) to store application-specific data for convenient storage and retrieval. See User Data Storage for details.

The block's update schedule is determined by the Evaluate Block. The following Parameter Dialog Box can be opened by double-clicking on the block in a Simulink Model:  

modulo_sim2

 

C++ API

MODULOBlock

Declaration

Public Method

 
class MODULOBlock: public virtual Block
{
public:
	// User accessible coefficients
	long	Divisor;
};
  Required Header: mechaware.h

Description

The Modulo block calculates the whole number remainder of division of the input by the divisor. 

 
long Divisor

Divisor. Output = Input % Divisor

Methods

Block Methods