SIN, COS, TAN, ASN, ACS, ATN, LN, LOG, DEG, RAD — Math Functions

Description
Section titled “Description”The ten math function blocks each take one Source, apply a function, and write the result to Dest every scan the rung is true. They are output instructions with no state and no status bits, identical in shape and behaviour, differing only in the function. Use them for angle and trigonometry work, logarithmic sensors, and unit conversion between degrees and radians. Do not chain three of them where one CPT would do; CPT Y A * SIN(RAD(Angle)) is one block and one Dest. Every one of these functions is also available inside CPT and CMP under the same name.
| Mnemonic | Function | Source | Result |
|---|---|---|---|
| SIN | Sine | angle in radians | −1 to 1 |
| COS | Cosine | angle in radians | −1 to 1 |
| TAN | Tangent | angle in radians | any; very large near ±π/2 |
| ASN | Arc sine | −1 to 1 | angle in radians, −π/2 to π/2 |
| ACS | Arc cosine | −1 to 1 | angle in radians, 0 to π |
| ATN | Arc tangent | any | angle in radians, −π/2 to π/2 |
| LN | Natural logarithm | greater than 0 | any |
| LOG | Logarithm base 10 | greater than 0 | any |
| DEG | Radians to degrees | angle in radians | angle in degrees |
| RAD | Degrees to radians | angle in degrees | angle in radians |
Angles are radians. SIN, COS and TAN expect radians and ASN, ACS and ATN return them. Convert with RAD on the way in and DEG on the way out, or write SIN(RAD(Angle)) in a CPT.
Operands
Section titled “Operands”| Operand | Type | Format | Valid Range | Required | Description |
|---|---|---|---|---|---|
| Source | Any numeric tag, member, element or bit, or a literal | Tag, Tag.Member, Tag[n], Tag.bit, or a literal |
See the table above; out of range gives 0 | Yes | The function argument. |
| Dest | A writable numeric tag, member or element | Tag, Tag.Member, Tag[n] |
SINT, INT, DINT or REAL; not a literal, not an input pin | Yes | Where the result is written. |
Dest must be a REAL. Every one of these functions returns a fraction almost always. Into a whole-number Dest the result truncates toward zero: SIN into an INT is 0 or ±1, LOG of 500 into an INT is 2. Only DEG, whose result may be tens or hundreds, makes sense in an INT, and even then the fraction is lost.
Out-of-range arguments. ASN 2, ACS −1.5, LN 0, LOG of a negative all write 0. There is no fault and the rung continues. Range-check the Source when it can wander.
Scan Behavior
Section titled “Scan Behavior”Prescan
Section titled “Prescan”Nothing. Dest keeps its power-up value.
Rung-condition-in is false
Section titled “Rung-condition-in is false”The instruction does nothing. Dest holds its last value.
Rung-condition-in is true
Section titled “Rung-condition-in is true”Source is read, the function is applied and the result is written to Dest every scan the rung is true.
Postscan
Section titled “Postscan”Nothing.
Example
Section titled “Example”Scenario: A tilt sensor reports an angle in degrees. The logic needs the sine of that angle for a load calculation, so the angle is converted to radians and then fed to SIN, two blocks on one rung.
Tags:
Calc_Trig— Compute, BOOLAngle_Deg— Tilt angle in degrees, REALAngle_Rad— The same angle in radians, REALSine— Sine of the angle, REAL
Rung 1:
—] [Calc_Trig———[RAD Angle_Deg Angle_Rad]———[SIN Angle_Rad Sine]———Scan 1 — Calc_Trig = 0. Angle_Deg reads 30. The rung is false: Angle_Rad and Sine both hold 0.

Scan 2 — Calc_Trig = 1. Both blocks run in order, left to right, in the same scan. Angle_Rad reads 0.523599 and, because the RAD wrote it before the SIN read it, Sine reads 0.5 on the very same scan.

Type 90 into Angle_Deg and Sine reads 1. Type −30 and it reads −0.5.
See Also
Section titled “See Also”- SQR — Square Root (the same shape, its own page)
- XPY — X to the Power of Y (the two-source member of this group)
- CPT — Compute (all ten functions inside one expression)
- Compute Instructions — Category index
Order on the rung. Output instructions on one rung execute left to right within the scan, so a block may consume the Dest of the block before it, as the example does.
Which arc tangent. ATN takes a single ratio and returns −π/2 to π/2; it cannot tell which quadrant a pair of coordinates is in. For a full-circle bearing from X and Y, test the signs with CMP and add π where needed.
Logarithms of sensors. A vacuum gauge or a pH probe with a logarithmic output linearises with LOG or LN followed by SCP.
Missing from the palette on purpose. EXP (e to the x) and TRN (truncate) exist only inside CPT and CMP. A block was not worth its place for either.
The block never colours. Watch the rung wire and the Dest value line.
Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11