3.5.03 MC_PWM
Version 2.1 by xingzhi lin on 2025/12/03 23:05
Instruction format
| Instruction | MC_PWM (FB) | |
| Name | Pulse width modulation | |
| Graphical performance | ST performance | |
![]()
| MC_PWM( Enable: = OutputPort: = PulsePeriod: = PulseWidth: = InVelocity=>, Busy=>, Error=>, ErrorID=>); | |
Related variables
| Input variables | Name | Data type | Effective range | Initial value | Description |
| Enable | Enable | BOOL | [FALSE, TRUE] | FALSE | Level trigger |
| OutputPort | Pulse output port | BYTE | [0, 2, 4, 6] | 0 | PWM output port, support D0, D2, D4, D6 only |
| PulsePeriod | Pulse width | UINT | [0,65535] | 0 | Period: The width of the complete square wave. Unit: 1us |
| PulseWidth | High-level pulse width | UINT | [0,65535] | 0 | The width of the high level of the square wave. Unit: 1us |
| Output variables | Name | Data type | Effective range | Initial value | Description |
| InVelocity | Reaching set value flag | BOOL | [FALSE, TRUE] | FALSE | The pulse width frequency reaches the set value. |
| Busy | Execution flag | BOOL | [FALSE, TRUE] | FALSE | Execute output PWM square wave. |
| Error | Error flag | BOOL | [FALSE, TRUE] | FALSE | TRUE when an error occurred inside the function block. |
| ErrorID | Error ID | MC_ERROR | - | MC_NO_ERROR | Error ID, refer to MC_ERROR. |
Function description
(1) This function block realizes dynamic pulse width modulation;
(2) After D0/D2/D4/D6 is configured as PWM function, control of D0 + D1/ D2 + D3/ D4 + D5 /D6 + D7 outputs is not allowed, during the execution of MC_PWM function block.
Sequence diagram


