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

A class for the Serial Wombat 18AB Chip that adds support for high frequency hobby Servos(200 Hz, 333Hz, 560Hz, etc) More...

#include <SerialWombatServo.h>

Inheritance diagram for SerialWombatHighFrequencyServo:
SerialWombatServo_18AB SerialWombatServo SerialWombatAbstractScaledOutput SerialWombatPin

Public Member Functions

 SerialWombatHighFrequencyServo (SerialWombatChip &serialWombat)
 
void attach (uint8_t pin, bool reverse)
 Do not use this interface for High Frequency Servos. More...
 
void attach (uint8_t pin, uint16_t min, uint16_t max, bool reverse=false)
 Initialize a high Speed servo on the specified pin. More...
 
int16_t writeFrequency_Hz (uint16_t frequency_hZ)
 
int16_t writePeriod_uS (uint16_t period_uS)
 
- Public Member Functions inherited from SerialWombatServo_18AB
 SerialWombatServo_18AB (SerialWombatChip &serialWombat)
 
uint8_t pin ()
 Facilitates inheritance. More...
 
uint8_t swPinModeNumber ()
 Facilitates inheritance. More...
 
- Public Member Functions inherited from SerialWombatServo
 SerialWombatServo (SerialWombatChip &sw)
 Constructor for the SerialWombatServo Class. More...
 
void attach (uint8_t pin, bool reverse)
 Initialize a servo on the specified pin. More...
 
void attach (uint8_t pin, uint16_t min=544, uint16_t max=2400, bool reverse=false)
 Initialize a servo on the specified pin. More...
 
void write (uint8_t angle)
 Writes a value to the servo. More...
 
void write16bit (uint16_t position)
 Writes a 16 bit value to the servo. More...
 
uint8_t read (void)
 returns the last position of the servo scaled to a number from 0 to 180. 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...
 
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) More...
 
- Public Member Functions inherited from SerialWombatAbstractScaledOutput
 SerialWombatAbstractScaledOutput (SerialWombatChip &sw)
 Constructor for the SerialWombatAbstractScaledOutput Class. More...
 
int16_t writeTimeout (uint16_t timeout_mS, uint16_t timeoutOutputValue)
 Enable a timeout value which will cause the output to go to a default value if not updated. More...
 
int16_t writeScalingEnabled (bool enabled, uint8_t sourcePin)
 Enable scaling and set which pin or public data is used as the input source. More...
 
int16_t writeInputScaling (uint16_t inputMin, uint16_t inputMax)
 Scale incoming values to a range of 0 to 65535. More...
 
int16_t writeOutputScaling (uint16_t outputMin, uint16_t outputMax)
 Reduces the output range from 0 to 65535 to user specified range. More...
 
int16_t writeScalingInvertedInput (bool inverted)
 if enabled subtract the input value from 65535 before doing any other processing. More...
 
int16_t writeScalingTargetValue (uint16_t target)
 The target input value for PID control. More...
 
int16_t writeRateControl (Period samplePeriod, uint16_t maximumChangecounts)
 
int16_t write1stOrderFiltering (Period sampleRate, uint16_t filterConstant)
 
int16_t writeHysteresis (uint16_t lowLimit, uint16_t lowOutputValue, uint16_t highLimit, uint16_t highOutputValue, uint16_t initialOutputValue)
 Controls the output based on hystersis control. More...
 
int16_t writePID (uint16_t kp, uint16_t ki, uint16_t kd, uint16_t target, Period samplePeriod)
 Configure the scaled output block into PID control mode. More...
 
uint16_t readLastOutputValue ()
 Request Last Output Value. More...
 
int16_t writeScalingTargetValueResetIntegrator (uint16_t target)
 
int32_t PIDGetLastError ()
 
int32_t PIDGetLastIntegrator ()
 
int32_t PIDGetLastIntegratorEffort ()
 
int32_t PIDGetLastProportionalEffort ()
 
int32_t PIDGetLastDerivativeEffort ()
 
int32_t PIDGetLastEffort ()
 
uint16_t ReadLastTarget ()
 
int16_t Enable2DLookupOutputScaling (uint16_t IndexInUserMemory)
 Set Up 2D Lookup Output Scaling. More...
 

Additional Inherited Members

- Public Types inherited from SerialWombatAbstractScaledOutput
enum  Period {
  PERIOD_1mS = 0, PERIOD_2mS = 1, PERIOD_4mS = 2, PERIOD_8mS = 3,
  PERIOD_16mS = 4, PERIOD_32mS = 5, PERIOD_64mS = 6, PERIOD_128mS = 7,
  PERIOD_256mS = 8, PERIOD_512mS = 9, PERIOD_1024mS = 10
}
 
- Protected Member Functions inherited from SerialWombatServo
void initializeServo ()
 
- Protected Attributes inherited from SerialWombatServo
uint16_t _position = 0
 
uint16_t _min = 544
 
uint16_t _max = 2400
 
bool _reverse = false
 
- Protected Attributes inherited from SerialWombatPin
uint8_t _pin = 255
 
SerialWombatChip_sw
 
uint8_t _pinMode = 0
 

Detailed Description

A class for the Serial Wombat 18AB Chip that adds support for high frequency hobby Servos(200 Hz, 333Hz, 560Hz, etc)

The SerialWombatHighFrequencyServo class is used to control hobby high frequency servos attached to the Serial Wombat chip.

https://youtu.be/sCQGRyau40g

This class SerialWombatServo_18AB SerialWombatServo by adding support for a frequency/period setting and by changing the on-chip pin mode to one optimized for high speed servos.

Only Enhanced Digital Capability output pins (0-4,7,9-19) pins can be used for this pin mode.

Up to six High Frequency Servo pins may be assigned per Serial Wombat 18AB Chip. This pin mode claims and holds one of the 6 timing resources also used by PWM output, standard servo output, etc.

This mode creates rapid pulse outputs by using a PWM rather than pulse generation mode. This makes it well suited for fast updates, (200 Hz or better) but a poor choice for driving standard 50Hz servos as it will have worse resolution at low speeds than the standard mode.

The SerialWombatServo and SerialWombatServo_18AB interface void attach(uint8_t pin, bool reverse) is not available in this mode, as it must be explicitly configured for minimum and maximum pulse width.

The pulse update rate can be set with writeFrequency() or writePeriod().

This class uses "attach" rather than "begin" to initialize servos to be consistent with the Arduino Servo native API.

Constructor & Destructor Documentation

◆ SerialWombatHighFrequencyServo()

SerialWombatHighFrequencyServo::SerialWombatHighFrequencyServo ( SerialWombatChip serialWombat)
inline

Member Function Documentation

◆ attach() [1/2]

void SerialWombatHighFrequencyServo::attach ( uint8_t  pin,
bool  reverse 
)

Do not use this interface for High Frequency Servos.

Parameters
pinThe Serial Wombat pin to set. Do not use this interface. Use the one below.
reverseDo not use this interface. Use the one below.

◆ attach() [2/2]

void SerialWombatHighFrequencyServo::attach ( uint8_t  pin,
uint16_t  min,
uint16_t  max,
bool  reverse = false 
)
inline

Initialize a high Speed servo on the specified pin.

This function must be called after the SerialWombatChip instance specified in the constructor has been initialized with a begin call. This function must be followed by a call to writeFrequency() or writePeriod()

Parameters
pinThe Serial Wombat pin to set. The Serial Wombat pin to set. This must be an enhanced capability pin ( WP0-4, WP7, or WP9-19)
minMinimum pulse width in uS.
maxMaximum pulse width in uS. Needs to be less than the value specified after in writePeriod / write Frequency
reverseIf true, the pulse widths will be reversed, with the longest pulse width corresponding to 0 position.

◆ writeFrequency_Hz()

int16_t SerialWombatHighFrequencyServo::writeFrequency_Hz ( uint16_t  frequency_hZ)
inline

◆ writePeriod_uS()

int16_t SerialWombatHighFrequencyServo::writePeriod_uS ( uint16_t  period_uS)
inline