project1 team2 - CourseReps/ECEN489-Fall2015 GitHub Wiki
Project 1 - Team 2
Sensing, Actuation, and Data Visualization
Members and Responsibilities
- Pranay Eedara - Interfaces and Networking
- Kan Zheng - Data Visualization
- Anthony Ramirez - Hardware
Hardware
To measure the flow rate from hall sensor, the teensy program uses a interrupt that is called upon receiving a rising edge from hall sensor and counts the number of times that interrupt is called for one second. The count is multiplied with a constant(0.053) to get the flow rate in ml/sec.
The hall sensor is calibrated by measuring the flow rate six times as the voltage supplied to pump increases from 2 to 9 periodically. The following plot between flow rate and the pump rate shows the measured flow rate values at different pump rates and a linear first degree polynomial that fits the data points. The curve fitting code and the database can be found here
Interfaces and Networking
-
The teensy board communicates with the NUC using Bluetooth. It uses the SoftwareSerial library to send the sensor data over Bluetooth. For every 1sec, the teensy board reads the measurements from IR sensor, Hall sensor and sends them along with relay state and pump rate to the NUC.
-
The NUC communicates with the central server using TCP connection and with the TeensyBoard using Bluetooth. It uses Qt Bluetooth API to establish the Bluetooth connectivity with the teensy board, and Boost libraries to establish the TCP connection with the central server.
The NUC communicates concurrently with the teensy board and the central server using QThreads. The communication with the teensy board is implemented in the main thread whereas the communication with the central server is implemented in a worker thread. In main thread, the NUC receives the data from the teensy board periodically and stores them along with team ID and timestamp into a database with table name 'DATA' and with columns as follows
DATA (DeviceID TEXT,Timestamp TEXT, IR_sensor TEXT, RelayState TEXT, Voltage TEXT, Flowrate TEXT);
In worker thread, the NUC listens for a TCP connection from the central server and upon accepting a socket connection, it sends the latest data from the database to the central server in the following JSON format.
{ "ID":"TeamName", "IRRange":"xxx", "PumpRate":"xxx", "FlowRate":"xxx", "SolenoidState":"ON/OFF", "Timestamp":"Unix epoch", "CurrentIP":"xx.xxx.xxx.xx" }
-
The central server communicates with all the NUC's using tcp connection and polls the NUC's periodically to get the latest data from the NUC's database till that timestamp and upon receiving the latest data, it stores them into a database.
The programs for above can be found here.
Data Visualization
IDE: Qt creator 3.5.0 (Qt 5.5.0 for Linux 64-bit) with QcustomPlot widget
In the part of Data Visualization, datas in database are shown in visualizing interface. There are three graphs and one switch in the interface:
- Graph 1: Show the curves of flow rate on time
- Graph 2: Show the curves of pump rate on time
- Graph 3: Show the curves of distance on time
- Switch: Show the state(open/close) of solenoid
For the client, each graph has one curve showing the data got from each local hardware.
For the central server, each graph has the whole curves from different clients.