WPILibC++  2018.4.1-20180819221726-1160-g6df500e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
PWM.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include <hal/Types.h>
13 
14 #include "frc/ErrorBase.h"
15 #include "frc/smartdashboard/SendableBase.h"
16 
17 namespace frc {
18 
36 class PWM : public ErrorBase, public SendableBase {
37  public:
54  };
55 
66  explicit PWM(int channel);
67 
73  ~PWM() override;
74 
82  virtual void SetRaw(uint16_t value);
83 
91  virtual uint16_t GetRaw() const;
92 
103  virtual void SetPosition(double pos);
104 
115  virtual double GetPosition() const;
116 
130  virtual void SetSpeed(double speed);
131 
144  virtual double GetSpeed() const;
145 
150  virtual void SetDisabled();
151 
158 
159  void SetZeroLatch();
160 
169  void EnableDeadbandElimination(bool eliminateDeadband);
170 
184  void SetBounds(double max, double deadbandMax, double center,
185  double deadbandMin, double min);
186 
200  void SetRawBounds(int max, int deadbandMax, int center, int deadbandMin,
201  int min);
202 
216  void GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
217  int32_t* deadbandMin, int32_t* min);
218 
219  int GetChannel() const;
220 
221  protected:
222  void InitSendable(SendableBuilder& builder) override;
223 
224  private:
225  int m_channel;
226  HAL_DigitalHandle m_handle;
227 };
228 
229 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void SetBounds(double max, double deadbandMax, double center, double deadbandMin, double min)
Set the bounds on the PWM pulse widths.
virtual void SetPosition(double pos)
Set the PWM value based on a position.
PeriodMultiplier
Represents the amount to multiply the minimum servo-pulse pwm period by.
Definition: PWM.h:41
Skip every other pulse.
Definition: PWM.h:49
Skip three out of four pulses.
Definition: PWM.h:53
void EnableDeadbandElimination(bool eliminateDeadband)
Optionally eliminate the deadband from a speed controller.
virtual void SetSpeed(double speed)
Set the PWM value based on a speed.
Don't skip pulses.
Definition: PWM.h:45
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
void GetRawBounds(int32_t *max, int32_t *deadbandMax, int32_t *center, int32_t *deadbandMin, int32_t *min)
Get the bounds on the PWM values.
void SetRawBounds(int max, int deadbandMax, int center, int deadbandMin, int min)
Set the bounds on the PWM values.
PWM(int channel)
Allocate a PWM given a channel number.
void SetPeriodMultiplier(PeriodMultiplier mult)
Slow down the PWM signal for old devices.
virtual void SetDisabled()
Temporarily disables the PWM output.
Base class for most objects.
Definition: ErrorBase.h:74
virtual void SetRaw(uint16_t value)
Set the PWM value directly to the hardware.
Definition: SendableBase.h:19
virtual double GetSpeed() const
Get the PWM value in terms of speed.
virtual uint16_t GetRaw() const
Get the PWM value directly from the hardware.
virtual double GetPosition() const
Get the PWM value in terms of a position.
Definition: SendableBuilder.h:23
~PWM() override
Free the PWM channel.
Class implements the PWM generation in the FPGA.
Definition: PWM.h:36