Serial Wombat Arduino Library

Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for SerialWombatProtectedOutput:
[legend]

## Public Member Functions
| SerialWombatProtectedOutput (SerialWombatChip &serialWombat)
| Constructor for SerialWombatProtectedOutput.
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.
void | makeInput ()
| Turn off protection features and make the protected pin an input.
void | digitalWrite (uint8_t state)
| Turn off the protection features and make the protected pin an unprotected output.
Public Member Functions inherited from SerialWombatPin
| SerialWombatPin (SerialWombatChip &serialWombatChip)
| Instantiates a Serial Wombat Pin.
| SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
| Instantiates a Serial Wombat Pin.
uint16_t | readPublicData ()
| Read the 16 Bit public data associated with this pin.
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.
void | digitalWrite (uint8_t val)
| Set output pin High or Low.
int | digitalRead ()
| Reads the state of the Pin.
uint16_t | writePublicData (uint16_t value)
| Write a 16 bit value to this pin.
uint8_t | pin ()
| Returns the current SW pin number. Used primarily for virtual calls by derived classes.
uint8_t | swPinModeNumber ()
| Returns the Mode number. Used primarily by derived classes to populate packet data.
int16_t | initPacketNoResponse (uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55)
int16_t | initPacketNoResponse (uint8_t packetNumber, uint16_t param0, uint16_t param1, uint8_t param2=0x55)
int16_t | disable ()
| Disables the pin mode (if applicable)
int16_t | enablePullup (bool enabled)
| Enables the weak pull up on a pin. Implemented on SW18AB only.
int16_t | enablePullDown (bool enabled)
| Enables the weak pull down on a pin. Implemented on SW18AB only.
int16_t | enableOpenDrain (bool enabled)
| Enables open drain mode on a pin. Implemented on SW18AB only.

## 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

Definition at line 68 of file SerialWombatProtectedOutput.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatProtectedOutput()

SerialWombatProtectedOutput::SerialWombatProtectedOutput | ( | SerialWombatChip & | serialWombat | ) |
| inline

Constructor for SerialWombatProtectedOutput.

Parameters

  serialWombat | The serial Wombat Chip on which the Protected Output runs

Definition at line 73 of file SerialWombatProtectedOutput.h.

## 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

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

Definition at line 77 of file SerialWombatProtectedOutput.h.

## ◆ 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

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

Definition at line 88 of file SerialWombatProtectedOutput.h.

## ◆ 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

Definition at line 121 of file SerialWombatProtectedOutput.h.

## ◆ 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

Definition at line 106 of file SerialWombatProtectedOutput.h.

## ◆ makeInput()

void SerialWombatProtectedOutput::makeInput | ( |  | ) |
| inline

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

Definition at line 112 of file SerialWombatProtectedOutput.h.