Motor Start/Stop for OEE Measurement

Afternoon Team,

I have an idea I am trying to vet out. I have a unit where we capture data from the PLC.

Using graphing I can see when the unit starts, when it stops and for how long, as well and the end day. I also have the total units produced.

I would like to view this data in a table showing this information.

Beginning Time
End Time
Any start and stop throughout the day and how long it stopped.

Any ideas?

Do you have a sample of data you can share?

Sample data.xlsx (22.5 KB)
Sampe Multiple Days.xlsx (6.6 KB)

I have added a single day and multiple days.

The data gathering of the data is really nice but to turn it into usable information is a little difficult.

Our day starts around 5:30 am. At that point the counts will start to increase.

Throughout the day there are 2 possibly 3 breaks that are a specific time. At the end of the day the data plateaus off and that is my end time.

Do you differentiate between small stops and full down?

We have three breaks. All approximately

1st at 8:30 am for 20 minutes
2nd at 12:00 for 36 minutes
3rd is random based out projected out time. It is 10 minutes.

Using Sample data.xlsx, and just comparing rows. Should give you a start.

from datetime import timedelta

##################################################################
# Read Excel file and put into dataset with millis formatted t_stamp
# This is to simulate the return from a historian query
#
filePath = 'C:/Test/ahawes/Sample data.xlsx'

datasetIn = util.excelToDataSet(filePath, True)

headers = list(datasetIn.getColumnNames())
data = []
for row in range(datasetIn.getRowCount()):
	data.append([datasetIn.getValueAt(row,0).toInstant().toEpochMilli(), datasetIn.getValueAt(row,1)])

datasetIn = system.dataset.toDataSet(headers, data)
##################################################################

# Check for rows that have the same quantity and add 
# the intervening number of milliseconds.
for i in range(1, datasetIn.getRowCount()):
	if datasetIn.getValueAt(i,1) == datasetIn.getValueAt(i-1,1):
		millisDown += datasetIn.getValueAt(i,0) - datasetIn.getValueAt(i-1,0)

print millisDown
print timedelta(seconds=millisDown/1000)

Output:

15708174
4:21:48

Alternative for using a PyDataSet. Whichever is easier to understand / maintain.

pyData = system.dataset.toPyDataSet(datasetIn)

millisDown = 0

# Check for rows that have the same quantity and add 
# the intervening number of milliseconds.
for row, prevRow in zip(pyData[1:], pyData):
	if row[1] == prevRow[1]:
		millisDown += row[0] - prevRow[0]

Amazing Jordan, thank you for the help. I will write it and implement the code.