project2 team2 - CourseReps/ECEN489-Fall2015 GitHub Wiki
Team 2
Responsibilities
- Hai - 3D printing and design
- Kaimen - PCB Design, Hardware and Sensors
- Austin - Arduino Code, PID, Communication and Qt
3D printing
We are given three acrylic tubes. There sizes are 3.5 inches, 1.25 inches, and 0.375 inches in diameter. The 3.5 inches one is used to make reservoir. The 1.25 inches one serves as the support and the 0.375 inches one is used as the return tube. Our object is to design a funnel and a cap for the reservoir. The funnel is cone shape connecting the bottom of the reservoir and the top of the drop tube. Also in order to hold the funnel a bracket is added on the right side of the funnel which is attached to the support tube.
The cap is half circle shape. Same as the funnel, the cap has a bracket attached to the support tube. The cap has a slot for the IR sensor and a hole for the return tube.
Arduino Code
Our Arduino Code for Project 2 was largely similar to the Arduino Code for Project 1. Our main loop in the Arduino Code does 4 things:
- Read values from the various sensors
- Use the PID Controller to adjust the pump rate
- Check for incoming data on the bluetooth module (to set a new Setpoint)
- Write the sensor values out from the bluetooth module
PID Control
We used a PID Controller to control the rate of the pump to adjust the height of the water. We used the Arduino libaries for PID controllers, which take care of everything except for finding the coefficients. For our coefficient calculation, we used the Ziegler-Nichols Method. Using this method, we obtained a Proportional value of 2.7, an Integral value of 5, and a Derivative value of 1.125. We tried two different methods for the input value to the PID controller: The height of the water, and the analog value from the IR sensor. We chose the analog value for the reason that it greatly reduced the amount of calculation done. Rather than convert the analog value to a height every loop, we simply did this once to set the Setpoint on the PID controller.
Communication
We used a bluetooth module on our board to communicate with our computers. This bluetooth module would write out the following:
- Water Height (as judged by the IR sensor)
- Pump rate
- Solenoid State
- Team Name
In comma separated value format. We also had a computer that was connected to the bluetooth module, and used a bluetooth manager for Linux to be able to use the bluetooth connection as a regular serial port. On this computer, we ran a server that would listen for requests. The two requests it listened for were "get_data" and "send_data". "get_data" would read the latest values from the bluetooth port, extract the values, and send back the values packed in a JSON object. "send_data" would send an integer value to the bluetooth, signifying the height for the water to be set at.
On another computer, we ran a client that would periodically send the "get_data" command to the server, and parse the resulting JSON object for the values to write to a MySQL database.
Data Visualization
We used a Qt application very similar to Project 1 to visualize the data for Project 2. This Qt application ran on the same computer as the above-mentioned client, and read directly from that database. Our Qt application had 4 graphs: IR sensor value, pump rate, setpoint for height, and solenoid state. It also has a selection box on the top of the graph, where the user can select a height to set the water to. Once the "Set Height" button is pressed, the height value is sent with the "send_data" command to the server, which in turn sends the value via bluetooth to the teensy (which makes sure that it is a valid height, and then sets the PID setpoint to that value). The below photo, as you can probably tell, is not from an actual run on the system, but is there to demonstrate what the Qt application looks like.
PCB Design
We used KiCAD to build and design our PCB. We built a schematic based on the working model of our breadboard design. Using the KiCAD Tutorial as a guideline, we built the PCB. A copper ground-plane was implemented on the front and back of the board according to standard practice. Care was taken to space out the heat generating parts such as the voltage regulator and the transistor used for PWM from other sensitive parts such as the Teensy. The schematic is shown here:
The PCB design is shown here: