Skip to content

project2 team4

Travis Taghavi edited this page Nov 9, 2015 · 11 revisions

#Scope

The goal of this project is to build a draining environment to test flow control of the pump using PID. The draining environment is similar in concept to that of a water tower. The water drains from a upper reservoir to a lower reservoir at a set rate while an IR sensor in the upper reservoir communicates with the arduino to control the pump rate to set the water level at specific heights.

Project 2 Diagram

This project will be build on top of Project 1 using an additional heigh adjustment bar in the QT interface, PID control of the pump, an enclosed testing environment, custom 3D printed connectors for the testing environment, and a PCB to replace the breadboard used in Project 1.

#Components of Project

QT Configuration

The QT and QCustomPlot code is very similar to that of Project 1. There is still a server which is connected to the Teensy via Bluetooth, and then provides data packets (in JSON format) upon request. Clients can then poll a number of servers, and place their information into a SQLite database.

The QT application then reads from this database in order to provide (pseudo)real-time plots of pump rate, IR range, and possibly flow rate/solenoid state. When the database contains data from more than one "device", a different curve is plotted on each of these four graphs.

One key addition to the QT application for this project is the ability to send a new PID setpoint (representing the water height in this case) to the Teensy. This was implemented using a textbox and a pushbutton. Upon the button being pressed, the textbox is read, and, if possible, the value is converted to a double in order to be sent to the Teensy.

QT App

3D Printing and Structure Layout

The complete design is to be constructed using clear plexiglass tubes of varying dimensions held together with custom 3D printed parts. In order to build a free-standing structure to support the system, we created two models to be 3D printed using Solidworks CAD software. The first of two is a funnel which attaches to the main support by the center bracket. The funnel is attached beneath the floating reservoir to allow the liquid to flow directly into a small tube that directs the water into a base tank. On the opposite side of the funnel is a smaller bracket which attaches to a small tube directing liquid flow back into the floating reservoir.

The second model acts as a cap for the floating reservoir. It attaches to the main support by its center bracket. Water flow is directed from a small tube back into the reservoir. It also includes a slot for the IR sensor so as to be directly above the liquid for optimal readings.

While the parts are currently being constructed, an improvised version of the setup was built using two plastic cups separated vertically by a piece of plywood. The tubing goes from the bottom cup filled with water through the pump to the top of the upper cup. The upper cup has a hole cut in the bottom to allow draining. Different draining speeds is controlled by covering up the hole with different amounts of duct tape. An IR sensor is held above the water level while testing is occurring.

PCB Design

First step of PCB design is to create a schematics in order to visualize the circuit. More importantly circuit should have been tested throughly to make sure our final product works fine. Components that do not have saved design in library should be newly drawn. Mark all the pins are not used as X and connected pins should follow electrical rules in order to create netlist.

After creating netlist we need to select footprint for each component then export to pcb new for actual Printed Circuit Board Design.

Now we are readly to read from the saved netlist. When you read from netlist it will automatically extract footprints and connection from previous steps. Spread out components with minimum crossover. We can manually connect traces but in this case the circuit is simple enough that we can use autoroute. Green traces are in the back copper plane and red traces are in the front copper plane. Edge cuts determine the size of the board.

Set front and back planes as ground planes; adjust no connect zone properly to avoid unexpected crossovers. Finally we can create Gerber files of two copper sides, edge cuts, and a drill file to be sent for printing.

IR Sensing and PID Controls

To properly relate the IR to distance, the output of the serial port needed to be taken with relation the distance it was measured at. Multiple readings were taken every 2 cm and plotted via Matlab and Microsoft Excel. A power function was fit to the data points to generate accurate estimations for all distances not manually entered. The generated power function is used in the arduino code to determine accurate distance readings.

The PID controls...

For the PID, we used the standard Arduino PID library linked from this website.. A "controller" is constructed with references to doubles for Input, Output, and Setpoint, as well as constant values for P, I, and D. From there, each loop of the Teensy code will assign the IR reading to the Input variable, and write the Output value to the pump. When it receives data from the Bluetooth serial port, it will parse the value and write it to the Setpoint.