You are on page 1of 2

Determining SPCPro Alarm Types With SQL Queries Page 1 of 2

Tech Note 99
Determining SPCPro Alarm Types With SQL Queries

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more
information.

Topic#: 000698
Created: May 1998

Wonderwareฎ SPCPro™ stores data in a database, rather than a text file like Wonderwareฎ SPC™. This allows
you the flexibility to do complex searches for data using SQL queries. In the SPCPro database, in the
SPCSamples table, there is a column called Alarms that contains all of the alarms for each sample in the
database. This Tech Note shows how to use SQL queries with the Alarms column to determine the alarm type for
a sample.

The Alarms column contains an encoded integer where each alarm type is indicated by a different bit. The
following table specifies the bit layout:

Bit Number Hex Location Alarm Type


0 0x00000001H Unused.
1 0x00000002H X-Bar outside specification limits.
2 0x00000004H 2 of the last 3 samples are outside 2 sd (same side).
3 0x00000008H 4 of the last 5 samples are outside 1 sd (same side).
4 0x00000010H X consecutive samples are outside 1 sd (either side).
5 0x00000020H X consecutive samples are inside 1 sd (either side).
6 0x00000040H X consecutive samples increasing or decreasing.
7 0x00000080H X consecutive samples alternating up and down.
8 0x00000100H X consecutive samples on one side of the mean.
9 0x00000200H X of the last Y samples are outside Z sd (either side).
10 0x00000400H X of the last Y samples are outside Z sd (same side).
11-29 Unused
30 0x40000000H Range outside control limits.
31 0x80000000H X-Bar outside control limits.

Using the above table, say that a sample point has a 2 of the last 3 samples outside 2 sd alarm and a 4 of
the last 5 samples outside 1 sd alarm. According to these alarm types, the binary representation of this point
would be 01100 (2 2 + 2 3), so the integer value in the Alarms column for this point would be 12.

This encoding of alarms adds some complexity in querying the database to retrieve information such as “how
many samples had an out of Range alarm” or “what were all of the alarms for sample number 25.” To extract
this type of information, the individual bits of the Alarms integer should be compared to the table above. This
can be done using a SQL query containing the bitwise AND operator, which is the & symbol. For example, you
could run the following SQL query to find all of the samples that are in all the datasets and all of the products
that are outside the specification limits:

select SampleNum, d.Name, p.Name


from SPCDatasets d, SPCProducts p, SPCSamples s
where p.DatasetID = d.DatasetID AND p.ProductID = s.ProductID
AND (Alarms & 2) > 0
order by d.Name, p.Name, SampleNum

To break apart the Alarms field and display each type of alarm in a different column, run the following SQL
query. The example below will find the alarms for dataset “XbarR,” where a 1 would indicate an alarm and a 0
would indicate no alarm.

select SampleNum, p.Name, (Alarms & 2)/2 OOS, (Alarms & 4)/4
“2of3”, (Alarms & 8)/8 “4of5”

http://fa.sammicomputer.co.kr/TECH/html/determi2.htm 1/23/2012
Determining SPCPro Alarm Types With SQL Queries Page 2 of 2

from SPCDatasets d, SPCProducts p, SPCSamples s


where p.DatasetID = d.DatasetID AND p.ProductID = s.ProductID
AND d.Name = “XBarR”
order by p.Name, SampleNum

The one exception to this bitwise comparison method is for the Xbar outside control limits alarm, which is the
sign bit. To check if a dataset has an Xbar outside of control limit alarm, simply check for Alarms < 0 in the
where expression. To return a discrete value, use (SIGN(Alarms)&2)/2 in the select statement.

Jeff Barkehanai

The Tech Note is published occasionally by Wonderware Technical Support. Publisher: Invensys Systems, Inc., 26561 Rancho Parkway
South, Lake Forest, CA 92630. There is also technical information on our software products at www.wonderware.com/support/mmi

For technical support questions, send an e-mail to support@wonderware.com.

back to top

ฉ2012 Invensys Systems, Inc. All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any
form or by any means, electronic or mechanical, including photocopying, recording, broadcasting, or by any information storage and
retrieval system, without permission in writing from Invensys Systems, Inc.

http://fa.sammicomputer.co.kr/TECH/html/determi2.htm 1/23/2012

You might also like