PWM (Pulse Width Modulation)
This function block generates an artificial pulse-width-modulated boolean signal you can use to simulate or drive timed triggers. Use it to create repeating on/off signals either by time (seconds) or by sample counts (discrete steps).
π₯ Inputs
This function block does not have any inputs.
π€ Outputs
Boolean The periodic True/False signal produced according to the configured mode and timings.
πΉοΈ Controls
Interval Enter the total period of one cycle. In Time mode this is in seconds. In Sample mode this is in number of samples/steps.
Up Duration Enter how long the output stays True within each cycle. Units match the selected mode (seconds or samples).
Time mode Toggle between Seconds (time-based mode) and Samples (sample-count mode).
π¨ Features
Time-based PWM mode for real-time periodic signals.
Sample-based PWM mode for step-driven or frame-synchronized signals.
Adjustable duty cycle via
IntervalandUp Durationcontrols.Simple boolean output that is easy to combine with logic and output blocks.
π Usage Instructions
Choose the operating mode with
Time mode.Set
Intervalto define the full cycle length.Set
Up Durationto define the active (True) portion of each cycle. EnsureUp Durationis less than or equal toInterval.Connect the
Booleanoutput to any block that consumes a check / boolean signal (for exampleLed Outputto visualize, or logic blocks to gate other behaviors).
π Evaluation
At runtime the block produces a repeated True/False pattern. In Time mode the pattern follows real seconds. In Sample mode the pattern advances with each run/step. The output duty cycle equals (Up Duration Γ· Interval).
π‘ Tips and Tricks
Visualize the signal using
Scopeto verify timing and duty cycle in real time.Use
Rising Edgeto detect transitions and trigger single-shot actions on the leading edge.Count pulses with
Counterto measure occurrences or drive batch operations.Combine with
AndorOrto gate the PWM signal with other conditions (for example a manualLogic Input).Use
Delay Step,ON DelayorOFF Delayblocks to shape or debounce transitions.Persist or freeze signals with
Data Memorywhen you need a stable value between updates.
π οΈ Troubleshooting
Output always True or always False
Check that
Up DurationandIntervalare set correctly and that the selectedTime modematches your expected units (seconds vs samples).
Timing seems off in Time mode
Verify that the host system clock is running and that other blocks are not blocking execution. Use
Scopeto confirm real timings.
Sample mode does not advance as expected
Ensure the system is producing steps/samples (the run loop or upstream blocks must provide iterations). Use
CounterorCycle Timerto inspect step progress.
Last updated
Was this helpful?