Overview

You are going to build water cooling control systems for growing Algae bio fuels. In this design exercise you will cover some engineering design processes, i.e. from modeling to simulation and finally building the prototype. These steps are divided into three parts as described below. We expect all students should be able to complete Part 1 and most students to complete Part 2. We provide Part 3 as an open design challenge.

Part 1

In this part you will need to do the following:
  • Write a function to read the temperature from a temperature sensor using Raspberry Pi.
  • Write a function to output a PWM signal to control the water pump and the DC fan using Raspberry Pi.
  • Use the state machine class to set the output based on the input.
  • Set a target temperature.
  • Write a program that continuously call the function to read the temperature, move the state machine to the next state and use the output to output a PWM signal.

To implement the state machine class you must use sm.SM class. The class should implement the following:
  • The state machine takes in temperature as the input.
  • The state machine outputs a tupple. The tupple consists of two numbers. The first number is the power output for the water pump and the second number is the power output for the fan. This power output is a float ranges from 0.0 to 1.0.

For this part, you need to demonstrate that the output speed of both the water pump and DC fan must change as follows:
  • If the temperature is above a target temperature, both the water pump and DC fan will be on with 100% power.
  • If the temperature is below the target temperature, both the water pump and DC fan will be off.

Due date: 2nd of April, 11:59PM, Submit code on eDimension Week 10.

Part 2

Part 2.1: Heat Exchanger controller

Your task is to design the controller:
  • Decide what kind of controller you will use? Proportional or Proportional-Derivative controller? Explain your choice.
  • What is the gain value you use in your controller? How do you decide on the values of the gains?
  • Modify your code in Part 1 to include the controller.

Part 2.2: Test Program

Your task to write a GUI application to test your controller state machine. The GUI application must satisfy the following:
  • You must use Kivy for your GUI library
  • The application allow the user to set the target temperature of the system. Decide what should be the value of this target temperature.
  • The application allow the user to change and modify the temperature of the system with some intuitive graphical user interface.
  • The application should consist of the state machine you did in Part 1. The state machine continuously read the temperature of the system as set by the GUI. The read temperature is fed in as input to move the state machine to the next time step, and produce its output.
  • The output of the state machine should be displayed in the GUI application. You should be able to see the power of the water pump and DC fan increase when the system's temperature is above the target temperature. Those output powers should change as the temperature change according to your controller.

Note that the test program in part 2.2 need not be implemented with the real sensor, water pump, and DC fan. It is purely software. We will do the real implementation in Part 3.

Due date: 12th of April, 12:00PM, Submit code on eDimension Week 12.

Part 3

Part 3.1: Prototype

Your task is:
  • to implement the controller in a real system, which you built from Physical World with actual temperature sensors, water pump, and DC fan.

Part 3.2: Hardware-in-loop simulation

Your task is to convert your test program in Part 2.2 into a HIL (Hardware-in-loop) simulation.
  • The controller is implemented using Raspberry Pi.
  • The plant in this case is the water cooling system and the Algae container. It is implemented as a simulation environment in Simpy. You can host the simulation on a PC or on the same Raspberry Pi. See figures 1 and 2 below.
  • To implement a HIL simulation, you will need to use RealtimeEnvironment.
  • Use Container in Simpy to emulate the temperature of the system as a shared resource. You can define other shared resources in the environment.
Your task is define and implement Processes that increase and decrease the temperature of the system.
  • Discuss what are the processes that increase the temperature.
  • Discuss what are the processes that decrease the temperature.
  • Discuss what are the shared resources in those processes.
  • Discuss how to implement those processes and shared resources using Simpy.
See if you can do the following:
  • Simulate the change in temperature at night time and day time.
  • Measure power consumption for a week.
  • Optimise output power consumption.
Note that defining these processes and shared resources is an open question. The more you integrate what you learn in other subjects, the more points you will get.
part3_pi_pc.png
Figure 1. You can use Raspberry Pi as the controller that reads the temperature data from the simulation. The simulation of the plant can be hosted on a PC. The data is transferred over a serial communication. The Raspberry Pi will send the output of the motor to the simulation plant. You can use pyserial library for the serial communication.
part3_pi_alone.png
Figure 2. You can use Raspberry Pi as both the controller and the simulation plant by running two processes. You need to figure out how to communicate between two process. The simplest maybe by writing and reading a file. But there are better ways to do it.

Due date: 11th of April, 11:59PM, Submit code on eDimension Week 12.

Grading

Total group points: 10 points
Part 1: 4 points

Poor
0 point
Average
1 point
Good
2 points
Demo
Students did not manage to demo the required task.
Students demonstrate the task with some bugs or error.
Students successfully demonstrate the required task.
Explanation
Students were not able to explain the code or the hardware.
Some students are able to explain the code and the hardware. Some others are not able to explain well.
All members in the group are able to explain the code and the hardware.

Part 2: 3 points

Poor
0 point
Average
0.5 point
Good
1 point
Demo
Students did not manage to demo the required task.
Students demonstrate the task with some bugs or error.
Students successfully demonstrate the required task.
GUI
GUI is poor or did not work as required.
GUI functions as required.
GUI is intuitive, beautiful, and professional. GUI functions as required.
Code
Code is written with no documentation. Code is written without any object oriented or modular design in mind.
Code is written with little documentation or poor documentation. Apply some object oriented or modular design, and yet can be written or designed better.
Code is written and documented properly. Apply object oriented design and modularity appropriately.

Part 3: 3 points


Poor
0 point
Average
0.5 point
Good
1 point
Prototype
Students are not able to demonstrate the controller working under varying temperature.
Students demonstrate the controller. However, students are not able to control the flow rate for different temperature.
Students are able to demonstrate the controller under varying temperature. Students are able to vary the water flow rate for different temperature measured.
Simulation
Simulation does not model the physics of the heat exchanger.
Simulation is able to model the physics of the heat exchanger. Students use simple model for the heat extraction. Students are able to explain some of the code or the model.
Simulation is able to model the physics of the heat exchanger. Students are able to explain the code and the model.
Code
Code is written with no documentation. Code is written without any object oriented or modular design in mind.
Code is written with little documentation or poor documentation. Apply some object oriented or modular design, and yet can be written or designed better.
Code is written and documented properly. Apply object oriented design and modularity appropriately.


Group points contribute to 60% of total 2D points.
2D Quiz points contribute to 40% of total 2D points.

References