<< Click to Display Table of Contents >> Navigation: MechDesigner Reference & User Interface > Dialogs > Dialog: FunctionBlock: Math (with Calculator) 
See Add Math FB See also : Tutorial 18: Math FB
Use a Math FB to add new math functions.
Use a Math FB to change the DataType and units . For example, change Motion units to Force units, and connect a Math FB to a Spring FB.
A Calculator interface can help you select different functions.

To open the Math FB dialog:

The Math FB dialog is now open.
Math FB dialog 
1.Click the button to add an inputconnectors to the Math FB. You need one inputconnector for each variable or parameter in your equation. 
1.Click the button to add an outputconnector from the Math FB. You need one outputconnector for each output. 
1.Click the button when you: •Change the Output DataType •Edit an equation 
The Output DataType applies to All of outputconnectors from the Math FB. To select a different Output DataType 1.Click the dropdown box 2.Select the Output DataType Notes: Inside the Math FB, all units are SI units. A change to the DataType may change the value at the outputconnector of the Math FB. 
Output DataType, OutputConnectors, DataChannels
For example: If you select Linear Coordinates as the Output DataType, then ALL of the equations use Linear Units If you have two(2) outputconnectors, there are 6 equations. •The units for DataChannels Q0[Dis.] and Q1[Dis.] are Displacement, with units of •The units for DataChannels Q0[Vel.] and Q1[Vel.] are Velocity, with units of •The units for DataChannels Q0[Acc.] and Q1[Acc.] are Acc, with units of •DataChannels/Equations 0, 1, 2 are for the OutputConnector #1 •DataChannels/Equations 3, 4, 5 are for OutputConnector #2 
Wire Numbers / inputconnectors and DataChannels
The image below shows three(3) Wires connected to three(3) InputConnectors. Each Wire has three DataChannels. 

3 Wires, 3 InputConnectors 
WireNumbers  refer to the image above. Wire numbers start at 0 •InputConnector 1, Wire 0  connected to the TOP inputconnector •InputConnector 2, Wire 1 •InputConnector 3, Wire 2  connected to the BOTTOM inputconnector 
Each wire has 3(three) datachannels. Each datachannel is designated with a letter: •p = DataChannel 1 •v = DataChannel 2 •a = DataChannel 3 The format to reference a WireNumber and DataChannel in an equation is DataChannel (WireNumber) Example  Entries in an Equation: p(0) : p refers to Datachannel 1 ; and (0) refers to inputconnector 1 a(2) : a refers to Datachannel 3 ; and (2) refers to inputconnector 3 v(1) : v refers to Datachannel 2 ; and (1) refers to inputconnector 2 
As an example, to calculate Power : P = Ʈ . ω Power (N.m./sec) = Torque(N.m.) × Angular Velocity (rad/sec) Torque data and AngularVelocity data are inputs to the equation. Power is the output. You need two inputconnectors and one outputconnector. Edit the Math FB to open the Math FB dialog. 1.Add two InputConnectors with the AddInput button 2.Select Power as the Output DataType 3.Click the UPDATE button 
Prepare the model (see above) 1.Add a Rocker  see Tutorial 1 2.Edit the CADLine of the Rocker, to open the CADLine dialog. In CADLine dialog > Mass Properties tab > User Mass Properties . Enter X and Y values to move the CenterofMass away from the startPoint (origin) of the CADLine. 3.Add a ForceData FB, open the ForceData FB dialog, select the PinJoint, and select the Point in the BasePart to find the Torque that actson the BasePart. 
See image above  the DataChannels on the wire of the ForceData FB and the MotionDimension FB The Math FB uses SI units for all data 'inside'. Enter the Equation Click the first equation in the Math FB The EquationEditor opens  see below. You need to enter this equation@ Q0 [Power] = p(0)*v(1) 
p(0) = WireNumber 0 (top inputconnector), Channel 1 (p = Torque) × v(1) = WireNumber 1 (inputconnector below top), Channel 2 (v = Angular Velocity) 
SYNTAX and VALID Equations Click the Update after you edit the equation to find out if the syntax is correct For example, it may not have correct number of parentheses. The reason is given as a message in the FeedbackArea. The at the left of each equation shows if its syntax is correct. IMPORTANT Data from Motion FBs If you connect a wire from a Motion FB to the input of a Math FB, Set the Output DataType in the MOTION FB to Linear or Rotary. 
There are 4 possible sources of confusion with respect to 'units' when you use the Math FB. SI Units Inside the Math FB, the units are SI. Example: •If the Motion FB is set to Rotary, and the output from it is 90º, then the value internal to the Math FB is 1.57radians. •If the Motion FB is set to Linear, and the output from it is 100mm, the value internal to the Math FB is 0.1m. If you multiply these together with the Math FB, the internal result is 0.157  of course. SI Units are converted to Engineering Units The SI units and values that are internal to the Math FB are converted back to Engineering Units of the Output DataType. Example continued... •If the Output DataType is Linear Coordinates, then 0.157 is 157mm at the outputconnector when the Engineering Units in the Machine Settings dialog are mm. •If the Output DataType is Rotary Coordinates, then 0.157 is 9º at the outputconnector when the Engineering Units in the Machine Settings dialog are degrees. The reason? 0.157rads (inside the Math FB) = 9º (outside the Math FB). LinearCoordinates to a Rocker, RotaryCoordinates to a Slider Example continued... Rotary units to move a Linear Slider! In the Math FB, if you set the Output Data Type to Rotary Coordinates, then 0.157 is 0.157rads internally to the Math FB. It is 9º at the output, when the EngineeringUnits are degrees. If you connect the Math FB to a MotionDimension FB to move a Slider, then the 9º is equal to 9mm. Linear Units to move a Rotary Rocker! In the Math FB, if you set the Output Data Type to Linear Coordinates, then 0.157 is 0.157m internally. It is 157mm at the output when the EngineeringUnits are mm. 
EquationEditor with Calculator
EquationEditor with Calculator 
The EquationEditor provides a few of the common mathematical functions you can add to each equation. Note 1: When open and close brackets show within a function button, you should enter a value that is constant or a value that changes over a machinecycle. Example 1: Sin( ) You can enter a constant . e.g. Sin(3.14) You can also enter a variable, e.g. Sin(p(1)) p(1) is datachannel #1 of inputconnector #2. Note 2: ALL data “inside” the Math FB are SI units. Calculator Functions1.Position, Velocity, and Acceleration Values for a linear or angular input •P( ) ; V( ) ; A( ) 2.Standard Algebra •Arithmetic: +, –, ∕ , * •Power: ^ •Brackets: ( ) 3.Boolean •> : <output> =1 if <value 1> > <value 2>, else 0 •< : <output> =1 if <value 1> > <value 2>, else 0 4.Trigonometry (all inputs in radians) •Standard: Sin( ), Cosine( ), Tangent( ) •Hyperbolic: Sinh( ), Cosh( ), Tansh( ) •Inverse: ArcSin( ), ArcCos( ) , ArcTan2( ; ) 5.Limit (input ; maximum value ; minimum value) : <output> = <input> if <input> is less than maximum value AND more than minimum value. <output> = <maximumvalue> if <input> is greater than maximum <output> = <minimumvalue> if <input> is less than minimum 6.OverLimit (input ; limitvalue) : <output> = <input> if <input> is 'greater than limitvalue' <output> = <limitvalue> if <input> is 'less than limitvalue' 7.UnderLimit (input ; limit value) : <output> = <input> if <input> is 'less than limitvalue' <output> = <limitvalue> if <input> is 'greater than limitvalue' 8.Limits (input ; maximum value ; minimum value) : <output> = <input> if <input> is 'greater than maximum value' OR less than minimum value'. <output> = <maximumvalue> if <input> is 'less than maximum' AND 'more than minimumvalue <output> = <minimumvalue> if <input> is 'greater than minimumvalue AND 'less than maximumvalue' 9.Numerical Keypad 10.1...9, 0, Π. 11.Abs( ) 12.Mag( ; ) (assumes the two values are 'orthogonal' and uses Pythagoras to find the 'resultant') 13.Sqrt( ); 14.DegToRad( ) 15.RadToDeg( ) 
Limit Function Limit (input ; maximum value ; minimum value) : <output> = <input> if <input> is less than maximum value AND greater than minimum value. <output> = <maximumvalue> if <input> is greater than maximum <output> = <minimumvalue> if <input> is greater than minimum Note that the arguments in the Limit Function are SI units for the units in the model. For example, 75 millimeters in the model is 0.075 meters in the function. 
Under Limit Function UnderLimit (input ; limit value) : <output> = <input> if <input> is 'less than limitvalue' <output> = <limitvalue> if <input> is 'greater than limitvalue' 
Over Limit Function OverLimit (input ; limitvalue) : <output> = <input> if <input> is 'greater than limitvalue' <output> = <limitvalue> if <input> is 'less than limitvalue' 