Math FB dialog-box

See Add Math FB

See also : Web Link: Globe-www Tutorial 18: Maths FB

Math FB:

A Math FB allows you to add new math functions, add limits to motion-values, combine data that might be useful for your modelling.

Edit the Math FB


Edit the Math FB:

1.Double-click the Math FB in the graphic-area

- or -

Motion FB dialog-box


Add Connectors; Edit Output Data Type 

If you do not see the three buttons, then click the Orange Bar, possibly two times.

Add Input button - Click to add an input-connector to the Maths FB.

A new input-connector shows at its left.
Each input-connector can 'carry' three(3) data-channels.

Add Output button - Click to add more output-connectors to the Maths FB.

There is one output-connector on the Maths FB when you add it to the model.
Each output-connector can carry three sets of data. Thus, we see three equations in the 'Equations box' for each output-connector. See below how to write the equations.

Output Data-Type

Use the drop-down box to select the Data-Type.
The units at the output-connectors correspond to the Output Data-Type.
All output-connectors have the same Data-Type.


Bug: If you actually want the output to be Linear Coordinates [units], you MUST select a different Data-Type and then select Linear-Coordinates again to initialise the units correctly.

Update button

You MUST click this button to update any change you do to any setting, before you close the Maths FB.

More information to help you write the equations


Each wire in your model 'carries' three sets of data. Each set of data is a called a 'Data-Channel'.

The Data-Channels are labeled as 'p', 'v', and 'a', even if the data is not actually Position, Velocity, and Acceleration.

Each input-connector is given a number.

Input-connector numbers start at 0 , then 1, 2, 3, ...

Data on each Input-Connector and Wire

The data-type of each data-channel at an input-connector is a function of the FB from which you connect the wire.

If you connect a wire from a:

Golden FB: the data-channels are: Position, Velocity and Acceleration as its three data-channels (Angular or Linear, depending on the actual FB)
Force-Data FB: the data-channels are Torque, Fx , Fy.


For example: data-channel #2 on the wire that is connected to input-connector #3 from the top.

'v(2)' - where 'v' is the data-channel, and '(2)' is the input-connector #3.

And, you might enter, as an equation:


Which is: '[Second data-channel, of the third Input-connector] × [Third data-channel, fourth Input-connector]1.2

You can write nonsense, so be careful.

Units (see below for more information on Units)

The units in the Maths FB are always SI Units : meters, radians, kilogramme, seconds.

An input of 12mm in the model 'outside' the Maths FB, is 0.012m 'inside' the Maths FB. , and an angle of 90º, becomes pi∕2 radians when 'inside' the FB.

If you want mm in an equation inside the Maths FB, you must multiply the value by 1000 in the equation.

UNITS 'inside' the Maths FB

There are 4 possible sources of confusion with respect to 'units' when you use the Maths FB.

1.Motion FBs

Set the Data Type in a Motion FB to Linear or Rotary units IF you connect a wire from a Motion FB to a Maths FB. If you do not, then the output from the Motion FB is 'Motion units' which is not useful for any calculations.

2.SI Units

Inside the Maths FB, the units are always SI. Thus, data from a Motion FB

oIf the Motion FB is set to rotary units, and the output from it is 90º, then the value inside the Maths FB is 1.57radians.
oIf the Motion FB is set to linear units, and the output from it is 100mm, the value inside the Maths FB is 0.1m.

If you multiply these together with the Maths FB, the result 'inside' the Maths FB is 0.157 - of course.

3.Output motion-values and Coordinates

Even though the values internally are SI, the units are converted back to units of the Machine Settings dialog at the output-connector, for the units you select in the Output Data-Type drop-down box.

For example: Machine Settings

If the units [inside the Maths FB] are set to Linear Coordinates, then an output of 0.157 becomes 157mm in the model when the units in the Machine Settings dialog-box are mm.
If the units [inside the Maths FB] are set to Rotary Coordinates, then an output of 0.157 becomes 9º in the model when the units in the Machine Settings dialog-box are degrees.
4.Confusion between Linear Coordinates given to a Rocker, and a Rotary Coordinates given to a Slider

Rotary units connected to a Linear Slider - that is probably not intended

If you set the Output Data Types to Rotary Coordinates, then 0.157 becomes 0.157rads , which is . at the output, when the Machine Settings are degrees.
If you then connect the output to a Motion-Dimension FB to move a Slider, then the becomes 9mm.

Linear Units connected to a Rotary Rocker - that is probably not intended

If you set the Output Data Type to Linear Coordinates, then 0.157 becomes 157mm, when the Machine Settings are mm.
If you connect the output to a Motion-Dimension FB to move a Rocker, then the Rocker rotates 157º.

Math Calculator


The Calculator gives some of the 'standard' mathematical functions.

When the open and closed brackets show in the function button, you must enter a value or an input variable -

For example, Sin(p(1)) calculates the trigonometric 'Sin' of the position value of the second input. [p(0) is the first position input, p(1) is the second, p(2) is the third....]

They include:

1.Position, Velocity and Acceleration Values for an Input
P() ; V(), A()
2.Standard Algebra
Arithmetic: +, –,  ∕ , *
Raise to the Power: ^
Brackets: ( )
3.Trigonometry [all inputs in radians]
Standard: Sin, Cosine, Tangent
Hyperbolic: Sinh, Cosh, Tansh
Inverse:ArcSin, ArcCos, ArcTan2
4.Limit (data input, data at output only when less than a maximum and greater than a minimum)
5.OverLimit (data input, data at output only when greater than value)
6.UnderLimit (data, only when less than)
7.XLimits (data, only when greater, and only when less)
8.Numerical Keypad
9.1...9, 0, Pi.
10.Abs(), Mag(), Sqrt();

Example Maths FB


Example 1: Rack Motion from a Pinion.

Assume we want to drive a Rack from a Pinion.

The Motion of a Rack is given by the Motion of the Pinion. The standard equations we should use are:

Rack Displacement = Pinion Radius * Pinion Rotation Angle of Pinion (D = R * Θ )
Rack Velocity = Pinion Radius * Pinion Angular Velocity of Pinion (V = R * ω )
Rack Acceleration = Pinion Radius * Angular Acceleration of Pinion (A = R * α )

The units in the Maths FB are always SI Units.

Linear Dimensions:

If the Linear Units in the Machine Settings dialog are mm, then the dimension of a Part is in mm. If you change the Linear Units to m, then the dimension of the Part is in m (meters).

For example, a dimension of 100 while the Machine Settings are set to millimeters, will become 0.1 if you change the units to meters in the Machine Settings.

When you add a wire to a Maths FB, it will use the SI units m (meters).

In this case you must multiply the Displacement equation by 1000.

Angular Dimensions:

If the units in the Machine Settings dialog are degs (degrees), and we measure the angle of a Part, it will show as degrees.

However, when you connect a wire to a Maths FB, it will use the SI units for the degs (degrees), that is: rads (radians)


Example 2: Epitrochoid / Hypotrochoid:

When you have parametric equations, you can give the output for the X parameter to a horizontal slider, and the Y parameter to a piggyback orthogonal slider.

If you enter the equations for

position only, then you can plot the Curve
position and velocity, then you can add a Cam with the Sliders (since a Cam needs position and velocity values)
position, velocity and acceleration, then you can plot Radius-of-Acceleration (since this needs all three motion derivatives)

See Tutorial 18 for full details of this example.


Make a Tool Translate at the end of a SCARA Robot.

1.Use Measurement FBs to measure the angles of the 'Upper Arm' and 'Lower Arm', relative to each other.
2.Add two Input-Connectors on the Maths FB
3.Subtract the two angles to give an angle in the Maths FB
4.Connect a wire at the output to the Motion-Dimension FB at the end of the SCARA to keep the tool fixed relative to the Base-Part.

Tutorial and Reference Help Files for MechDesigner and MotionDesigner 13.2 + © Machine, Mechanism, Motion and Cam Design Software by PSMotion Ltd