Vous êtes sur la page 1sur 5

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 In System Level view you have a visual
you want the device configured. This allows you programming interface configures the PSoC
direct access to all of the features of your PSoC device and writes the low level firmware for you:
device and complete control over the routing,
system resource use, and firmware development:

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 Step 3: Define the behavior of the inputs and
give the PSoC device the functionality outputs
you need.
Step 4: Simulate and verify your design
Step 4: Connect the user modules to each other
Step 5: Build the program
and to the proper pins.
Step 6: Program the PSoC device and test the
Step 5: Write firmware for your project in C or
program
assembly language.
Step 6: Program the PSoC device and test the
program
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.
1. Click the File menu and select New Project.
2. 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.
1. 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.
2. 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.
3. 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.
5. 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.
6. Select OFF for the Initial Value.
7. Select 2 for the BlinkRate.
8. 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.
1. Right click the IndicatorLED output and select Transfer Function from the popup menu.
2. 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.
3. 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

4. Click on the if box of the priority encoder.


5. Begin typing a V, select Voltage, and then type in < 1500.
6. Click on the then IndicatorLED = box of the priority encoder, and begin typing an I.
7. Select IndicatorLED__OFF.
8. Press [Enter] in the then box. A second row appears in the priority encoder.
9. Use this same process to enter two more rows:
a. if Voltage<3000 then IndicatorLED = IndicatorLED__BLINKING
b. 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:
1. 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.
2. Slide the slider to approximately 1 V. The LED widget should indicate a value of 0 (Off).
3. Slide the slider to approximately 2 V. The LED widget should indicate a value of 2 (Blinking).
4. 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.
1. 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

2. Choose the PSoC chip that you have available in your evaluation kit (most likely the
CY8C27443).
3. Select “5.0V” from the Supply Voltage dropdown list.
4. Select “64Hz” from the Sample Rate dropdown list.
5. 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.
6. 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
 

Vous aimerez peut-être aussi