4 Replies Latest reply on Sep 20, 2017 7:44 AM by rodolfog_11

# How to generate PWM for 5 different voltage steps(or, duty cycles) in PSoC 4 CY8CKIT-042-BLE?

I am new on PSoC and I wanted to know how to generate PWM for 5 different voltage steps { like 20,40,60,80,100} (or, duty cycles) in PSoC 4 CY8CKIT-042-BLE?, I am using a 10KHz clock cycle, 16-bit resolution with a period of 10000 on a 16-bit UDB PWM

• ###### 1. Re: How to generate PWM for 5 different voltage steps(or, duty cycles) in PSoC 4 CY8CKIT-042-BLE?

The duty cycle is (period / compare) * 100 in percent. So modifying the compare value only between 0 and 10000 will give you any value you need. There is an API to set the compare value.

Imho the input frequency should be a bit higher. As for now your period is 1s which seems quite too slow. I would suggest setting the input freq to 10MHz.

Bob

• ###### 2. Re: How to generate PWM for 5 different voltage steps(or, duty cycles) in PSoC 4 CY8CKIT-042-BLE?

Can we generate 5 different duty cycles on single PWM? How?

• ###### 3. Re: How to generate PWM for 5 different voltage steps(or, duty cycles) in PSoC 4 CY8CKIT-042-BLE?

Can we generate 5 different duty cycles on single PWM? How?

• ###### 4. Re: How to generate PWM for 5 different voltage steps(or, duty cycles) in PSoC 4 CY8CKIT-042-BLE?

You might want to use an RC circuit outside of the PSoC to convert a digital wave signal to an analog signal.

The RC circuit would filter the high frequency of the PWM, providing an almost constant voltage (you would see some small ripple, depending how big is the capacitor of the RC circuit).

If the PWM VDDIO is 3.3 V, you would get:

100% Duty Cycle -> 3.3 V

50% Duty Cycle ~ 1.65 V

0% Duty Cycle -> 0.0 V

You can refer to the Trim/Margin component in the Cypress Catalog. They use this technique to control power regulators.