Generate pulse width modulated signal on analog output pin
Simulink Support Package for Arduino Hardware / Common
The PWM block generates square pulses of varying duty cycle depending on the input value sent to the block on the Arduino® hardware pin. This block enables a digital output to provide a range of different power levels, similar to that of an analog output.
For more information on how to select pins when you Simulink® model contains PWM, Standard Servo Read, Standard Servo Write, Continuous Servo Write, and Input Capture blocks, see Conflicting Pin Configurations on Arduino Timer.
If you use the PWM block along with the Serial Receive and Serial Transmit blocks in a Simulink model, use longer sample times to avoid overruns.
This table specifies the upper limit of the output frequency that can be generated on the digital pins of the following Arduino boards.
| Arduino Board Type | Arduino Pin Number | Generated PWM Output Frequencies (Hz) |
|---|---|---|
| Uno, Nano 3.0 | 5, 6 | 980.4 |
3, 11 | 31372.55, 3921.16,
980.4, 490.2,
245.1, 122.55,
30.64 | |
| Mega 2560/ADK | 4, 13 | 980.4 |
9, 10 | 31372.55, 3921.16,
980.4, 490.2,
245.1, 122.55,
30.64 | |
| Leonardo, Robot Control Board, Robot Motor Board, Micro | 3, 11 | 980.4 |
Conflicting Pin Configurations on Arduino Timer | Continous Servo Write | Install Support for Arduino Hardware | Model Configuration Parameters for Simulink Support Package for Arduino Hardware | Pin Mapping for Arduino Timer Dependent Blocks | Standard Servo Read | Standard Servo Write