Cos (source), Cosh (source) – Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 179

Advertising
background image

Section 8. Processing and Math Instructions

8-7

Example

BeginProg

'Program begins here

Scan( RATE, RUNITS, 0, 0 ) 'Scan 1(mSecs),
'______________________ Volt Blocks ______________________
VoltDiff(HiVolts, VREP1, VRNG1, 5, 1, 0, VDLY1, VINT1, VMULT1,

VOSET1)

AvgRun(AvgOut,1,HiVolts,100 ) 'Put the average of 100 HiVolts in

AvgOut

CallTable MAIN

'Go up and run Table MAIN

Next Scan

'Loop up for the next scan

EndProg

'Program ends here

Cos (Source)

Returns the cosine of an angle specified in radians.

Syntax
x = Cos (
source)

Remarks
Source can be any valid numeric expression measured in radians.

The Cos function takes an angle and returns the ratio of two sides of a right
triangle. The ratio is the length of the side adjacent to the angle divided by the
length of the hypotenuse. The result lies in the range -1 to 1.

To convert degrees to radians, multiply degrees by

π

/180. To convert radians

to degrees, multiply radians by 180/

π

.

Cos FunctionExample
The example uses Cos to calculate the cosine of an angle with a user-specified
number of degrees.

Dim Degrees, Pi, Radians, Ans

'Declare variables.

BeginProg
Pi = 4 * Atn(1)

'Calculate Pi.

Degrees = Volts(1)

'Get value to convert.

Radians = Degrees * (Pi / 180)

'Convert to radians.

Ans = Cos(Radians)

‘The Cosine of Degrees.

EndProg

CosH (Source)

The COSH function returns the hyperbolic cosine of an expression or value.

Syntax
x = COSH
(source)

Remarks
The COSH function takes a value and returns the hyperbolic cosine [COSH(x)
= 0.5(ex + e-x)] for that value.

COSH Function Example
The example uses COSH to calculate the hyperbolic cosine of a voltage input
and store the result in the Ans variable.

Advertising