Details
Solution: Implementing a Heartbeat (Vital Sign) Using Digital Inputs and Outputs
Problem Description
In certain applications, devices are required to provide a heartbeat (vital sign) signal to upstream systems such as PLCs, controllers, or monitoring systems. This signal is used to confirm that the device is powered, responsive, and operational.
Solution Overview
This solution demonstrates a simple method to generate a heartbeat signal using digital inputs and user-defined digital outputs on a DataMan reader.
An external system periodically toggles a digital input. The DataMan reader detects this input change and responds by activating a User Output, which can be wired back to the higher-level system as a vitality indicator.
Solution Script
function CommHandler()
{
return {
onConnect: function (peerName)
{
this.peerName = peerName;
if (peerName == "COM1")
{
this.input1 = registerHandler(
Callback.onInput,
this.onInput1Handler.bind(this),
ConstInput.Input1
);
return true;
}
else
{
return false;
}
},
onDisconnect: function()
{
deregisterHandler(this.onInput1);
},
onInput1Handler: function(inputs)
{
if (inputs & 0x02)
{
dmccCommand("Output.User1");
}
}
};
}
How It Works
- The script listens for activity on COM1.
- A callback handler is registered for Digital Input 1.
- When Input 1 becomes active:
- The script triggers User Output 1.
- The output signal can be monitored by the upstream system as a heartbeat or vitality confirmation.
Configuration Notes
- Ensure Digital Input 1 is correctly wired and periodically toggled by the external system.
- Map User Output 1 to a physical output line in the I/O configuration.
- The heartbeat interval is controlled externally (e.g., by a PLC).
Summary
- A heartbeat signal can be implemented using simple digital I/O logic.
- Digital input activity confirms upstream communication.
- User outputs provide a reliable vitality signal to higher-level systems.