Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by
and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty
provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create
derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, transla tion, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described
herein. Cypress does not assume any liability arising out of the applica tion or use of any product or circuit described herein.
Cypress does not authorize its products for use as critical components in life-support systems whe re a malfunction or failure
may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all
charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
®
PSoC Designer™ and Programmable System-on-Chip™ are trademarks and PSoC
is a registered trademark of Cypress
Semiconductor Corp. All other trademarks or registered trademarks referenced herein are property of the respective corporations.
Flash Code Protection
Cypress products meet the specifications contained in their particular Cypress PSoC Data Sheets. Cypress believes that its
family of PSoC products is one of the most secure families of its kind on the market today, regardless of how they are used.
There may be methods, unknown to Cypress, that can breach the code protecti on features. Any of these methods, to our
knowledge, would be dishonest and possibly illegal. Neither Cypress nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the prod uct as "unbreakable."
Cypress is willing to work with the customer who is concerned about the inte grity of their code. Co de prot ection i s constantly
evolving. We at Cypress are committed to continuously improving the code protection features of our products.
This wavelength kit demonstrates the use of Cypress’s PSoC® device to control a pyroelectric Infrared (PIR) sensor. The human body radiates a certain wavelength of infrared light – about 10 µm at
normal body temperature. The concept behind PIR sensing is to capture this radiated light, filter the
analog signals, convert those signals to digital, and then use those digital signals to control hardware. In the PIR Motion Sensor Evaluation kit, the conversion of these infrared rays to digital signals
controls a relay and some LEDs.
The CY3236A-PIRMOTION EVK includes all of the software, hardware, code examples, and documentation you need to implement all of these PIR sensing control functions in one flexible and powerful PSoC device, the CY8C27443. An application note, AN2414, “Proximity Sensing Using PIR” is
available on the Cypress website at http://www.cypress.com/?rID=2794.
Chapter 2 of this document describes the installation and configuration of the kit software. Chapter 3
explains the programming of a PSoC 1 device with PSoC Programmer. Chapter 4 describes the
hardware operation. Chapter 5 pr ovides instructions on how to use the kit with the help of a code
example. The Appendix provides the schematics, layout, and bill of materials (BOM) for the kit.
1.1Kit Contents
The PIR Motion Sensor Evaluation Kit includes the following:
Added Kit Operations, Hardware, and Code Examples chapters.
Added BOM and board images in Appendix.
Content updates throughout the document.
Changed title to “CY3236A Pyroelectric Infrared (PIR) Motion Sensor
Evaluation Kit Guide”.
1.5Documentation Convent ions
Table 1-2. Document Conventions for Guides
ConventionUsage
Courier New
Italics
[Bracketed, Bold]
File > Open
Bold
Times New Roman
Text in gray boxesDescribes Cautions or unique functionality of the product.
Displays file locations, user entered text, and source code:
C:\ ...cd\icc\
Displays file names and reference documentation:
Read about the sourcefile.hex file in the PSoC Designer User Guide.
Displays keyboard commands in procedures:
[Enter] or [Ctrl] [C]
Represents menu paths:
File > Open > New Project
Displays commands, menu paths, and icon names in procedures:
Click the File icon and then click Open.
This chapter describes how to install and configure the CY3236A- P IRM O TI ON kit.
2.1Kit Installation
To install the kit software, follow these steps:
1. Insert the kit DVD into the DVD drive of your PC. The DVD is designed to auto-run and the kit
installer startup screen appears.
Note You can also download the latest installer from http://www.cypress.com/go/CY3236.
Three different types of installers ar e available for download:
■ CY3236A-PIRMOTION_ISO: This file (ISO image) is an archive file of the optical disc provided
with the kit. You can use this to create an installer DVD or extract information using WinRar or
similar tools.
■ CY3236A-PIRMOTION_Single Package: This executable file installs the DVD contents, which
includes PSoC Programmer, PSoC Designer, code examples, kit hardware files, and user documents.
■ CY3236A-PIRMOTION_Single Package (without prerequisites): This executable file installs only
the kit contents, which includes kit code examples, hardware files, and user documents.
2. Click ‘Install CY3236A-PIRMOTION Kit’ to start the installation.
Note If auto-run does not execute, double-click cyautorun.exe file on the root directory of the DVD.
Figure 2-2. Root Directory of DVD
3. The InstallShield Wizard screen appears. On this screen, choose the folder locatio n to install the
setup files. You can change the location of the folder for the setup files using Change (see
Figure 2-3).
4. Click Next to launch the kit installer.
Figure 2-3. InstallShield Wizard
5. On the Product Installation Overview screen, select the installation type that best suits your
requirement. The drop-down menu has three options - Typical, Custom, and Complete (see
7. When the installation begins, a list of packages appears on the Installation Page. A green check
mark appears adjacent to every package that is downloaded and installed (see Figure 2-5).
8. Wait until all the packages are downloaded and installed successfully.
2. Click File > New Project, to create a new project; click File > Open Project to work with an existing project.
Figure 2-7. PSoC Designer Interconnect View
Getting Started
3. To experiment with the code examples, go to Code Examples on page 27.
Note For more details on PSoC Designer, see the PSoC Designer IDE Guide located at:
<Install_Directory>:\Cypress\PSoC Designer\<version>\Documentation.
See Reference Documents on pag e 6 for links to PSoC Designer training. The PSoC Designer quick
start guide is available at: http://www.cypress.com/?rID=47954.
4. Use the Program button to program the hex file on to the chip.
5. When programming is successful, Programming Succeeded appears in the Actions pane.
6. Close PSoC Programmer.
Note For more details on PSoC Programmer, see the user guide at the following location:
<Install_Directory>:\Program Files\Cypress\Programmer\<version>\Documents.
The CY3236A-PIRMOTION EVK allows you to evaluate Cypress’s' PSoC (Programmable Systemon-Chip™) device's ability to control a PIR sensor to implement motion sensing applications such as
automatic lighting controls, automatic door openers, security systems, kiosk wakeup, and activating
wireless cameras.
3.2Evaluating the PSoC Device
To evaluate the default project programmed on the CY3236A-PIRMOTION board. Ensure that the
jumper (shunt) is not connected on J4. Power the board using the 12-V adapter at the power jack,
J1. Stimulate the infrared sensor by moving your hand over as shown in Figure 3-1. The sensor status is indicated by D7, This LED (D7) turns on when hand is brought near the sensor. The Fresnel
lens is used to direct infrared rays from various angles toward the PIR sensor . The AC terminal block
can be used to connect an external hardware device.
Figure 3-1. Infrared Radiation Detected by Human Body
To adjust the length of time during which the relay is active, use the potentiometer, R7. Turn it counter-clockwise to increase the relay-on time and vice versa. Relay on is indicated by the LED, D2.
To enable the ambient light detector, shunt header J4. After enabling this feature, adjust the responsiveness of the board to light, using the potentiometer, R8.
If the PSoC on the board has been reprogrammed or erased, follow the steps in the section 3.2.1
Programming Specifications and Connections to program the board with the hex file provided in the
When the MiniProg is connected, you can use PSoC Programmer to program the CY3236A-PIRMOTION Evaluation kit. Plug in the USB cable into the MiniProg before attaching it to the ISSP header
on the board. When using MiniProg, the LEDs blink at a variab le rate to tra ck connection status. The
green LED near the USB connector turns on after MiniProg is plugged into the computer and is configured by the operating system. If MiniProg cannot find the correct driver in the system, this LED
does not turn on. After the device is configured, th e LED stays on at about a 4-Hz blink rate. This
changes during programming, when the blink duty cycle increases. The red LED (see Figure 3-2) at
the bottom turns on when the MiniProg powers the part. The LED is off when power is provided by
the target board.
This chapter provides an overview of the hardware, including power system, jumper setting, and programming interface. To start using the board, go to Code Examples on page 27.
4.1System Block Diagram
The CY3236A-PIRMOTION board has the following sections:
■ PSoC CY88C27443 silicon
■ Power supply and regulator
■ Ambient light sensor
■ PIR sensor
■ ISSP programming header
■ Test points
■ Status LEDs
■ Potentiometer to adjust relay time and light sensitivity
This PSoC device is configured to filter the analog signals from sensors, convert those signals to
digital, and then use the digital signals to control hardware via a relay.
The kit can be powered by a 9 V to 12 V DC wall transformer with a positive tip barrel plug and 1 A
current rating. The onboard regulator converts the in put volt age to a regulate d 5 V required by PSoC
and other passive components. The relay unit is directly powered by the wall transformer.
3. Ambient Light Sensor
The ambient light sensor consists of a phototransistor. This sensor data is used to detect the presence of ambient light and can override th e function of the PIR sensor an d keep th e relay from tur ning
on. In other words, the relay activation is now controlled by how much ambient light is present. The
PIR signal can be ignored by the firmware, allowing the ambient light sensor to control the relay.
Refer to the Rohm PRM-075PT Phototransistor datasheet on the kit CD (<drive>:\Documenta-tion\Datasheets) for additional information on the sensor..
The CY3236A-PIRMOTION board consists of a Glolab's PIR325 PIR sensor. Humans, at normal
body temperature, radiate in frared light waves at an approximate wavelength of 10 µm. A PIR sensor can detect this infrared radiation and convert it to an electric charge. This charge is buffered
through a FET and can be converted to voltage variations using a load resistor. This analog data is
filtered and converted to digital by PSoC. Refer to the Glolab PIR325 In frar ed Mot ion Detec tor datasheet on the kit CD for additional information on the sensor (<drive>:\Documentation\Data-sheets).
This header is used to program the device using the MiniProg programmer.
[+] Feedback
Page 24
Hardware
Analog Out
DAC_OUT
VCC
TP5
TP3
TP4
TP1
6. Test Points
The DAC Debug Test Point is used to view the output of the processed PIR signal. Connect a scope
to the test point to view the sensor performance after the PSoC has filtered, amplified, and digitized
the analog signal from the PIR sensor. Additional voltage test points are also provided to monitor the
output voltage of the regulator.
7. Status LEDs
There are four status LEDs to indicate the sensor and power status. D1 indicates the power status,
D2 indicates the status of relay (lights up when relay is on), and D7 indicates the status of the PIR
sensor. LEDs D5 and D6 are not used with the firmware included with this kit. However, they can be
configured to perform other functions, such as sensing directional movement.
8. Potentiometer to Adjust Relay Time and Light Sensitivity
Potentiometer R7 is used to control the amount of time the relay is active. Adjust the relay ON time
by turning the potentiometer so that the relay remains on for longer periods. To increase the relay
ON time, turn the potentiometer counterclockwise. Turn it clockwise to decrease the ‘On’ time. R8 is
used to adjust the circuit's sens itivity to ambie nt light. To make the board more sensitive to ambient
light, turn the potentiometer clockwise. For less sensitivity, turn it counterclockwise. R8 is only active
if the shunt J4 is connected. When the shunt is removed, ambient light detection is disabled
The on board really is a 12 V relay that is controlled by PSoC via a transistor as shown in the following circuit diagram. The normally open and common pins of Relay are connected to an AC terminal
block This unit allows you to connect a small AC powered device (the device is controlled by the
relay). Such a device should include a small, low watt incandescent light bulb.
CAUTION Due to exposed pins on the back side of the board, connect no more than a 24 V AC to
this terminal block.
10.GPIO Expansion Port
The unused pins, Port 2 of the PSoC device, are brought out to an 8-pin, 0.100" pitch footprint,
allowing access to this port.
This code example demonstrates Cypress's PSoC device's ability to control a PIR sensor to implement motion sensing applications such as automatic lighting controls, automatic door openers, security systems, kiosk wakeup, and activating wireless cameras.
The human body radiates a certain wavele ngth of infrared l ight in the realm of a bout 10 µm at normal
body temperature. PIR sensing captures this radiated light. The PSoC filters the analog signals from
the PIR sensor, converts those signals to digital, and then uses the digital signals to control the hardware depending on the application.
Additionally, PSoC processes the signal from the PIR, based on the inputs from the ligh t se nsor, and
the Relay Time Preset controls the relay. The light sensor senses the ambient light and feeds the
PSoC with an analog signal proportional to the ambient light. The Relay T ime Preset contr ol is a preset that provides a 0- to 5-V signal to the PSoC. The ambient light sensor can be used in applications such as automatic porch light control, where the load need not be switched on during daylight.
Similarly, the relay time preset can be used to control the duration for which the relay remains on
when infrared wavelengths are detected.
5.2Device Configuration
The analog and digital user module placement within PSoC Designer are shown in Figure 5-1. The
project uses three analog blocks and two digital blocks for the actual PIR implementation. Two more
analog blocks are used for a 9-bit DAC. The DAC9 is purely for debugging purposes.
■ Aanalog-to-digital converter (ADCINCVR): This user module measures the signal generated by
the PIR sensor. It also determines the voltage from the relay time preset and the voltage from the
ambient light photo transistor.
■ Digital-to-analog converter (DAC): This user module outputs the processed PIR signal and is
intended for debugging purposes only.
■ Programmable gain amplifier (PGA): T wo of th ese user modules are used in th is design. The first
amplifies the PIR signal as it leaves the PIR sensor. The second performs three functions. It
amplifies the PIR signal as a second stage following the first amplifier. It then buf fers the voltage
from the relay time preset to the ADC. Lastly, it amplifies the voltage signal generated by the
ambient light photo transistor.
■ 8-Bit Counter: The 8-bit counter is a time-based generator for sampling the PIR signal.
Figure 5-1. PSoC Designer Analog and Digital User Module Placement
The firmware uses an infinite loop during which the PIR signal, relay-on time, and the output voltage
of the ambient light sensor are sampled. Activation of the relay and motion LEDs are then determined by the values acquired from sampling .
1. Ensure that jumper (shunt) is not placed on J4.
2. Power the board using the 12-V power adapter provided with the kit. After powering the board,
wait for approximately 30 seconds for the firmware to initialize.
3. Upon initializing, move your hand over the PIR sensor; the relay K1 switches on. The LED D2 is
also turned ‘On’ to indicate that relay is on. The relay remains in ‘On’ state as long as there is
infrared motion detected. LED D7 lights up when the PIR device senses infrared radiation from
the human body (hand).
Figure 5-2. Infrared Radiation Detection from Human Body
The amount of time the relay is active can be changed. Adjust the relay ‘On’ time by turning the
potentiometer, R7, so that the relay remains on for longer periods. To increase the relay ‘on’ time,
turn the potentiometer counterclockwise. Turn it clockwise to decrease the ‘on’ time.
5.4Ambient Light Sensing
Figure 5-3. Ambient Light Sensing
Code Examples
The evaluation board is also equipped with an ambient light sensor in the form of a photo transistor,
DR. To use this feature, header J4 must be shunted. When this feature is enabled, the presence of
ambient light can override the function of the PIR sensor and keep the relay fro m turn ing on. In other
words, the relay activation can now be enabled depending on by how much ambient light is present.
Based on how much light is present, the PIR signal can be ignored by the firmware, allowing the
ambient light sensor to control the relay. To adjust the circuit's sensitivity to ambien t light, tune the
potentiometer, R8. To make the board more sensitive to ambient light, turn the potentiometer clockwise. For less sensitivity, turn it counterclockwise
The board also contains a test point for the digital-to-analog conv ersion output of the PIR signal.
Connect a scope to this test point to view the PIR signal that the PSoC has proc ess ed .
LEDs D5 and D6 are not used with the firmware included with this kit. However, they can be configured to perform other functions, such as sensing directional movement.