Tiva Lab 02: Home Control System

Introduction

This lab aims to acquaint learners with the Home Control System using Tiva TM4C LaunchPads. Participants will explore how to effectively utilize the General Purpose Input/Output (GPIO) configurations and understand how to read and write data through pins, thus controlling various household devices.

Objective

  • Understand and implement basic I/O operations.
  • Master GPIO configurations.
  • Read from input pins and write to output pins to control devices.

Required Reading Material

Overview

GPIO (General Purpose Input/Output)

It's an interface standard that allows microcontrollers to connect with other electrical devices. These GPIOs can be set in two primary modes:

  • Input Mode
    The microcontroller gathers input from other devices, like receiving the status of a button.
  • Output Mode
    The microcontroller sends data to devices, such as instructing an LED to turn on/off.

This lab will guide participants through writing C code to set up GPIO ports, decipher the status of switches, and manage LED operations.

The GPIO configuration is vital. Post reset, the software must be initialized, including loading the right configurations described in "Lesson 09: GPIO Ports and Configurations".

You can read the following articles to get more information about LEDs and push-buttons:

Requirements

Now, a client has asked you to remodel their house. He wants to use an embedded system to control all the lighting systems in the house, including the doorbell. Three types of control systems can be used in a home control:

  1. A button controls a device: like a doorbell — when the user presses the doorbell button, the system triggers the doorbell to make noises until the button is released.
  2. A switch controls a group of lights: the lights come on when the user presses the switch. Press again to turn off the lights.
  3. Multiple switches control a group of lights: e.g., stairwell lighting control system — switches are installed on the first and second floors near the stairs. When the user presses any switch, the light turns on, and presses any switch again to turn off the light.

Required Components List

Button Small 64 Push Button (Switch) × 4
Resistor 64 220-ohm Resistor × 3
LED Green 64 LED × 2
Trnasistor 64 S8050 NPN Transistor × 1
ActiveBuzzer 64 Active Buzzer × 1
breadboard s Breadboard × 1

Circuit / Schematic Diagram

The prototype system will use a Tiva board to emulate the three control systems. Details of the circuit can be referred to in Figures 1 (Simulation Circuit for Home Using TM4C123GXL/TM4C1294) and Figure 1.2 (Circuit Connection on the Breadboard). Also, the pin configurations for different devices are given in Table 1.

EK-TM4C123GXL LaunchPad

lab cirsuit 123g NPN S8050 Pinout 2
NPN S8050 Pinout 2

Figure 1: The Simulation Circuit for Home Using TM4C123GXL

BreadboardConnection s
Figure 1.2: The Circuit Connection on the Breadboard

Table 1: Pin Configurations:

DevicePort.Pin Signal TypePCTLDirectionDrive Mode

You must place all the components on the breadboard and use wires to connect the components to the Tiva board. The main functions you have to implement are as follows.

  • The SW1 is used to control the buzzer (doorbell).
  • The SW2 is used to control LED1.
  • The SW3 and SW4 control LED2 that is installed on the stairs.

Procedures

  1. Make a new folder named "Lab02_HomeControlSystem" inside the "EE3450" folder.
  2. Launch the Keil μVisio and start a new project. Save the project to the recently created folder named "Lab02_HomeControllSystem".
  3. Add "MyDefines.h" to the Source Group, then add the Common folder to the "include paths" under the "Options for Target" setting.

Configurations

Implement the Setup_GPIO() function to initialize the GPIO Ports based on the PIN Configuration table.

Example Source Code

The provided sample code will serve as the foundation, but it remains incomplete. It's the participant's responsibility to finish the code following lab instructions.

Lab Experiments

© 2024 Air Supply Information Center (Air Supply BBS)