Creating a Project with PSoC Designer

Creating a Project with PSoC Designer
PSoC Designer™ is two tools in one. It combines a full featured integrated development environment
(IDE) with a powerful visual programming interface. The two tools require and support two different
design processes.
In the Chip-Level view you specify exactly how
you want the device configured. This allows you
direct access to all of the features of your PSoC
device and complete control over the routing,
system resource use, and firmware development:
In System Level view you have a visual
programming interface configures the PSoC
device and writes the low level firmware for you:
Step 1: Create a new project
Step 1:
Create a new project
Step 2: Choose a base device to work with.
Step 2:
Select the inputs and outputs
Step 3: Choose and configure user modules that
give the PSoC device the functionality
you need.
Step 3:
Step 4: Connect the user modules to each other
and to the proper pins.
Step 4:
Simulate and verify your design
Step 5:
Build the program
Step 6:
Step 5: Write firmware for your project in C or
assembly language.
Define the behavior of the inputs and
Program the PSoC device and test the
Step 6: Program the PSoC device and test the
You must choose one of the two design methods to start with when you create a project. You can
start in the System-Level view and switch to Chip-Level view, but the converse is not true. The project
structure necessary to support the System-Level view is not created for Chip-Level Projects. Both of
the interfaces share a common code editor, builder, debug, emulation, and programming tools.
This tutorial guides you through a small project that you can program on one of the PSoC evaluation
boards such as the CY3210-PSoCEval1. The project reads the voltage from a potentiometer and sets
the LED to off, on, or blinking depending on the voltage level. You can choose to do the project in the
Chip-Level view or the System-Level view. When you are finished with the tutorial you will be familiar
with the entire design process.
Step 1: Create a New Project
In PSoC Designer 5, you create a new project for your new design before you begin to design.
Click the File menu and select New Project.
In the Project types box, choose a Chip-Level Project for complete control of the project, or
choose an System-Level Editor Project for rapid development. Choose any desired name for
the project and click OK.
Depending on your choice above, select a link below to continue with the tutorial.
Chip-Level Project
System-Level Project
Return to Top
Step 2: Select the Inputs and Outputs
PSoC Designer’s System-Level view has a catalog of devices that can be used to acquire real-world
inputs such as temperature, voltage, and switch state and devices that can be used in real-world
output functions such as fan speed commands, relay closure/opening, and LED lighting. These
devices are known as drivers.
There are four types of drivers; input, output, valuators, and interfaces, each type with its own tab in
the Driver Catalog.
To add an input driver, click the Inputs tab at the bottom of the Driver Catalog window. If you do
not see the Driver Catalog window, choose Driver Catalog from the View menu.
Open the Voltage Input folder, then the DC folder and select a DC “0.000 to 5.000 V” input and
drag it on to the design window. The Add Input Driver dialog displays.
Change the Name to Voltage. Click OK.
Figure 1. Voltage Driver
Now, click the Outputs tab. The output driver section of the driver catalog will open.
Select Display, then LED, Single Color, and finally On/Off with blink. Drag it on to your design
and name it IndicatorLED using the process described above.
The Add Output Driver dialog contains properties that can be set for this driver. Sometimes there
are read only properties shown in gray. All of the properties shown here are black to show that
you can set the value.
Select OFF for the Initial Value.
Select 2 for the BlinkRate.
Leave the Current Mode at its default value (Sourcing). Click OK.
Figure 2. LED Driver
Return to top
Step 3: Define Input/Output Behavior
Once you have the inputs and outputs defined, the next step is to define how the system outputs will
behave as a result of inputs. A Transfer Function is the name given to the method of defining this
behavior in PSoC Designer. A PSoC Designer output can have several transfer function types. See
the IDE Guide (Help -> Documentation) for details on the types and uses of transfer functions.
Right click the IndicatorLED output and select Transfer Function from the popup menu.
Select PriorityEncoder, and click the OK button. The Priority Encoder Transfer Function
definition screen shows up (see Figure 3). When you start typing in the if and then boxes, PSoC
Express will automatically complete parts of your entry to aid you with creating valid expressions.
In addition, some of the auto complete entries will have tool tips.
Select Voltage from the list and a tool tip will indicate that a scaling factor of 1000 has been
applied to Voltage so 5 volts is represented as 5000.
Figure 3. Priority Encoder Transfer Function
Click on the if box of the priority encoder.
Begin typing a V, select Voltage, and then type in < 1500.
Click on the then IndicatorLED = box of the priority encoder, and begin typing an I.
Select IndicatorLED__OFF.
Press [Enter] in the then box. A second row appears in the priority encoder.
Use this same process to enter two more rows:
if Voltage<3000 then IndicatorLED = IndicatorLED__BLINKING
if 1 then IndicatorLED = IndicatorLED__ON
10. Note that the voltage values used were 1500 and 3000. Because the scaling factor associated
with Voltage is 1000, these correspond to 1.5 volts and 3 volts respectively. Note also that the
last if expression entered was 1. This is used as a catch-all case. If none of the other previous if
statements were satisfied then this if statement is satisfied, and its then expression will set the
output value.
11. Click OK.
A red line is now drawn between the Voltage input driver and the IndicatorLED output driver
indicating that the output has a dependency on the input.
12. From the File menu, select Save.
Return to top
Step 4: Simulate and Verify Your Design
Based on the behavior specified in step 2, we expect the LED to be off if the input voltage is less than
1.5 volts, we expect the LED to be blinking if the voltage is between 1.5 volts (inclusive) and 3 volts
(exclusive), and we expect the LED to be on if the voltage is at or above 3 volts. PSoC Express
provides simulation capability to prove this out.
To simulate the Voltage Monitor example:
Click the Simulation tab at the top of the screen.
A slider widget appears next to the Voltage icon, and a Current Value box widget appears next to
the IndicatorLED icon.
Slide the slider to approximately 1 V. The LED widget should indicate a value of 0 (Off).
Slide the slider to approximately 2 V. The LED widget should indicate a value of 2 (Blinking).
Slide the slider to approximately 4 V. The LED widget should indicate a value of 1 (On).
If the behavior meets your expectations, you are ready for the next step. If not, you can go back to
the Design tab, make some changes to your design, and return to Simulation to verify your changes.
Return to top
Step 5: Build the Program
You selected the inputs and outputs, defined the system behavior, and verified it through simulation.
Now, you are ready to put your design into target hardware. PSoC Express is ready too, waiting for
your command to build a program file for the right-size PSoC device based upon your design.
Choose Generate/Build Project from the Build menu.
The PSoC Device Configuration Selection screen appears. This screen allows you to choose
your desired PSoC device along with some system options that include defining system voltage
and program loop update rate (the behaviors defined in the design are translated into a loop that
runs periodically). Only PSoC configurations that will meet the input/output requirements of your
design are shown. They are listed in order from least expensive to most expensive.
Figure 4. PSoC Device Configuration Selection
Choose the PSoC chip that you have available in your evaluation kit (most likely the
Select “5.0V” from the Supply Voltage dropdown list.
Select “64Hz” from the Sample Rate dropdown list.
Click the Next button.
PSoC Express will automatically assign the drivers to pins on the selected chip. This window
shows a chip footprint, and indicates pins assigned to drivers in dark blue. Unassigned pins are
light blue, and pins that cannot be used for input or output are white.
Depending on the evaluation kit you have, you may want to reassign the pins in order to test the
program. If so, you can manually reassign any pin. Drag the blue rectangle associated with an
input/output driver off the top of the pin. As you drag, you will see that that one or more pins on
the footprint are highlighted in green. The green highlighting indicates that those pins will accept
the driver that you are assigning. Drop the blue rectangle on any one of these pins.
After all input/output drivers have been assigned to pins, click the Next button.
PSoC Designer now converts the system design into microcontroller code and stores it in a .HEX
file. Upon completion, PSoC Designer also shows the resulting pin assignments along with
hypertext links to a bill of materials, a datasheet, and a schematic that have been custom created
for your design.
Return to top
You are now ready to program your PSoC device. Programming the PSoC device is exactly the same
regardless of which of the design methods you choose. Click the link below to go to the last section of
the tutorial.
Program Your PSoC Device