Jump to content

Component: PWM (CAL) (Misc): Difference between revisions

From Flowcode Help
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(One intermediate revision by the same user not shown)
Line 261: Line 261:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
| width="90%" class="mtx-class-propfolder" | Connections
|-
|-
|-
|-
Line 280: Line 280:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Configuration
| width="90%" class="mtx-class-propfolder" | Configuration
|-
|-
|-
|-

Latest revision as of 14:37, 13 July 2026

Author Matrix TSL
Version 2.2
Category Misc


PWM component

CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the Pulse Width Modulation peripheral.

Version information

Library Version, Component Version, Date, Author, Info
10, 2.2, 04-11-24, BR, Added pin caption to the remap port pin selection property
11, 2.2, 04-11-24, BR, Cleaned up pin caption from none remap port pin property
12, 2.2, 08-07-25, BR, Allowed the component to skip over unimplemented PWM channels
12, 2.2, 08-07-25, BR, Added a bubble sort to the Remap Pin property to better present the Port/Pin data
13, 2.2, 18-07-25, BR, Moved bubble sort to a timer to avoid it triggering multiple times

Detailed description

The ChangePeriod macro must be called at least once before calling the Enable macro to configure and start the PWM timer resource.

Examples

No additional examples








Macro reference

ChangeFrequency

ChangeFrequency
Advanced function for the ESP32 hardware to set the PWM output frequency. 
- ULONG Frequency
New PWM desired frequency in Hz 
- VOID Return


ChangePeriod

ChangePeriod
Change the Period (and prescaler) for this PWM Channel 
- UINT period
period value PIC/AVR: 0-255 16-bit PIC: 0-65535 
- UINT prescaler
prescaler 1,4,16,64 
- VOID Return


Disable

Disable
Disable this PWM Channel 
- VOID Return


Enable

Enable
Enable this PWM Channel, note the ChangePeriod macro must be called at least once before calling this function  
- VOID Return


GetList

GetList
Returns CHANNEL or PRESCALE list from the FCD and updates the internal property  
- STRING Name
 
- STRING Return


GetValue

GetValue
Returns Named property Value  
- STRING Name
 
- STRING Return


SetDuty10Bit

SetDuty10Bit
Set the Duty Cycle for this PWM Channel. PIC/AVR - Range: 0-1023 16-bit PIC - Range: 0-65535 
- UINT duty
Duty value 0 - 1023 
- VOID Return


SetDuty8Bit

SetDuty8Bit
Set the Duty cycle (0-255) for this PWM Channel 
- BYTE duty
duty value 0 - 255 
- VOID Return


SetDutyFloat

SetDutyFloat
Advanced function for the ESP32 hardware to set the PWM duty as a percentage between 0.0 and 100.0 
- FLOAT Duty
 
- VOID Return


SetValue

SetValue
Sets the Value of the property PERIOD, PRESCALE or CHANNEL (if CHANNEL also updates the PORT from FCD)  
- STRING Name
 
- STRING Value
 
- VOID Return


Property reference

Properties
Enable
 
Connections
Channel
PWM Channel selector 
Alt Pin Enable
Alternative Pin Enable (if available on target device) 
Port
 
Configuration
Period Register
Allows the user to change the number of counts for the whole PWM period. Note that all PWM channels based on the same timer will share the same period overflow. PIC/AVR Range: 0 - 255 16-bit PIC Range: 0 - 65535 
Prescaler Divide
Allows the user to change the number of program cycles per PWM cycle count. Note that all PWM channels based on the same timer will share the same prescaler. 
PWM Timer
Timer associated with PWM to drive the output. Warning - All PWM channels linked to the same timer will share the same period and prescaler settings. 
Clock Speed
 
Period (uS)
 
Frequency (KHz)
 
Frequency (Hz)
 
Master Divider
 

Component Source Code

Please click here to download the component source project: FC_Comp_Source_PWM.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_PWM.fcfx