Serial Wombat Arduino Library

Loading...
Searching...
No Matches
Public Member Functions | List of all members
SerialWombatFrequencyOutput Class Reference

A class representing a Serial Wombat Frequency Output. More...

`#include <SerialWombatFrequencyOutput.h>`

Inheritance diagram for SerialWombatFrequencyOutput:
[legend]
Collaboration diagram for SerialWombatFrequencyOutput:
[legend]

## Public Member Functions
| SerialWombatFrequencyOutput (SerialWombatChip &serialWombat)
| Constructor for SerialWombatFrequencyOutput class.
int16_t | begin (uint8_t pin, uint16_t maxFrequency_Hz=65535, bool lowFrequency=false, uint16_t dutyCycle=0x8000)
| Initialize a pin that has been declared as FrequencyOutput.
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

A class representing a Serial Wombat Frequency Output.

An instance of this class should be declared for each pin to be used as a Serial Wombat Frequency Output.

Serial Wombat 18AB PWM outputs are driven either by hardware peripherals or by a DMA based software PWM scheme. Up to 6 hardware PWM outputs are avaialble on Enhanced Digital Performance pins (0-4,7,9-19). The first six Enhanced Digitial Performance pins configured after reset will claim hardware resources. Any additional pins configured for Frequency output will use DMA based output. Hardware capable pins can generate high resolution signals up to about 100kHz. DMA based output is limited to transitions every 17uS, so a 1kHz output will have about 6 bits of resolution and a 100 Hz output will have about 9 bit resolution. Since the DMA runs at only 57600 Hz, frequency accuarcy will suffer on DMA pins as frequency increases, unless the desired frequency is an integer divisor of 57600.

For very slow signals (under 20 Hz) the low frequency option should be used. Otherwise these signals cannot be generated. The low frequency option works on a mS rather than uS timer, so its resolution becomes increasingly poor at higher frequencies, but may be useful for applications such as simulation of speedometers or tachometers which operate at relatively low freqeuencies.

A single very high speed frequency output is available on the Serial Wombat 18AB through the High Speed Clock Output function

Definition at line 60 of file SerialWombatFrequencyOutput.h.

## Constructor & Destructor Documentation

## ◆ SerialWombatFrequencyOutput()

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

Constructor for SerialWombatFrequencyOutput class.

Parameters

  serialWombat | SerialWombat chip on which the FrequencyOutput will run

Definition at line 67 of file SerialWombatFrequencyOutput.h.

## Member Function Documentation

## ◆ begin()

int16_t SerialWombatFrequencyOutput::begin | ( | uint8_t | pin,
|  | uint16_t | maxFrequency_Hz = 65535,
|  | bool | lowFrequency = false,
|  | uint16_t | dutyCycle = 0x8000 )
| inline

Initialize a pin that has been declared as FrequencyOutput.

Parameters

  pin | Pin to use for Frequency Output. Use an enhanced Digital Capability pin for high frequencies
  maxFrequency_Hz | Maximum frequency to be output (used to pick best timing hardware)
  lowFrequency | Set to true if signals slower than 20Hz need to be generated. Has negative effect on higher frequencies
  dutyCycle | Duty cycle of frequency to be output

Definition at line 76 of file SerialWombatFrequencyOutput.h.