Getalarms, 2 getalarms – Sensoray 118 User Manual
Page 33

Sensoray Model 118 Smart A/D™ Instruction Manual
31
Commands: Alarms
6.5.2 GetAlarms
Returns the status of all channel alarms in two response
bytes. The first byte indicates the status of all high alarms
while the second byte indicates the status of all low
alarms. Bits 7 (most significant) through bit 0 (least
significant) of each response byte corresponds to
channels 7 through 0, respectively. A status bit
containing logic 1 indicates a violated alarm limit while a
logic 0 indicates no limit violation.
In addition to returning alarm flag data, this command
also resets all channel alarm flags as well as the Smart
A/D™ status register alarm bit.
Driver
// Read all alarm flags from a Smart A/D. Low alarm flags are returned
// in the LSB, and high alarm flags are returned in the MSB.
USHORT GetAlarms( USHORT BasePort )
{
if ( inp( BasePort + 1 ) & STATUS_ALRM ) // If at least one chan alarm sounding ...
{
SendByte( CMD_GET_ALARMS ); // request all alarm flags
return (USHORT)ReadWord(MyBasePort); // fetch and return all alarm flags
}
else // Otherwise ...
return 0; // indicate no alarms are sounding
}
Example
// Read alarm flags and service any channels that are sounding an alarm.
USHORT AlarmFlags = GetAlarms( MyBasePort );
for ( UCHAR Channel = 0; Channel < 8; Channel++ )
{
if ( AlarmFlags & 0x0100 )
{
// Service high limit violation on Channel ...
}
if ( AlarmFlags & 0x0001 )
{
// Service low limit violation on Channel ...
}
AlarmFlags >> 1;
}
Command: (48)
Response:
(HighAlarmFlags),(LowAlarmFlags)