Omron K6CM User Manual page 209

Motor condition, monitoring device
Hide thumbs Also See for K6CM:
Table of Contents

Advertisement

bOutputAgain := FALSE;
bInitUnitConf := TRUE;
bTimeUp := FALSE;
bCollecting := FALSE;
END_IF;
IF ( bInitUnitConf = TRUE ) THEN
// get current time and date --> make CSV file name (K6CM_YYYYMMDD-hhmm.CSV)
dtStartTime := GetTime();
DtToDateStruct(dtStartTime, stStartTime);
sFileName := CONCAT('K6CM_', UINT_TO_STRING(stStartTime.Year));
sWkStr := CONCAT('0', USINT_TO_STRING(stStartTime.Month));
sFileName := CONCAT(sFileName, RIGHT(sWkStr, 2));
sWkStr := CONCAT('0', USINT_TO_STRING(stStartTime.Day));
sFileName := CONCAT(sFileName, RIGHT(sWkStr, 2), '-');
sWkStr := CONCAT('0', USINT_TO_STRING(stStartTime.Hour));
sFileName := CONCAT(sFileName, RIGHT(sWkStr, 2));
sWkStr := CONCAT('0', USINT_TO_STRING(stStartTime.Min));
sFileName := CONCAT(sFileName, RIGHT(sWkStr, 2), '.CSV');
END_IF;
insF_TRIG_FirstOut( Clk := bFirstOutput, Q => bFirstOutput_pls );
IF bFirstOutput_pls = TRUE THEN
bFirstOutputDone := TRUE;
END_IF;
// generate time up signal every data cycle time
IF ( P_First_Run = FALSE ) AND ( bTimeUp = FALSE ) THEN
bTimeMeas := TRUE;
END_IF;
IF ( P_First_Run = FALSE ) AND ( bTimeMeas = FALSE ) THEN
bInitUnitConf := FALSE;
END_IF;
insTON(
In := bTimeMeas,
PT := tOutputCycle, // data collection cycle time
Q => bTimeUp );
// down the flag of collecting during time up of data collection
IF ( bTimeUP = TRUE ) THEN
// Devices carried over to the next cycle during FB processing or retry are treated as retry over
FOR iWk1 := UINT#0 TO iNumOfUnits - UINT#1 BY UINT#1 DO
IF iStatus[ iWk1 ] = UINT#1 OR iStatus[ iWk1 ] = UINT#2 THEN
iStatus[ iWk1 ] := UINT#4;
IF iProCode[ iWk1 ] = UINT#0 THEN // regard it as an invalid device if its product code has not been acquired
bEnable[ iWk1 ] := FALSE;
END_IF;
ELSE
iStatus[ iWk1 ] := UINT#0;
END_IF;
END_FOR;
bCollecting := FALSE;
bTimeMeas := FALSE;
END_IF;
// raise the flag of collecting during measuring of time up (bTimeMeas --> TRUE)
insR_TRIG( Clk := bTimeMeas, Q => bTimeMeas_pls );
IF ( bTimeMeas_pls = TRUE ) THEN
Clear(bExecute);
Clear(wErrID);
Clear(iSelectableUNIT);
Clear(iRetryCnt);
Clear(stRespServiceDat);
bCollecting := TRUE;
bOutput := FALSE;
END_IF;
// status handling of data collection
IF ( bCollecting = FALSE ) THEN
// off the K6CM FB except during data collection
FOR iWk1 := UINT#0 TO iNumOfParallel - UINT#1 BY UINT#1 DO
bExecute[ iWk1 ] := FALSE;
END_FOR;
ELSE
// K6CM FB execution setting 1 ( initialize index of execution target unit )
FOR iWk1 := UINT#0 TO iNumOfParallel - UINT#1 BY UINT#1 DO
IF ( iSelectableUNIT[ iWk1 ] < iWk1 ) THEN
iSelectableUNIT[ iWk1 ] := iWk1; // set initial value if initial status
END_IF;
END_FOR;
// K6CM FB execution setting 2 ( update index of next execution unit )
FOR iWk1 := UINT#0 TO iNumOfParallel - UINT#1 BY UINT#1 DO
// fix the status if invalid node
IF ( bEnable[ iSelectableUNIT[ iWk1 ] ] = FALSE ) THEN
iStatus[ iSelectableUNIT[ iWk1 ] ] := UINT#4;
bExecute[ iWk1 ] := FALSE;
END_IF;
// retry at abnormal completion with flag handled ( return temporary to untreated status )
IF ( iStatus[ iSelectableUNIT[ iWk1 ] ] = UINT#2 ) THEN
IF ( bExecute[ iWk1 ] = FALSE ) AND ( bEnable[ iWk1 ] = TRUE ) THEN
iStatus[ iSelectableUNIT[ iWk1 ] ] := UINT#0;
END_IF;
END_IF;
// search next untreated unit if successful completion or retry-over
IF ( iStatus[ iSelectableUNIT[ iWk1 ] ] = UINT#3 OR iStatus[ iSelectableUNIT[ iWk1 ] ] = UINT#4 ) THEN
IF ( bExecute[ iWk1 ] = FALSE ) THEN
// search next untreated unit
FOR iWk2 := UINT#0 TO iNumOfUnits - UINT#1 BY UINT#1 DO
IF ( iStatus[ iWk2 ] = UINT#0 AND bEnable[ iWk2 ] = TRUE ) THEN // search condition: untreated and not being treated on other session
FOR iWk3 := UINT#0 TO iNumOfParallel - UINT#1 BY UINT#1 DO
END_FOR;
IF ( iWk3 = iNumOfParallel ) THEN
END_IF;
END_IF;
END_FOR;
END_IF;
END_IF;
// when abnormal completion with flag unhandled
IF ( iStatus[ iSelectableUNIT[ iWk1 ] ] = UINT#2 ) THEN
K6CM Motor Condition Monitoring Device User's Manual (N219)
8 Monitoring and Setting Using the EtherNet/IP Devices
During the data collection cycle tOutputCycle, set bTimeMeas (i.e., data collection
in progress) to TRUE during time up measurement.
Once the data collection cycle has passed, set the time-up measurement in
progress to FALSE once and set the time-up measurement to TRUE again during
the data collection cycle.
When time-up measurement in progress bTimeMeas is TRUE,
set the data collection in progress flag bTimeMeas_pls to TRUE.
When the time-up measurement in progress flag is TRUE, set the
bCollectiong during data collection to TRUE.
IF ( iSelectableUNIT[ iWk3 ] = iWk2 ) THEN
EXIT;
END_IF;
iSelectableUNIT[ iWk1 ] := iWk2;
EXIT;
When data collection in progress bCollectiong is TRUE, set the FB execution command
bExecute to TRUE according to the device processing state iStatus.
(The data collection status is held for each device)
Device processing state
0: Indicates that the data collection target is unprocessed.
If it is an unprocessed and valid state (bEnable = TRUE), the FB execution instruction is
set to TRUE.
1: Indicates that data is being collected during processing.
2: Indicates that an error occurred in error data collection. Set the FB execution command
to FALSE, add the number of retry times, and retry communications (once return the
device processing state to 0).
3: Indicates that completion data collection is completed. Set the FB execution command
to FALSE and search for the next unprocessed device.
4: Indicates that the upper limit of the retryover communications retry count has been
reached. Search for the next unprocessed device.
8
8 - 39

Advertisement

Table of Contents
loading

Table of Contents