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>

Inheritance diagram for SerialWombatProtectedOutput:
SerialWombatPin

Public Member Functions

 SerialWombatProtectedOutput (SerialWombatChip &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...
 
- Public Member Functions inherited from SerialWombatPin
 SerialWombatPin (SerialWombatChip &serialWombatChip)
 Instantiates a Serial Wombat Pin. More...
 
 SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
 Instantiates a Serial Wombat Pin. More...
 
uint16_t readPublicData ()
 Read the 16 Bit public data associated with this pin. More...
 
void pinMode (uint8_t mode, bool pullDown=false, bool openDrain=false)
 Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings. More...
 
void digitalWrite (uint8_t val)
 Set output pin High or Low. More...
 
int digitalRead ()
 Reads the state of the Pin. More...
 
uint16_t writePublicData (uint16_t value)
 Write a 16 bit value to this pin. More...
 
uint8_t pin ()
 Returns the current SW pin number. Used primarily for virtual calls by derived classes. More...
 
uint8_t swPinModeNumber ()
 Returns the Mode number. Used primarily by derived classes to populate packet data. More...
 

Additional Inherited Members

- Protected Attributes inherited from SerialWombatPin
uint8_t _pin = 255
 
SerialWombatChip_sw
 
uint8_t _pinMode = 0
 

Detailed Description

Combine and input and output pin for a protected output.

The SerialWombtProtectedOutput class is assigned to a Serial Wombat output pin. 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 chip 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 chip and its associated libraries are not designed for use in Safety Critical applications. The Serial Wombat chip 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 ( SerialWombatChip serialWombat)
inline

Constructor for SerialWombatProtectedOutput.

Parameters
serialWombatThe serial Wombat Chip on which the Protected Output runs

Member Function Documentation

◆ begin()

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

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 
)
inline

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)
inline

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 ( )
inline

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 ( )
inline

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