project2 team3 - CourseReps/ECEN489-Fall2015 GitHub Wiki
Team Members
- Pranay Kumar
- Kan Zhang
- Jinpeng You
Responsibilities
- Create working PID Arduino Code for Teensy 3.1 to manage water levels.
- Communication between Nuc (via QT) and Teensy to determine setpoints and relay values.
- Fabrication of PCB and 3-D Printing of water plant model.
Water Management System
Overview
The purpose of project2 is to build a water management system for controlling the water level remotely. The water management system consists of a working water reservoir system, a PCB that integrates various sensors to a teensy development board and a Qt interface for visualizing and setting the state of physical entities like water level and pump rate in pseudo real time. Building this system involves the following tasks
- 3D modeling of components required to build a working water reservoir system
- PCB design for integrating various sensors to a teensy development board
- Implementing PID control in teensy for managing a consistent water level
- Developing Qt interface for visualizing and setting the water level and pump rate.
The hardware used for this project consists of a IR sensor for measuring the water level in the reservoir, a pump, a Bluetooth module and a teensy development board.
3D Modeling
The water reservoir system is built using a 1. Reservoir - a acrylic tube of diameter 3.5 inches, 2. Return tube for liquid of diameter 0.375 inches, 3. Support - a acrylic tube of diameter 1.25 inches, 4. Base tank filled with water and 5. Two custom designed holders for holding the reservoir, return tubes & sensors.
The custom designed holders are modelled using SolidWorks. One of the holders is used at the end of the floating reservoir and is designed as a funnel with small brackets on its surface. The small brackets hold the floating reservoir at the bottom and return tube at the middle and the funnel connects the reservoir tube to small tube that controls the water flow to the base tank.
The other holder is used at the top and is designed to hold IR sensor, PCB, reservoir and return tube.
PCB Design
Tool: KiCad In total, There are three steps to design a PCB board:
- Eeschema design
- Footprint edit
- PCB design
Eeschema design
As is shown below, the circuit contains many electrical components, which may be in libraries or not. If the component is not in libraries, it should be created by ourselves using library editor.
Footprint edit
For each component, there is a specific footprint for PCB design. The footprint of component may also exist in libraries or not. So if the footprint of component is not shown in libraries, we need to draw the footprint ourselves. For example, following picture shows the footprint of Teensy.
PCB design
Through placing footprint, track and zone on the board, we finally get the PCB file which can be print on PCB machine.
PID Control
Project 2 consists of programming the controls for managing desired water levels. PID library was used to program the Teensy board through Arduino IDE. We used the IR readings as input for the PID control function, pump voltage as output and desired height as setpoint.
The error is the difference between the setpoint height and actual height of water. The coefficients that are being used, Kp, Ki, Kd, will determine how the setpoint is reached and the change at which pump rate increases/decreases. The IR sensor is reading distance using analog pins, returning a value between 0-1023. The value is then calibrated and converted to centimeter values in order to determine how far away the water level is from the setpoint. PID controls will then provide the appropriate pump voltage to increase or decrease the water level to meet the setpoint.
We used very passive coefficients for our PID control to ensure that the pump does not jump from highest voltage to 0 whenever the setpoint is not met. It will gradually decrease in voltage once the setpoint is almost met, and will have a consistent pump speed once the setpoint is hit.
To meet the desired setpoints in centimeter precision, we calibrated and tested the IR sensor to every centimeter, from 2 to 15, then hard coded the value range for each in order to provide the same range to the user.
In order to interact with the user, Bluetooth is used to communicate with the user's Qt GUI.
Qt Interface
The Qt interface for visualizing and setting the water level and pump rate is shown below. The Interface consists of three plots for IR Sensor value, pumprate(in voltage) and lowrate w.r.t time in hh::mm:ss format and three frames to control relay state, to start/stop teensy and to set water level at the desired height. The graphs are plotted in pseudo real time with the data received from the teensy over Bluetooth.