beautypg.com

Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 112

background image

Section 6. Data Table Declarations and Output Processing Instructions

6-18

Histogram4D (BinSelect, Source, DataType, DisableVar, Bins1, Bins2,

Bins3, Bins4, Form, WtVal, LoLim1, UpLim1, LoLim2, UpLim2,
LoLim3, UpLim3, LoLim4, UpLim4)

Processes input data as either a standard histogram (frequency distribution) or
a weighted value histogram of up to 4 dimensions.

The description of the Histogram instruction also applies to the Histogram4D
instruction. The difference is that the Histogram4D instruction allows up to
four bin select inputs (dimensions). The bin select values are specified as
variable array. Each of the bin select values has its own range and number of
bins. The total number of bins is the product of the number of bins in each
dimension (Bins1 x Bins2 x Bins3 x Bins4).

Histogram4D Output Example
'The example program below is an example of using the Histogram4D
'instruction to calculate a 2 dimensional histogram of RPM distribution vs Gear

'\\\\\\\\\\\\\\\\\\\\ VARIABLES and CONSTANTS ////////////////////

Public RPM, Gear, Port(4)
Dim Bin(2)

'\\\\\\\\\\\\\\\\\\\\\\\\ OUTPUT SECTION ////////////////////////

DataTable (RPMvsG,1,100)

DataInterval(0,60,Min,100)
Histogram4D(Bin(), FP2, 0,4,8, 0, 0,000,1,0.5, 4.5, 0,8000, 0, 0, 0, 0)
'4 bins for gear, range 0.5 to 4.5; 8 bins for RPM range 0 to 8000
'Open form so that RPM >8000 is included in 7000 to 8000 bin

EndTable

'\\\\\\\\\\\\\\\\\\\\\\\\\\\ PROGRAM ///////////////////////////

BeginProg

Scan (100,mSec,3,0)
PulseCount (RPM,1,1 ,1,1,0.4225,0)'RPM from pick up on 142 tooth fly wheel

'60 rpm/142 Hz = 0.42253 ...

Portget (Port(1),1)

'There are digital inputs to ports 1 to 4

Portget (Port(2),2)

'If C1 is high then the care is in first gear

Portget (Port(3),3)

'C2 indicates 2nd gear etc.

Portget (Port(4),4)

IF Port(1) then Gear = 1
If Port(2) Then Gear = 2
If Port(3) Then Gear = 3
If Port(4) Then Gear = 4

Bin(1) = Gear
Bin(2) = RPM
CallTable RPMvsG
Next Scan

EndProg