void SetPwmParameters(int channel, Eth32PwmChannel state, double freq, double duty)
This method is provided for your convenience in working with all of the various PWM settings. It allows you to specify the PWM frequency and the duty cycle of a channel in more familiar terms (hertz and percentage) rather than PWM clock counts. It also puts the appropriate I/O pin into output mode unless you specify that the PWM channel should be disabled. This method internally calls several other API functions to set everything up, therefore replacing calls to PwmBasePeriod Property, PwmDutyPeriod Property, PwmClockState Property, PwmChannel Property, and SetDirectionBit Method with a single call to this method.
channel - Specifies the PWM channel number (0 or 1).
state - This property is a Eth32PwmChannel enumerator type, which has the following valid values:
Eth32PwmChannel.Disabled - The PWM pin will function as a normal digital I/O pin.
Eth32PwmChannel.Normal - The PWM pin will function as a PWM output. It will be high for the time specified by the duty period and low for the rest of the PWM base period.
Eth32PwmChannel.Inverted - The PWM pin will function as a PWM output. It will be low for the time specified by the duty period and high for the rest of the PWM base period.
freq - Specifies the frequency in Hertz. The valid range is 30.5 HZ to 40,000 HZ (40 KHZ)
duty - Specifies the duty cycle as a percentage (A floating point number from 0.0 to 1.0). This specifies the percentage of each cycle that the channel will be active.
Note that this method uses the PwmBasePeriod Property to set the PWM base period. Because the PWM base period is shared between both PWM channels, this will affect the other PWM channel if you specify a frequency different than what is already in effect.
Eth32 dev = new Eth32(); try { // .... Your code that establishes a connection here // Set up PWM channel 0 to have a 10 KHZ, 60% PWM signal: dev.SetPwmParameters(0, Eth32PwmChannel.Normal, 10000, 0.60); } catch (Eth32Exception e) { // Handle Eth32 errors here }