Cypress CY3236A User Manual

Page 1
CY3236A
Pyroelectric Infrared (PIR) Motion Sensor
Evaluation Kit Guide
Doc. # 001-68617 Rev. *A
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone (USA): 800.858.1810
http://www.cypress.com
[+] Feedback
Page 2
Copyrights
Copyrights
© Cypress Semiconductor Corporation, 2011. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or sa fety applica tions, unless pursu ant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components in life­support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
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 soft­ware and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as speci­fied 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 MATE­RIAL, 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 sys­tems 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 corpora­tions.
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 guaran­tee 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.
2 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 3

Contents

1. Introduction 5
1.1 Kit Contents..................................... ... ... .......................................... ............................5
1.2 Prerequisites................................................................................................................6
1.3 Reference Documents............................................................... ... ............................... 6
1.4 Document Revision History ........................................................................................7
1.5 Documentation Conventions .......................................................................................7
2. Getting Started 9
2.1 Kit Installation . .... .......................................... ......................................... ......................9
2.2 PSoC Designer..........................................................................................................13
2.3 PSoC Programmer ....................................................................................................14
3. Kit Operations 15
3.1 Introduction................................................................................................................15
3.2 Evaluating the PSoC Device......................................................................................15
3.2.1 Programming Specifications and Connections...............................................16
4. Hardware 19
4.1 System Block Diagram ................................................. ... ... ... .... ... ... ... .......................19
4.2 Functional Description .................................. ......................................... .... ... ... ... .... ...21
5. Code Examples 27
5.1 Project Description....... ... .... ... ... ... .... ... ... ... .... ......................................... .... ... .............27
5.2 Device Configuration .................................................................................................27
5.2.1 Flowchart........................................................................................................29
5.3 Verify Output - PIR Sensing.......................................................................................30
5.4 Ambient Light Sensing...............................................................................................31
A. Appendix 33
A.1 PIR Motion Sensor Board Schematic ........................................................................33
A.2 Board Images ........ .......................................... ... ... ... .... ... ... .......................................34
A.3 Bill of Materials ..........................................................................................................34
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 3
[+] Feedback
Page 4
Contents
4 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 5

1. Introduction

This wavelength kit demonstrates the use of Cypress’s PSoC® device to control a pyroelectric Infra­red (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 hard­ware. 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 docu­mentation you need to implement all of these PIR sensing control functions in one flexible and pow­erful 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.1 Kit Contents

The PIR Motion Sensor Evaluation Kit includes the following:
PIR sensor evaluation board
12-V power adapter
CY8C27443-24PVXI sample silicon
Quick start guide
CY3236A-PIRMOTION kit DVDPSoC Designer installation filePSoC Programmer installation fileBridge Control Panel installation file (packaged along with PSoC Programmer)Code examplesHardware filesKit guideQuick start guideRelease notes
Inspect the contents of the kit. If any parts are missing, contact your nearest Cypress sales office for further assistance.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 5
[+] Feedback
Page 6
Introduction

1.2 Prerequisites

The following are required for the programming of the kit:
CY3217-MiniProg1 is a programming tool that can be used to program all PSoC1 devices. This
kit can be purchase separately at http://www.cypress.com/go/CY3217-Miniprog1.

1.3 Reference Documents

The following documents are included in the documentation folder (<drive>:\Documentation\Datasheets):
Datasheet – Glolab PIR325 Infrared Motion Detector
Datasheet – Rohm PRM-075PT Phototransistor
Visit www.cypress.com for additional learning resources in the form of datasheets, technical refer- ence manual, and application notes.
For more information regarding PSoC Designer functionality and releases, go to:
www.cypress.com/go/psocdesigner
For more information regarding PSoC Programmer, supported hardware, and COM layer, go to:
www.cypress.com/go/psocprogrammer
For a list of PSoC Designer-related trainings, go to:
http://www.cypress.com/?rID=40543
Application note, AN2414 – Proximity Sensing Using PIR
http://www.cypress.com/?rID=279
Datasheet – CY8C27443 Cypress PSoC device
http://www.cypress.com/?rID=3324
6 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 7

1.4 Document Revision History

Table 1-1. Revision History
Revision
** 04/18/2011 OWEN Initial version of kit guide
*A 09/19/2011 RKPM
PDF
Creation Date
Origin of
Change
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.5 Documentation Convent ions

Table 1-2. Document Conventions for Guides
Convention Usage
Courier New
Italics
[Bracketed, Bold]
File > Open
Bold
Times New Roman
Text in gray boxes Describes 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.
Displays an equation:
2 + 2 = 4
Introduction
Description of Change
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 7
[+] Feedback
Page 8
Introduction
8 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 9

2. Getting S tarted

This chapter describes how to install and configure the CY3236A- P IRM O TI ON kit.

2.1 Kit 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 docu­ments.
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.
Figure 2-1. Kit Installer Startup Screen
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 9
[+] Feedback
Page 10
Getting Started
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
Figure 2-4).
6. Click Next to start the installation
10 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 11
Figure 2-4. Installation Type Options
Getting Started
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.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 11
[+] Feedback
Page 12
Getting Started
Figure 2-5. Installation Page
9. Click Finish to complete the installation. Figure 2-6. Installation Complete
12 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 13
Note Advanced users can go to Code Examples on page 27.

2.2 PSoC Designer

1. Click Start > All Programs > Cypress > PSoC Designer <version> > PSoC Designer <version>.
2. Click File > New Project, to create a new project; click File > Open Project to work with an exist­ing 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.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 13
[+] Feedback
Page 14
Getting Started

2.3 PSoC Programmer

1. Click Start > All Programs > Cypress > PSoC Programmer <version> > PSoC Programmer <version>.
2. Select the MiniProg from Port Selection.
Figure 2-8. PSoC Programmer Window
3. Click File Load to load the hex file.
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.
14 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 15

3. Kit Operations

3.1 Introduction

The CY3236A-PIRMOTION EVK allows you to evaluate Cypress’s' PSoC (Programmable System­on-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.2 Evaluating 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 sta­tus 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 coun­ter-clockwise to increase the relay-on time and vice versa. Relay on is indicated by the LED, D2.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 15
[+] Feedback
Page 16
Kit Operations
To enable the ambient light detector, shunt header J4. After enabling this feature, adjust the respon­siveness 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
kit CD or installed directory
<Install_Directory>:\Cypress\ CY3236A-PIRMOTION\<version>\Firmware\

3.2.1 Programming Specifications and Connections

When the MiniProg is connected, you can use PSoC Programmer to program the CY3236A-PIRMO­TION 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 con­figured 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.
Figure 3-2. Hardware Connections for Programming
16 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 17
Figure 3-3. PSoC Programmer Window
Kit Operations
Follow these steps to program using MiniProg1:
1. Connect the USB cable to the PC and MiniProg1 (Figure 3-2)
2. Plug in the MiniProg1 to the ISSP header on the CY3236A-PIRMOTION board
3. When USB is connected to the MiniProg1, LED (green ) glo ws in th e Min iPro g 1
4. Open PSoC Programmer
5. Click the Load File button and browse to the hex file location. Select the hex file and click Open
6. Click Connect or double click on the respective MiniProg under Port Selection to select or con­nect to MiniProg (in case not connected)
7. Click Program or press [F5] to initiate programming
8. The green LED on the MiniProg1 blinks to indicate the progress of programming
9. After successful programming, the red LED on MiniProg1 is powered off.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 17
[+] Feedback
Page 18
Kit Operations
18 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 19

4. Hardware

This chapter provides an overview of the hardware, including power system, jumper setting, and pro­gramming interface. To start using the board, go to Code Examples on page 27.

4.1 System 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
Relay and AC terminal block
GPIO expansion port
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 19
[+] Feedback
Page 20
Hardware
PSoC
CY8C27443
silicon
PIRsensor
Regulator
AmbientLight
sensor
ISSP
programming
header
Potentiometer
Relaytime&
lightsensitivity
StatusLEDs
Power LED
TestPoints
Relay(via
transsitor)
ACterminal
block
GPIO
expansionport
12DC
Shuntfor
light
sensitivity
Figure 4-1. Hardware Block Diagram
20 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 21
Figure 4-2. CY3236A-PIRMOTION Board
ISSP/I2C
Programming
Header
Relay
AC Terminal
Block
12-V Power
Jack
LED for Relay
Status
Status LEDs
PIR Sensor with Fresnel
Lens Covering
Light Detect
Enable
Ambient
Light Sensor
Light Sensitivity
Adjust
Relay Time
Adjust
DAC Debug
Test Point
PSoC
CY8C27443
Hardware

4.2 Functional Description

1. PSoC CY8C27443 Silicon
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.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 21
[+] Feedback
Page 22
Hardware
Ambient Light Sensor
Voltage divider
3.4V for diode.
LIGHT
RLY_TIME
VCC
0805
R15
4.7K
J4
2 PIN HDR
1 2
D4
Photo Diode
2 1
R7
POT 10K Top Adjust
13
2
0805
R14
2.2K
R8
POT 1M Top Adjust
13
2
2. Power supply and Regulator
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 pres­ence 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..
22 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 23
Hardware
P2_7
VCC
0805
R13
1K
0805
R12
100K
0805
R10
10K
P1
Fresnel Lens
1 2
MEC1 MEC2
0805
R11
470K
0805
C9
0.1 uFd
U3
PIR Motion Sensor
1 2
3
12
3
0805
C7
0.1 uFd
0805
C10
0.1 uFd
0805
C8
1.0 uFd
CY8C27443 SSOP28
5 9
14
P2_6 P2_7 SMP
VSS
ISSP Programming Header
XRES SCLK SDATA
VCC
J5
HDR 1x5
1
3
2
4 5
4. PIR 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 sen­sor 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 data­sheet on the kit CD for additional information on the sensor (<drive>:\Documentation\Data- sheets).
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 23
5. ISSP Programming Header
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
24 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 25
Hardware
Ambient Light Sensor
RELAY
VCC
VCC_12V
0805
R2
2.2K
COMM
N.O.
N.C.
K1
SPDT-12V
4
2
5
1
3
D3
MRA4007
2 1
E
B
C
SOT-23
Q1 BC847
1
2 3
J3
TERMINAL BLK
1 2
0805
R3
5.6K
0805
D2
LED Red
21
M1
430V
9. Relay and AC Terminal Block
The on board really is a 12 V relay that is controlled by PSoC via a transistor as shown in the follow­ing 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.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 25
[+] Feedback
Page 26
Hardware
26 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 27

5. Code Examples

All code examples are available on the CY3236A-PIRMOTION kit DVD or at this location:
<Install_directory>:\Cypress\CY3236A-PIRMOTION\<version>\Firmware

5.1 Project Description

This code example demonstrates Cypress's PSoC device's ability to control a PIR sensor to imple­ment motion sensing applications such as automatic lighting controls, automatic door openers, secu­rity 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 hard­ware 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 pre­set that provides a 0- to 5-V signal to the PSoC. The ambient light sensor can be used in applica­tions 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.2 Device 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.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 27
[+] Feedback
Page 28
Code Examples
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 deter­mined by the values acquired from sampling .
28 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 29

5.2.1 Flowchart

START
Enable Global Interrupts
Initialize IIR Filter, ADC
and Timer
Wait for approximately 30 secs
for PIR signals to initialize
B
YES
Is ADC data ready
NO
Setup ADC input to read PIR
signal
Is ADC data ready
NO
Change ADC input to read
ambient light
Is ADC data read
y
Change ADC input to read Relay time
adjust pot
NO
NO
B
YES
B
Set the relay ON time based on i/p from relay time
adjust pot
Is PIR signal beyond detection threshold and ambient light is
Code Examples
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 29
[+] Feedback
Page 30
Code Examples
TimerInterrupt
Is relay ON time counter > 0
EXIT
NO
YES
Decrement the relay ON
counter
Is relay ON time counter = 0
NO
YES
Turn OFF the rela
y

5.3 Verify Output - PIR Sensing

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
30 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 31
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.4 Ambient 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 clock­wise. 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 config­ured to perform other functions, such as sensing directional movement.
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 31
[+] Feedback
Page 32
Code Examples
32 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Page 33
Ambient Light Sensor
ISSP Programming Header
Analog Out
Bulk Caps
Bypass Cap
PDCR-9377 **
121R-37700 **
Voltage divider
3.4V for diode.
REF-13820 *
CY3236A-PIRMOTION PCB
B
Title
Size Document Number R
CYPRESS SEMICONDUCTOR © 2006
LIGHT
XRES
SCLK
SDATA
DAC_OUT
XRES
G2_IN
LIGHT
DAC_OUT
G1_OUT
G1_IN
P2_0
P2_1
P2_2
P2_3
P2_4
P2_5
P2_6
P2_7
P2_0 RLY_TIME
P2_2
RELAY
SDATA
P2_3
P2_4
P2_6
P2_7
P2_5
P2_1
SCLK
RLY_TIME
RELAY
VCC
VCC
VCC
VCC
VCC
VCC_12V
VCC
VCC_12V
VCC_12V
VCC
VCC
VCC
0805
R2
2.2K
0805
R13
1K
0805
C6
1.0 uFd
0805
D5
LED Red
2 1
COMM
N.O.
N.C.
K1
SPDT-12V
4
2
5
1
3
0805
R12
100K
J5
HDR 1x5
13245
TP5
0805
R4
1K
0805
R15
4.7K
J4
2 PIN HDR
1
2
0805
R10
10K
P1
Fresnel Lens
1 2
MEC1 MEC2
TP3
0805
R1
1K
0805
D6
LED Red
2 1
0805
R11
470K
0805
D1
LED Green
21
0805
R9
1M
P2
RECP 8X1
1234567
8
1234567
8
0805
R5
1K
+
E
C3
10 uFd 25v
TP4
D4
Photo Diode
2 1
0603
C4
0.1 uFd
DPAK
U1
L78M05
3
2
1
VOUT
GND
VIN
0805
C9
0.1 uFd
0805
D7
LED Red
2 1
D3
MRA4007
2 1
U3
PIR Motion Sensor
1 2
3
12
3
0805
R6
1K
0805
C7
0.1 uFd
+
E
C1
10 uFd 25v
EBC
SOT-23
Q1
BC847
1
2 3
R7
POT 10K Top Adjust
13
2
0603
C5
0.1 uFd
TP1
J3
TERMINAL BLK
1
2
0805
R3
5.6K
0805
C10
0.1 uFd
0805
D2
LED Red
21
0805
C8
1.0 uFd
0805
R14
2.2K
M1
430V
J1
RAPC722
1
2
3
R8
POT 1M Top Adjust
13
2
U2
CY8C27443 SSOP28
151316121711181020821722623
5
19924425326227
1
2814
P1_0
P1_1
P1_2
P1_3
P1_4
P1_5
P1_6
P1_7
P2_0
P2_1
P2_2
P2_3
P2_4
P2_5
P2_6
P2_7
XRES
SMP
P0_0
P0_1
P0_2
P0_3
P0_4
P0_5
P0_6
P0_7
VCCVSS
0603
C2
0.1 uFd

A. Appendix

The schematic, board layouts, and BOM are available on the kit CD or at: <Install_directory>:\Cypress\CY3236A-PIRMOTION\<version>\Hardware.

A.1 PIR Motion Sensor Board Schematic

Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 33
[+] Feedback
Page 34

A.2 Board Images

Figure A-1. Layout Primary Side
Figure A-2. Layout Secondary Side

A.3 Bill of Materials

Table A-1. BiOM
Item Qty
1 2 710R-13952 C3,C1
2 3 730R-11026 C2,C4,C5
3 2 730R-10963 C6,C8
4 3 730R-10074 C7,C9,C10
5 1 860R-13830 D1
34 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
CY Part
Number
Reference Description Manufacturer Mfr Part Number
CAP ELECT 10UF 25V KS RADIAL
CAP .1UF 50V CERAMIC Y5V 0603
CAP 1.0UF 16V CERAMIC Y5V 0805
CAP .1UF 50V CERAMIC X7R 0805
LED GREEN CLEAR 0805 SMD
Panasonic - ECG ECE-A1EKS100
Panasonic - ECG ECJ-1VF1H104Z
Panasonic - ECG ECJ-2VF1C105Z
Panasonic - ECG ECJ-2YB1H104K
LITE-ON LTST-C170GKT
[+] Feedback
Page 35
Table A-1. BiOM (continued)
Item Qty
6 4 860R-13823
7 1 810R-13953 D3
8 1 810R-13827 D4
9 1 420R-11051 J1
10 2 420R-13590 J4,J2
11 1 420R-13954 J3
12 1 420R-10516 J5
13 1 800R-13955 K1
14 1 800R-13958 P1
15 1 830R-13956 Q1
16 5 630R-10733
17 1 630R-10534 R2
18 2 630R-10246 R10,R3
19 1 670R-13826 R7
20 1 670R-13828 R8
21 1 630R-10347 R9
22 1 640R-13825 R11
23 1 630R-10197 R12
24 1 500R-13829 U1
25 1 26 1 870R-13824 U3 PIR Motion Sensor, 3POS Glolab Corp. PIR325 27 1 PDCR-9377 ** PCB 28 1 LABEL1 PCA # 121R-37700 **
DO NOT INSTALL
29 1 840R-13957 M1
CY Part
Number
CY8C27443­24PXI
Reference Description Manufacturer Mfr Part Number
D2,D5,D6,D 7
R1,R4,R5, R6,R13
U2
LED RED Clear 0805 SMD LITE-ON Inc LTST-C170CKT DIODE GPP 1A 1000V
DO41 PHOTOSENSOR MINI
3.3V 550NM 2QFN CONN 2.1MM PWRJACK
RT ANGLE PCB CONN HEADER VERT
2POS .100 30AU CONN TERM BLOCK
PCB 5.0MM 2POS CONN HEADER 5POS 0.1
VERT KEYED RELAY PCB SPDT 10A
12VDC FRESNEL LENS, ROUND,
21mm TRANS NPN LP 100MA
30V SOT23 RES 1K OHM 1/10W 5%
0805 SMD RES 2.2K OHM 1/10W 5%
0805 SMD RES 10K OHM 1/10W 5%
0805 SMD POT 10K OHM 6MM CER-
MET HORZ
POT 1.0M OHM 6MM CERMET HORZ
RES 1M OHM 1/10W 5% 0805 SMD
RES 470K OHM 1/8W 5% 0805 SMD
RES 100K OHM 1/16W 5% 0805 SMD
IC REG VOLT POS 500MA 5V DPAK
IC PROGRAMMABLE SOC DIP28
PRINTED CIRCUIT BOARD
VARISTOR 430V 1.7J 3MM AXIAL T/R
Fairchild Semiconductor
Avago Technologies US Inc.
1N4007
HSDL-9001
Switchcraft Inc. RAPC722 AMP Division of
TYCO
1-87215-0
Weidmuller 1715250000
Molex 22-23-2051
Omron G2R-1-DC12
3Dlens 5114
ON Semiconductor BC847
Panasonic - ECG ERJ-6GEYJ102V
Panasonic - ECG ERJ-6GEYJ222V
Panasonic - ECG ERJ-6GEYJ103V CTS Corporation
Resistor/
307UC103ER
Electrocomponents CTS Corporation
Resistor/
307UC105ER
Electrocomponents Panasonic - ECG ERJ-6GEYJ105V
Panasonic - ECG ERJ-6GEYJ474V
Panasonic - ECG ERJ-6GEYJ104V
STMicroelectronics L78M05CDT-TR Cypress
Semiconductor
Cypress Semiconductor
CY8C27443­24PXI
PDCR-9377 **
Littlefuse V430MT7B
Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A 35
[+] Feedback
Page 36
36 Pyroelectric Infrared Motion Sensor Evaluation Kit Guide, Doc. # 001-68617 Rev. *A
[+] Feedback
Loading...