Skip to content

This repository contains a solution for an automatic retractable roof system based on rain presence. The solution uses MTCH9010 for water detection and the AVR16EB32 as a host device.

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-examples/avr16eb32-mtch9010-smart-retractable-roof

Repository files navigation

Microchip Technologies Inc.

Smart Retractable Roof Using the AVR16EB32 Microcontroller and MTCH9010 Liquid Detector

This repository provides an MPLAB® X project that showcases a smart retractable roof application. The project uses the MTCH9010 Evaluation Kit for rain detection and the Stepper Driver Reference Design Board featuring the AVR16EB32 MCU to extend or retract the roof. The application uses a customised version of this code example to drive the stepper motor and an AVR®-adapted version of this code example for MTCH9010 configuration. It is recommended to review these examples before moving forward with the application featured on this page.

The Stepper Driver Reference Design is based on the Multiphase Power Board.

Related Documentation

Software Used

Hardware Used

Operation

To program the MCU with this MPLAB X project, follow the steps provided in the How to Program the Microcontroller section.

Concept

The Stepper Driver Board featuring the AVR16EB32 MCU is used as the host for the MTCH9010 Liquid Detector. The power supply is set to 24V and the motor is driven in Half-Step mode. The MTCH9010 is operating in Capacitive mode and Enhanced Configuration is enabled. At start-up, the host MCU sends the configuration parameters to the MTCH9010 via USART. The reference value (600) is set based on the dry-state sensor measurement and setup (sensor wires length) at normal room temperature and humidity. The threshold value (50) is set based on the sensor reading when a single water droplet is present on it. After the configuration sequence has ended, the host MCU monitors the state of the DETECT signal provided by the MTCH9010. When water (rain) is present on the sensor, the DETECT signal transitions to logic-high and the host MCU initiates the clockwise driving sequence for the stepper motor, extending the roof (tarp). If no liquid is present on the sensor, the DETECT signal transitions to logic-low and the MCU initiates the counter-clockwise driving sequence, retracting the roof. Two mechanical endstop switches are used to determine if the roof is completely extended or retracted. The motor is stopped as soon as either of the switches is activated.

The Stepper Driver Board also features two push buttons. The first button (SW1) allows the user to switch control of the system between the MTCH9010 and manual control using the second button (SW2). A short press on SW1 will switch the control to Manual mode while a long press will allow the MTCH9010 to take control of the system. In Manual mode, a short press on SW2 will initiate a clockwise driving sequence, extending the roof and a long press will initiate a counter-clockwise driving sequence, retracting the roof. The driving sequence can be interrupted at any time by another short press on SW2.


Setup

MTCH9010 Evaluation Kit settings:

  • LOCK: OFF
  • ECFG: ON
  • USB Bridge: OFF

Note: In Enhanced Configuration mode, the slide switches for OUTPUT, MODE and Sleep Period are bypassed, as these parameters are configured through serial communication.

Note: When powering the board externally through the I/O header (top left corner of the board), the jumper cap on the power header (bottom left corner of the board) must be removed to prevent potential damage to the board.

AVR16EB32 MCC settings:

  • Clock control:

  • Interrupt Manager:

  • Configuration Bits:

  • Brown-out Detector:

  • TCE0:

  • WEX0:

  • ADC0:


  • UART0:

  • USART0_Peripheral:

  • RTC:

  • Pins:

  • Pin Grid View:

Wiring diagram


Demo

Photo of the complete assembly, front side:

Photo of the complete assembly, back side:

Photo of the mounting bracket:

Close-up of the MTCH9010 Evaluation Kit next to the stepper motor:

Close-up of the Stepper Driver Board:

Close-up of the liquid detection sensors:

Assembly in action:

Summary

The project shows how to create a smart roof application using the AVR16EB32 MCU and MTCH9010 Liquid Detector.

How to Program the Microcontroller

This chapter demonstrates how to use the MPLAB X IDE to program an AVR device with an Example_Project.X. This is applicable to other projects, too.

  1. Connect the board to the PC.

  2. Open the Example_Project.X project in MPLAB X IDE.

  3. Set the Example_Project.X project as main project.
    Right click the project in the Projects tab and click Set as Main Project.

  4. Clean and build the Example_Project.X project.
    Right click the Example_Project.X project and select Clean and Build.

  5. Select PICkit 5 in the Connected Hardware Tool section of the project settings:
    Right click the project and click Properties.
    Click the arrow under the Connected Hardware Tool.
    Select PICkit 5 (click SN), click Apply and then click OK:

    Note: Other PICkit versions can be used as well.

  6. Program the project to the board.
    Right click the project and click Make and Program Device.



Menu

About

This repository contains a solution for an automatic retractable roof system based on rain presence. The solution uses MTCH9010 for water detection and the AVR16EB32 as a host device.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published