Project 1: Temperature Control with EagleSoC Board using PSoC Creator 3.0

This project demonstrates temperature sensor (TMP 102) interface with the EagleSoC board via Inter-Integrated Circuit (I2C) protocol. The HC-SR501 Body Sensor module is used to detect the motion within the angle of 100 degrees and with maximum range of 7 meters. The temperature sensor triggers the Futaba servo motor via PWM signal once the threshold temperature of 26 C degrees is surpassed. These three project components are shown in Figure 1.

Figure 1: Hardware Components

PSoC Creator allows drag and drop of hardware modules in the "Top Design" area. The interfacing components for each hardware block with required interconnections are shown in Figure 2. PWM block is controlled through the 3.0 MHz clock. The digital output pin (Servo_1) represents the servo motor which receives signal through the PWM block. Passive Infrared (PIR) motion sensor is the HC-SR501 sensor which is represented by the Digital Input Pin. The signal is based on the motion detection and can be set to either high or low value. The temperature sensor is shown in the I2C block. The threshold alarm is being triggered through the Interrupt Service Routine attached to the timer block. The timer block has its own input clock. As soon as the threshold is surpassed, the temp_alarm_LED Digital Output Pin is being triggered. LED Heartbeat pin attached to the timer. The LCD block is used for temperature information display and can be used for all other debugging necessary within the project.

Figure 2: Top Design

In order to add all the above components, start a new empty project from the PSoC Creator and save it under the directory of your choice. In the Workspace Explorer click on the Top Design branch and you will see the empty layout in the center of your screen. On the right side, you should find a Component Catalog. Search for the required components and drag-and-drop them to your layout in the center. Figure 3 demonstrates the search for PWM component under "Functions" directory. Transfer this component to your layout.

Figure 3: Adding PWM Component

Figure 4 shows a clock component that is found under system directory. Transfer this component to your layout.

Figure 4: Adding Clock Component

Double-click on your PWM component and you will see its configuration window. On your configure tab, make the appropriate settings for your motor. The typical frequency for the servo motors is 50 Hz, hence the servo motor will be expecting a pulse every 20 ms.

Figure 5: PWM Configuration

Select new clock type with Internal Main Oscillator (IMO) as a source and with frequency of 3.00 MHz.

Figure 6: Clock Configuration

Now drag the configured clock and connect it to the input of the PWM block as shown on Figure 7.

Figure 7: Clock to PWM Connection

Return to the component catalog and find the Digital Output Pin under "Ports and Pins" directory. Drag and drop the component on the layout.

Figure 8: Adding Digital Output Pin for Servo Motor

Also, find the Digital Logic Zero component under "Logic" directory. Drag and drop two of these components on your layout.

Figure 9: Digital Logic Zero

Digital Logic Zero will provide constant low signal "0" to the Kill and Reset inputs of PWM blocks. Kill and Reset inputs of the PWM will be permanently disabled

Figure 10: Kill and Reset Inputs

Return to the component catalog and find the timer block under Digital Function subdirectory. Drag and drop the timer to the Top Design layout.

Figure 11: Adding Timer

Double-click on Timer block and configure the Timer as shown in Figure 12. Make sure to check the Terminal Count box. Apply the settings.

Figure 12: Timer Configuration

Double-click the clock component of the timer and configure it as shown on Figure 13. Also, apply the settings by pressing "OK".

Figure 13: Timer Clock Configuration

Now add an Interrupt block located under "System" directory.

Figure 14: Adding Interrupt Service Routine (ISR)

Attach the Interrupt Service Routine (ISR) to your Timer block as shown on Figure 15

Figure 15: Connecting Timer with the ISR

Double-click on the ISR in order to rename it to the object name in your code.

Figure 16: Rename ISR to match the object in the code

Find the I2C Master (Fixed Function) component in the catalog under "Communications" and "I2C" subdirectories.

Figure 17: Adding Inter-Integrated Circuit (I2C)

Double-click on the I2C block and select 50 kbps for its data rate. Press "OK".

Figure 18: Configuring I2C

Add two more Digital Output Pins from the catalog.

Figure 19: Adding two more Digital Output Pins

Leave one of the Digital Output Pins on layout and rename it to "temp_alarm" as shown on Figure 20.

Figure 20: Temperature Alarm Pin Configuration

Rename the other Digital Output Pin to "LED_Heartbeat" and attach it to the Terminal Counter of the Timer block as shown on Figure 21.

Figure 21: LED Output Pin Configuration

Add the LCD Char from the catalog under "Display" directory.

Figure 22: Add LCD Character Display

You are now ready to assign your pins. On your workspace explorer double click on CYDWR branch, which is located right under the Top Design. On your right hand side you will see your recently added components. Assign the pins corresponding to your board connections as demonstrated on Figure 23 or you can choose your own pin assignment.

Figure 23: Pin Assignment and Configuration

Use the breadboard and wires to perform connections to the EagleSoC. The final physical system wiring is shown on Figure 24.

Figure 24: Complete Physical Setup

The code samples will be provided at a later time.