<< Click to Display Table of Contents >> Navigation: MechDesigner Reference & User Interface > DialogBoxes > 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, (the units of the data). E.g. 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:

The Math FB dialogbox is now open.
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. 
There are three(3) Equations for each outputconnector See below for more explanations. 
Output DataType. OutputConnectors, DataChannels
For example: If you select Linear Coordinates as the Output DataType then ALL equations use Linear Units If you have two(2) outputconnectors, there are 6 equations. •The units for DataChannels 0 & 3 are Dis, with units of •The units for DataChannels 1 & 4 are 'Vel', with units of •The units for DataChannels 2 & 5 are 'Acc', with units of •DataChannels/Equations 0, 1, 2 are for 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 
How many input and outputconnectors?
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. We need two inputconnectors and one outputconnector. Edit the Math FB to open the Math FB dialogbox. 1.Add two InputConnectors with the AddInput button 2.Select Power for the Output DataType. 3.Click 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 dialogbox. In CADLine dialogbox > 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 dialogbox, 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 EquationClick the first equation in the Math FB The EquationEditor opens  see below. We 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 becomes 157mm at the outputconnector when the Engineering Units in the Machine Settings dialogbox are mm. •If the Output DataType is Rotary Coordinates, then 0.157 becomes 9º at the outputconnector when the Engineering Units in the Machine Settings dialogbox 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 connected to a Linear Slider  that is probably not intended In the Math FB, if you set the Output Data Type to Rotary Coordinates, then 0.157 becomes 0.157rads internally. This becomes 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º becomes 9mm. Linear Units connected to a Rotary Rocker  that is probably not intended In the Math FB, if you set the Output Data Type to Linear Coordinates, then 0.157 is 0.157m internally. This becomes 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 have the options to add these functions, when needed, with each equation. Note 1: When open and close brackets show within a function button, you must enter a value or an input variable. For example, Sin( ), you must enter at least one wire input. Sin(p(1)) will calculate the trigonometric 'Sine' of the position value of the second inputconnector/ wire... Note 2: •p(0) is data on datachannel 1, at the top, or inputconnector #1, •p(1) is data on datachannel 1, at inputconnector #2, •p(2) is data on datachannel 1, at inputconnector #3, ... Note 3: ALL data 'inside' the Math FB are SI units. Calculator functions1.Position, Velocity and Acceleration Values for an 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.XLimits (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. E.g.: 75 as millimeters m in the model is 0.075 as 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' 