Serial Wombat Arduino Library
Public Member Functions | List of all members
SerialWombatProtectedOutput Class Reference

Combine and input and output pin for a protected output. More...

#include <serialWombatProtectedOutput.h>

Public Member Functions

 SerialWombatProtectedOutput (SerialWombat &serialWombat)
 Constructor for SerialWombatProtectedOutput. More...
 
void begin (uint8_t pin, uint8_t monitoredPin)
 
void configure (PO_COMPARE_t compareMode, uint16_t compareValue, uint8_t debounceTime, SerialWombatPinState_t activeState, SerialWombatPinState_t safeState)
 
bool isInSafeState ()
 Queries the Serial Wombat to see if the protected output has entered safe mode due to a fault. More...
 
void makeInput ()
 Turn off protection features and make the protected pin an input. More...
 
void digitalWrite (uint8_t state)
 Turn off the protection features and make the protected pin an unprotected output. More...
 

Detailed Description

Combine and input and output pin for a protected output.

The SerialWombtProtectedOutput class is assigned to a Serial Wombat output. It monitors another previously configured pin's public data, such as a digital I/O value or an Analog input. If the monitored value does not meet expectations, then the protected pin changes values to a configured state. This allows the Serial Wombat to constantly verify a condition without the need for constant polling from the host device.

Warning
The SerialWombatProtectedOutput is intended to help prevent accidental damage to hobby circuitry. The Serial Wombat and its associated libraries are not designed for use in Safety Critical applications. The Serial Wombat should not be used in situations where a malfunction or design defect could result in damage to property, economic loss, or harm to living people or creatures.

The period of time that a mismatch must occur before going to the safeState is configurable.

Video Tutorial

https://youtu.be/p8CO04C1q_Y

Constructor & Destructor Documentation

◆ SerialWombatProtectedOutput()

SerialWombatProtectedOutput::SerialWombatProtectedOutput ( SerialWombat serialWombat)

Constructor for SerialWombatProtectedOutput.

Parameters
serialWombatThe serial Wombat on which the Protected Output runs

Member Function Documentation

◆ begin()

void SerialWombatProtectedOutput::begin ( uint8_t  pin,
uint8_t  monitoredPin 
)

Initialize the Protected Output. No pin state changes happen with this function

Parameters
pinThe output pin of the Protected output Valid values for SW4A: 0-3 SW4B: 1-3
monitoredPinThe input pin for the Protected Output. Must be initialized before this call

◆ configure()

void SerialWombatProtectedOutput::configure ( PO_COMPARE_t  compareMode,
uint16_t  compareValue,
uint8_t  debounceTime,
SerialWombatPinState_t  activeState,
SerialWombatPinState_t  safeState 
)

Configure a protected output. This function will change the pin output to activeState unless fault conditions are met

Parameters
compareModeEnumerated type of PO_COMPARE_t .
compareValueA 16 bit unsigned value that will be compared with the public data from the monitored pin and compared based on compareMode
debounceTimeHow long, in mS the compareMode fault condition must exist before transitioning to safeState
activeStateThe initial, pre-fault state for the output (SW_LOW, SW_HIGH, SW_INPUT). Do not use Arduino HIGH or LOW or INPUT constants.
safeStateThe safe, post-fault state for the output (SW_LOW, SW_HIGH, SW_INPUT). Do not use Arduino HIGH or LOW or INPUT constants.

◆ digitalWrite()

void SerialWombatProtectedOutput::digitalWrite ( uint8_t  state)

Turn off the protection features and make the protected pin an unprotected output.

This function is compatible with the Arduino digital write, and therefore uses HIGH and LOW as parameters rather than SW_HIGH or SW_LOW /param state HIGH or LOW

◆ isInSafeState()

bool SerialWombatProtectedOutput::isInSafeState ( )

Queries the Serial Wombat to see if the protected output has entered safe mode due to a fault.

Returns
True if in safe state, false if in openState

◆ makeInput()

void SerialWombatProtectedOutput::makeInput ( )

Turn off protection features and make the protected pin an input.