# Cypress Developer CommunityTM

## how to generate a square wave of frequency 50 Hz using PSOC3

Summary: 21 Replies, Latest post by danaaknight on 08 Aug 2012 07:50 AM PDT
User
9 posts

It should have an amplitude of 5V.

Im doing project on PSOC plz help me continue my work.humble request...

plz help me..

Cypress Employee
569 posts

It is possible to generate square pulses using PWM or Counter/Timer component. This example project should help you do the same. Note that the amplitude of the square wvae is dependent on the voltage at which the I/O system is working. In PSoC3 the I/O system is divided into 4 quadrants and each quadrant has it's own supply pin. VDDIO0, VDDIO1,VDDIO2,VDDIO3. Hence to get an amplitude of 5Volt the VDDIO that corresponds this particular pin needs to be connected to 5V(any desirable voltage).

Cypress Employee
569 posts

This example project should get you started,

User
26 posts

Hi,

Is it possible to produce 50 Hz with this.

User
26 posts

Hi,

Is it possible to produce 50Hz using this work. What modifications are required.

Cypress Employee
569 posts

Yes, it is possible to generate a 50 hz signal by modifying this project. The project as such has a 1Mhz clock connected to the PWM component. Change this clock to 100 Khz by double clicking the component. Now double click the PWM component, in the configuration GUI, set Period as 19 to give a time period of 20ms. This gives a square wave of frequency 50 hz. The dutycycle is determined by the compare value. To get 50 % duty cylcle set the "compare value 1" parameter to 9.

User
26 posts

Thank u

User
26 posts

hai U2,

I need an out of phase square wave too,in order to drive the inverter circuit.

I have used Look Up Table (LUT) block to invert the present 50Hz square wave.

Actually the square wave is inverted but not having the same amplitude.

What shud I do to obtain same amplitude ,infact I can do using external circuit ; but I need to know that is it possible with PSOC itself.

Plz help.

Cypress Employee
730 posts

Hi Deeps,

You can easily get the inverted square wave by connecting a NOT gate (from Logic category of component catalog).

You can connect the NOT gate in parallel with the PWM output and connect it with an output pin which is configured to 'Strong Drive' mode.

If the corresponding Vddio is connected to 5V, then the output will remain at 5V.

User
26 posts

hi dasq,

I have used the NOT block, but it was unsuccessful.

Cypress Employee
569 posts

There is another way of doing this, Double click the PWM component to configure its parameters. In the UDB implementation, the PWM component is capable of generating two PWM outputs, PWM1, PWM2. Set the PWM mode to generate two outputs. Set "compare Type1" to "Less than or Equal" and "Compare Type 2" to "Greater than or Equal" or the otherway round. This way the two PWM outputs are out of phase. Picture attached illustrates the same. Connect the two PWM outputs to Pins that have same VDDIO to ensure that they have same amplitude.

Attachments: