Specifications

Section 8. Processing and Math Instructions
8-24
Public Dim XY(2)
Public Change(3), Deg, PeakV(2)
Const Pi=4*ATN(1) ‘Define Pi for converting degrees to
radians
DataTable(PV1,Change(1),500) ‘Peaks and valleys for first signal,
triggered when ‘Change(1) is not 0.
Sample(1,PeakV(1),IEEE4) ‘DataTable PV1 holds the peaks and
valleys for XY(1)
EndTable
DataTable(PV2,Change(2),500) ‘Peaks and valleys for second signal,
triggered when ‘Change(2) is not 0.
Sample(1,PeakV(2),IEEE4) ‘DataTable PV2 holds the peaks and
valleys for XY(2)
EndTable
‘The Following table is an alternative to using separate tables for each signal.
‘It stores both signals whenever there is a new peak or valley in either signal.
‘The value stored for the signal that does not have a new peak will be a repeat
‘of its last peak or valley. Normally a program would not have a table storing
‘peaks and valleys for several signals, it would use individual tables for the
‘signals.
DataTable(PVBoth,Change(3),500)
Sample(2,PeakV(1),IEEE4)
EndTable
BeginProg
Scan(500,mSec,0,0)
Deg=Deg+5
XY(1)=Cos(Deg*Pi/180) ‘Compute the cosine as input XY(1)
XY(2)=Sin(Deg*Pi/180) ‘Compute the sine as input XY(2)
PeakValley(PeakV(1),Change(1),2,XY(1),0.1) ‘Find the peaks and
‘valleys for both
‘inputs. Hysteresis
= 0.1
CallTable PV1
CallTable PV2
CallTable PVBoth
Next Scan
EndProg