"

Readings Specific to Lab Assignments

Lab 1: Home Security Alarm System

Introduction to Microcontroller-Based Security Systems

Microcontroller-based security systems have become increasingly popular for home and business applications due to their flexibility, cost-effectiveness, and ability to integrate multiple sensors and outputs. The PIC16F18875 microcontroller is well-suited for this type of project due to its ample I/O pins, built-in timers, and analog-to-digital conversion capabilities.

Key Components and Concepts

  1. Sensor Inputs:
    • Door/window sensors (magnetic reed switches)
    • Motion detectors (PIR sensors)
    • Glass break detectors
  2. User Interface:
    • Keypad for arming/disarming (3-digit code)
    • LCD display for system status
  3. Outputs:
    • LEDs for visual indicators
    • Piezo buzzer or siren for audible alarm
    • Relay for external siren control
  4. Timing Considerations:
    • Entry/exit delays (30 seconds)
    • Alarm activation delay (15 seconds)
  5. State Machine:
    • Disarmed state
    • Armed state
    • Alarm triggered state

Implementation Tips

  1. Use interrupts for sensor inputs to ensure quick response times.
  2. Implement debouncing for keypad inputs to avoid false triggering.
  3. Use timer interrupts for managing delays and timing functions.
  4. Store the security code in EEPROM for persistence across power cycles.
  5. Use a state machine approach to manage system behavior in different modes.

Assembly Language Considerations

  1. Use meaningful labels and comments to improve code readability.
  2. Utilize macros for repeated code segments to improve maintainability.
  3. Be mindful of register bank selection when accessing special function registers.
  4. Use bit-wise operations for efficient handling of individual I/O pins.

Lab 2: Temperature Indicator

Introduction to Analog Temperature Sensing

The MCP9701 is a linear active thermistor integrated circuit that provides a voltage output proportional to temperature. By using the PIC16F18875’s analog-to-digital converter (ADC), we can measure this voltage and convert it to a temperature reading.

Key Components and Concepts

  1. MCP9701 Temperature Sensor:
    • Linear output: 19.5mV/°C (scale factor)
    • 500mV output at 0°C (offset voltage)
  2. Analog-to-Digital Conversion:
    • 10-bit ADC on PIC16F18875
    • Voltage reference selection
  3. Temperature Calculation:
    • Converting ADC reading to voltage
    • Applying scale factor and offset to calculate temperature
  4. LED Indicators:
    • Red LED for high temperature
    • Blue LED for low temperature
    • Green LED for on-target temperature

Implementation Tips

  1. Configure the ADC for the appropriate voltage reference and acquisition time.
  2. Use averaging of multiple ADC readings to reduce noise.
  3. Implement hysteresis to prevent rapid switching between temperature states.
  4. Use floating-point calculations for accurate temperature conversion.

Assembly Language Considerations for ADC

  1. Configure ADC control registers (ADCON0, ADCON1, etc.) appropriately.
  2. Use bit-setting instructions to start conversions and check for completion.
  3. Implement proper timing delays for ADC acquisition and conversion.
  4. Handle 10-bit results correctly, considering result formatting (left/right justified).

Sample Code Snippet (PIC16F18875 Assembly)

Deepen your understanding: Watch the accompanying lecture video to delve deeper into the concepts covered in the reading.

 

License

Icon for the Creative Commons Attribution 4.0 International License

Introduction to Microcontrollers Copyright © 2024 by Lake Washington Institute of Technology is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.