You are here

Coding For PSOC creator | Cypress Semiconductor

Coding For PSOC creator

Summary: 138 Replies, Latest post by srim on 05 Sep 2012 10:34 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
user_149977394's picture
User
1 post

I m new to PSOC. SO is there anyone who can help me in writing the coding for the implemantation of the OR gate in PSOC  ceator. The LED glows when the output is one......I really need the coding.........I have assign P0.1 and P0.1 as the input terminals and P0.3  is connected to the LED.

user_66945721's picture
User
256 posts

Hey sinny,welcome to the fascinating world of PSoC ;)

About your query,

To add the OR component:

Goto 'Digital' in the component catalog,and then double click 'Logic' as well,to expand it.The OR Gate component is listed here.Simply drag it into your top design view(the white canvas central in the IDE).

Add 2 Digital Input Pins, and a Digital Output pin the same way.(you'll find these under the 'Ports & Pins' section of the Component catalog.

You should have something of this sort by nw:

Click the second icon from top in the vertical toolbar shown in the image below and wire the components.Heres another pic:

Head over to the configuration section.Access this by double clicking on the .cywdr file in the Workspace Explorer window,and goto the Pins tab in the interface that shows up.Assign them there from the drop down,and its only programming of the kit left from then on.(use F5 to do a build,program and then debug of your project.)

Thats it!

Hope this helps.

U2
uday's picture
Cypress Employee
569 posts

As illustrated in the previous post an OrR gate can be used to implement OR logic. This is completely implemented in hardware. It uses the UDB fabric in PSoC3 to implement this. Note that same thing can be done in code as well. There are plenty of gates and other digital logic(D FLip Flop, Counters, Quadrature deocder and so on) available in the component catalog in PSoC Creator. You can use these to implement complex digital logic.

user_94391782's picture
User
102 posts

 Hi!

I've jst started using PSoC. I have CY8C001 development kit, through which i have to build an application to count negative(or positive) pulses appearing at input. the pulses to be counted have to be above some threshold value and the output is required in cps. How should i start?

user_1377889's picture
User
10803 posts

Welcome in the PSoC society!

Install the PSoC Creator 2.0 Program, sit back and relax, go to the videos webside (selectable from the top of this very page) and look at some of the fundamental procedures to build a project.

then have a look at the datasheets: the comparator, the counters, the Cahracter-LCD-module (hopefully you've got one in your Kit)

Get together the needed APIs, Initialize your hardware and - its done!

 

Happy coding

Bob

dasg's picture
Cypress Employee
730 posts

Hi neha,

 

According to the description of your requirement, you need to continuously count the number of pulses which you receive and express it in counts per second.

Also, the a pulse is to be considered only if it exceeds certain (voltage) threshold.

 

So, this design has 2 requirements.

First, to determine if the signal exceeds the threshold. This can be achieved with the aid of a Comparator along with the threshold reference. This threshold can be an external voltage (external to PSoC), or an internal reference like Voltage DAC (VDAC).

Second requirement is to count the number of pulses in a window of 1 second. This can be achieved with the use of a Counter Component available in PSoC Creator Component Catalog. Also a signal which generates 1 second window is required for this purpose.

dasg's picture
Cypress Employee
730 posts

Implementing these two requirements, the schematic will look as shown below:

 

 

 

Here, the Voltage DAC (VDAC) is used to set the threshold at the inverting input terminal of the comparator. The non-inverting input terminal of the Comparator is connected to the input under observation (Input_Pulse). The output of the comparator is either high or low. This input can then be fed to the Counter's Count terminal for counting.

 

A PWM Component is configured such that it generates pulse with a period of 1 second. The terminal count (tc) of the PWM component generates a pulse every second. This is fed to the Capture input terminal configured as "Rising Edge" triggered.

The Counter is configured as upcounter and the "Reload on Capture" feature is enabled. Hence upon every capture, the present count value is dumped to the FIFO and the counter is reloaded with 0. This will free the user from resetting the counter every second using firmware.

The Interrupt Component (isr_1) is used after configuring the counter to generate an interrupt on Capture. Hence, the user can read the captured value in firmware and use the value thus obtained. This value can be displayed on a Character LCD.

user_1377889's picture
User
10803 posts

@dasq: The length of the window to count may be any other length, not only one second. You'll have just to re-calculate the sps value. This is especially required when the frequency to count is near or even below 1 Hz.

Happy counting

Bob

dasg's picture
Cypress Employee
730 posts

That's absolutely right, Bob!

When the input pulse frequency is less than 1Hz, we may have to use a larger window and appropriately scale down the result.

On the other hand, if the input frequency is very high, updating the counts every 1 sec might be too long (depending upon the user requirement). Using smaller window and updating the counts/sec more frequently is also aother option.

dasg's picture
Cypress Employee
730 posts

Another technique to measure the frequency of the pulse is to measure its time interval.

This thread discusses the technique mentioned above.

user_94391782's picture
User
102 posts

Thnx Bob, thnx dasg!!! 

I've got some valuable help. The aim of the project is to embibe as many features in the chip as possible.

I'll try to take reference frm VDAC then. Actually these pulses are output of some detector , a completely random process (rather poissons' distribution is followed). 

is it possible that i initially generate TTL pulses through software at random intervals and count them in the absence of detector ?   

Log in to post new comments.