See Add Math FB
See also : Tutorial 18: Maths FB
Use a Math FB to add new math functions, add limits to motionvalues, and combine data that might be useful for your modelling.
You can use a Maths FB to change the units of motionvalues.
There is also a Calculator interface that open to help you select different functions.

Edit the Math FB:


Motion FB dialogbox
Add Connectors; Edit Output Data Type Add Input button  to add inputconnectors to the Maths FB.
Add Output button  to add outputconnectors to the Maths FB. Note: When you add a Maths FB to the graphicarea, it has one outputconnector.
Update button  click this button to update ANY change in the dialog. 

Output DataType
If you select Linear Coordinates, as the units, ALL equations should equate to Linear Units. If you have 4 outputconnectors:
Notes: The Units inside the Maths FB are SI units: kilogram, metres, seconds, ... 

It is easy to use the buttons to add input and outputconnectors. It is also easy to connect wires to the input and outputconnectors. However, to be able to use the Maths FB we MUST spend some time to understand WireNumbers/InputConnectors and DataChannels 

Wire Numbers/inputconnectors and DataChannels The image shows three Wires connected to three inputconnectors. Each Wire has a three DataChannels. 

WireNumbers  refer to the image above. Wire Numbers start at 0
DataChannel Each wire has 3(three) datachannels. Each datachannel has a letter  p, v, and a (even if the data at the input is not a motionvalue}
Each variable in an equation is identified by its: DataChannel(WireNumber) Example Entries in an Equation: p(0) : the p refers to Datachannel 1, and (0) refers to inputconnector 1 a(2) : the a refers to Datachannel 3, and (2) refers to inputconnector 3 v(1) : the v refers to Datachannel 2, and (1) refers to inputconnector 2 How many input and outputconnectors? By way of an example, to calculate Power from Torque × Angular Velocity P = Ʈ . ω Torque(N.m.) × Angular Velocity (rad/sec) Torque data and AngularVelocity data are the inputs and Power is the output. Thus, you need two inputconnectors and one outputconnector. To get Torque data: we must add a ForceData FB to the model. To get AngularVelocity data: the output from the MotionDimension FB is in the model. There is one outputconnector when we add the Maths FB to the model. 

Set the Output Data Type to Power. Click UPDATE after we select the Output Data Type and before we add equations. The Maths FB converts the data of all data at its inputconnectors to SI units. The equation in the Maths FB is: × p(0)*v(1) WireNumber 0 (top), Channel 1 (p = Torque) × WireNumber 1 (bottom wire), Channel 2 (v = Angular Velocity) SYNTAX and VALID Equations: Click the Update after you edit the equation to find if its syntax is correct or not correct. For example, the syntax is not correct if it does not have the correct number of parentheses. The reason is given as a message in the FeedbackArea. The at the left of each equation shows whether its syntax is correct. 

There are 4 possible sources of confusion with respect to 'units' when you use the Maths FB. Data from Motion FBsIf you connect a wire from a Motion FB to the input of a Maths FB, set the Output Data Type IN THE MOTION FB to Linear or Rotary to indicate the SI units you want to apply to an equation in the Maths FB SI UnitsInside the Maths FB, the units are always SI. Thus, data from a Motion FB
If you multiply these together with the Maths FB, the result 'inside' the Maths FB is 0.157  of course. Output motionvalues and CoordinatesEven though the values internal to the Maths FB are SI, the units are converted back to units of the Machine Settings dialog at the outputconnector, for the units you select in the Output DataType dropdown box. For example: Machine Settings
Confusion between Linear Coordinates given to a Rocker, and a Rotary Coordinates given to a SliderRotary 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 9º. at the output, when the Machine Settings are degrees. If you then connect the output 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 If you set the Output Data Type to Linear Coordinates, then 0.157 becomes 157mm, when the Machine Settings are mm. 
Calculator with special functions. 
Use these functions, when needed, with each equation. Click the Equation in the Maths FB, to make sure it is 'active', then the function in the Calculator. You will usually need to edit the equation again! The Calculator provides a few of the common mathematical functions. 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:
Note 3: ALL data 'inside' the Maths FB are SI units. 

Calculator functions
<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
<output> = <input> if <input> is 'greater than limitvalue' <output> = <limitvalue> if <input> is 'less than limitvalue'
<output> = <input> if <input> is 'less than limitvalue' <output> = <limitvalue> if <input> is 'greater than limitvalue'
<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'


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:
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
See Tutorial 18 for full details of this example.


To make a Tool Translate at the end of a SCARA Robot.
