A CHIP IO library for Python: IO+PWM+SPWM+ADC+Utilities
Import the SOFTPWM module as follows
import CHIP_IO.SOFTPWM as SPWM
Enable/Disable the Debug
Parameters
None
Examples
SPWM.toggle_debug()
Function to report to the calling script if the SBC is a CHIP or a CHIP Pro
Parameters
None
Returns
int - 1 for CHIP Pro, 0 for CHIP
Examples
is_chip_pro = SPWM.is_chip_pro()
Start the Software PWM
Parameters
channel - pin for software PWM is configured duty_cycle - initial duty cycle of the PWM (optional) frequency - frequency of the PWM (optional) polarity - signal polarity of the PWM (optional)
Returns
None
Examples
SPWM.start("CSID0")
SPWM.start("CSID0", 37.0)
SPWM.start("CSID0", 10.0, 500.0)
SPWM.start("CSID0", 50.0, 1000.0, 1)
Stop the Software PWM
Parameters
channel - pin software PWM is configured
Returns
None
Examples
SPWM.stop("CSID0")
Set the duty cycle of the Software PWM
Parameters
channel - pin software PWM is configured duty_cycle - duty cycle of the PWM (0.0 to 100.0)
Returns
None
Examples
SPWM.set_duty_cycle("CSID0", 25.0)
Set the frequency of the Software PWM in Hertz
Parameters
channel - pin PWM is configured frequency - frequency of the PWM
Returns
None
Examples
SPWM.set_frequency("CSID0", 450.0)
Cleanup Software PWM. If not channel input, all Software PWM will be cleaned up
Parameters
channel - pin Software PWM is configured (optional)
Returns
None
Examples
SPWM.cleanup()
SPWM.cleanup("CSID0")