#include <PWM.h>
Public Member Functions | |
PWM (unsigned channel) | |
PWM (unsigned slot, unsigned channel) | |
virtual | ~PWM () |
void | SetRaw (unsigned char value) |
unsigned char | GetRaw (void) |
void | SetPeriodMultiplier (PeriodMultiplier mult) |
Protected Member Functions | |
void | SetMaxPositivePwm (int maxPositivePwm) |
The maximum raw PWM value for forward direction. | |
void | SetMinPositivePwm (int minPositivePwm) |
The minimum raw PWM value for forward direction. | |
void | SetCenterPwm (int centerPwm) |
The raw PWM value that represents idle. | |
void | SetMaxNegativePwm (int maxNegativePwm) |
The maximum raw PWM value for reverse direction. | |
void | SetMinNegativePwm (int minNegativePwm) |
The minimum raw PWM value for reverse direction. | |
void | SetPosition (float pos) |
float | GetPosition (void) |
void | SetSpeed (float speed) |
float | GetSpeed (void) |
Static Protected Attributes | |
static const unsigned | kDefaultPwmPeriod = 766 |
static const unsigned | kDefaultMinPwmHigh = 103 |
As of revision 0.1.4 of the FPGA, the FPGA interprets the 0-255 values as follows: 255 = full "forward" 254 to 129 = linear scaling from "full forward" to "center" 128 = center value 127 to 2 = linear scaling from "center" to "full reverse" 1 = full "reverse" 0 = disabled (i.e. PWM output is held low)
PWM::PWM | ( | unsigned | channel | ) |
PWM::PWM | ( | unsigned | slot, | |
unsigned | channel | |||
) |
PWM::~PWM | ( | ) | [virtual] |
void PWM::SetRaw | ( | unsigned char | value | ) |
unsigned char PWM::GetRaw | ( | void | ) |
void PWM::SetPeriodMultiplier | ( | PeriodMultiplier | mult | ) |
Slow down the PWM signal for old devices.
mult | The period multiplier to apply to this channel |
void PWM::SetPosition | ( | float | pos | ) | [protected] |
Set the PWM value based on a position.
This is intended to be used by servos.
SetMinNegativePwm() called.
pos | The position to set the servo between 0.0 and 1.0. |
float PWM::GetPosition | ( | void | ) | [protected] |
Get the PWM value in terms of a position.
This is intended to be used by servos.
SetMinNegativePwm() called.
void PWM::SetSpeed | ( | float | speed | ) | [protected] |
Set the PWM value based on a speed.
This is intended to be used by speed controllers.
SetMinPositivePwm() called.
SetCenterPwm() called.
SetMaxNegativePwm() called.
SetMinNegativePwm() called.
speed | The speed to set the speed controller between -1.0 and 1.0. |
float PWM::GetSpeed | ( | void | ) | [protected] |
Get the PWM value in terms of speed.
This is intended to be used by speed controllers.
SetMinPositivePwm() called.
SetMaxNegativePwm() called.
SetMinNegativePwm() called.
const unsigned PWM::kDefaultPwmPeriod = 766 [static, protected] |
kDefaultPwmPeriod is "ticks" where each tick is 6.525us 20ms periods (50 Hz) are the "safest" setting in that this works for all devices 20ms periods seem to be desirable for Vex Motors 20ms periods are the specified period for HS-322HD servos, but work reliably down to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot; by 5.0ms the hum is nearly continuous 10ms periods work well for Victor 884 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers
This is the 1x period (5ms). In hardware, the period scaling is implemented as an output squelch to get longer periods for old devices. Set to 5 ms period / 6.525us clock = 766
const unsigned PWM::kDefaultMinPwmHigh = 103 [static, protected] |
kDefaultMinPwmHigh is "ticks" where each tick is 6.525us There are 127 pwm values less than the center, so... The minimum output pulse length is 1.5ms - 127 * 6.525us = 0.671ms 0.671ms / 6.525us per tick = 103