Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Motor_Control_using_lib Motor_Control_API
PwmOutResetSync Class Reference
A pulse-width modulation digital output. More...
#include <PwmOutResetSync.h>
Public Member Functions | |
| PwmOutResetSync (PinName pin) | |
| Create a PwmOutResetSync connected to the specified pin. | |
| virtual | ~PwmOutResetSync () |
| Destructor. | |
| void | write (float value) |
| Set the ouput duty-cycle, specified as a percentage (float) | |
| float | read () |
| Return the current output duty-cycle setting, measured as a percentage (float) | |
| void | pulsewidth (float seconds) |
| Set the PWM pulsewidth, specified in seconds (float), keeping the period the same. | |
| void | pulsewidth_ms (int ms) |
| Set the PWM pulsewidth, specified in milli-seconds (int), keeping the period the same. | |
| void | pulsewidth_us (int us) |
| Set the PWM pulsewidth, specified in micro-seconds (int), keeping the period the same. | |
| PwmOutResetSync & | operator= (float value) |
| A operator shorthand for write() | |
| operator float () | |
| An operator shorthand for read() | |
Static Public Member Functions | |
| static void | period (float seconds) |
| Set the PWM period, specified in seconds (float), keeping the duty cycle the same. | |
| static void | period_ms (int ms) |
| Set the PWM period, specified in milli-seconds (int), keeping the duty cycle the same. | |
| static void | period_us (int us) |
| Set the PWM period, specified in micro-seconds (int), keeping the duty cycle the same. | |
Detailed Description
A pulse-width modulation digital output.
Example
// Moter Control. #include "mbed.h" #include "PwmOutResetSync.h" PwmOutResetSync pwm_l(P4_4); PwmOutResetSync pwm_r(P4_5); int main() { while(1) { pwm_l = 0.5; pwm_r = 0.5; wait(1); pwm_l = 0.0; pwm_r = 0.8; wait(1); } }
- Note:
- The PWMs all share the same period - if you change the period for one, you change it for all. Routines that change the period maintain the duty cycle for its PWM.
Definition at line 40 of file PwmOutResetSync.h.
Constructor & Destructor Documentation
| PwmOutResetSync | ( | PinName | pin ) |
Create a PwmOutResetSync connected to the specified pin.
- Parameters:
-
pin PwmOutResetSync pin to connect to
- Attention:
- Output Pins for Reset-Synchronized PWM Mode. [TIOC3B : P8_11, (P7_9), (P3_5)], [TIOC4A : P3_8, P4_4, (P7_12), (P11_0)], [TIOC4B : P3_9, P4_5, (P7_13), (P11_1)] ():On the GR-PEACH, it can not be used.
Definition at line 56 of file PwmOutResetSync.h.
| virtual ~PwmOutResetSync | ( | ) | [virtual] |
Destructor.
Definition at line 63 of file PwmOutResetSync.h.
Member Function Documentation
| operator float | ( | ) |
An operator shorthand for read()
Definition at line 155 of file PwmOutResetSync.h.
| PwmOutResetSync& operator= | ( | float | value ) |
A operator shorthand for write()
Definition at line 143 of file PwmOutResetSync.h.
| static void period | ( | float | seconds ) | [static] |
Set the PWM period, specified in seconds (float), keeping the duty cycle the same.
- Parameters:
-
seconds Specified in seconds (float). The maximum period is 2s. When you set a number greater than 2s, 2s is set.
- Note:
- The resolution is currently in microseconds; periods smaller than this will be set to zero.
Definition at line 101 of file PwmOutResetSync.h.
| static void period_ms | ( | int | ms ) | [static] |
Set the PWM period, specified in milli-seconds (int), keeping the duty cycle the same.
- Parameters:
-
seconds Specified in milli-seconds (int). The maximum period is 2s. When you set a number greater than 2s, 2s is set.
Definition at line 110 of file PwmOutResetSync.h.
| static void period_us | ( | int | us ) | [static] |
Set the PWM period, specified in micro-seconds (int), keeping the duty cycle the same.
- Parameters:
-
seconds Specified in micro-seconds (int). The maximum period is 2s. When you set a number greater than 2s, 2s is set.
Definition at line 119 of file PwmOutResetSync.h.
| void pulsewidth | ( | float | seconds ) |
Set the PWM pulsewidth, specified in seconds (float), keeping the period the same.
Definition at line 125 of file PwmOutResetSync.h.
| void pulsewidth_ms | ( | int | ms ) |
Set the PWM pulsewidth, specified in milli-seconds (int), keeping the period the same.
Definition at line 131 of file PwmOutResetSync.h.
| void pulsewidth_us | ( | int | us ) |
Set the PWM pulsewidth, specified in micro-seconds (int), keeping the period the same.
Definition at line 137 of file PwmOutResetSync.h.
| float read | ( | ) |
Return the current output duty-cycle setting, measured as a percentage (float)
- Returns:
- A floating-point value representing the current duty-cycle being output on the pin, measured as a percentage. The returned value will lie between 0.0f (representing on 0%) and 1.0f (representing on 100%).
- Note:
- This value may not match exactly the value set by a previous <write>.
Definition at line 88 of file PwmOutResetSync.h.
| void write | ( | float | value ) |
Set the ouput duty-cycle, specified as a percentage (float)
- Parameters:
-
value A floating-point value representing the output duty-cycle, specified as a percentage. The value should lie between 0.0f (representing on 0%) and 1.0f (representing on 100%). Values outside this range will be saturated to 0.0f or 1.0f.
Definition at line 74 of file PwmOutResetSync.h.
Generated on Tue Jul 12 2022 14:35:42 by
1.7.2