Categories
Tech

CPU Info Checker with Fan Speed Controlling

Category: Project Proposal

Topic: CPU Info Checker with Fan Speed Controlling

Subject: CSE323 – Operating System Concepts

In this Arduino based project, we are going to control DC fan speed according to the room temperature and show these parameter changes on a 16×2 LCD display. It is accomplished by the data communications between Arduino, LCD, DHT11 sensor Module and DC fan that is controlled by using PWM. PWM is a technique by using which we can control voltage.

Circuit Components

  1. Arduino UNO
  2. DHT11 sensor
  3. DC Fan
  4. 2n2222 transistor
  5. 9 volt battery
  6. 16×2 LCD
  7. 1K resistor
  8. Connecting wires
  9. LED Light

Description:

This project consists of three sections. One senses the temperature by using humidity and temperature sensor namely DHT11. Second section reads the dht11 sensor module’s output and extracts temperature value into a suitable number in Celsius scale and control the fan speed by using PWM. And last part of system shows humidity and temperature on LCD and Fan driver.

Fan speed and PWM values and duty cycles values that we are going to use is showing in given table:

TemperatureDuty CyclePWM ValueFan Speed
Less 260%0Off
2620 %5120%
2740%10240%
2860%15360%
2980%20480%
Greater 29100%255100%
Fan Speed & PWM Values

Fan speed control technique:

 A low-frequency pulse-width modulation (PWM) signal, usually in the range of about 30Hz, whose duty cycle is varied to adjust the fan’s speed is used. An inexpensive, single, small pass transistor can be used here. It is efficient because the pass transistor is used as a switch.

One disadvantage of this approach, however, is that it can make the fan noisy because of the pulsed nature of the signal. The PWM waveform’s sharp edges cause the fan’s mechanical structure to move (like a badly-designed loudspeaker), which can easily be audible.

Circuit Diagram:

We will implement that circuit and add some extra features & sensors that will help to check proper info of CPU usage.

Fig. : Circuit diagram of the temperature-based fan speed control and monitoring CPU usage using Arduino

Categories
Programming Tech

Fractional Knapsack Problem – Programming Solution

Fractional Knapsack Problem Question:

You are required to implement the fractional knapsack problem using a programming language of your own choice. You are going to take the number of items, their weights, volume and costs 5 from the user as well as the knapsack capacity and determine the maximum value that can be 6 taken. Also, print out the items and its quantities that can be taken.

Background:

An efficient solution is to use Greedy approach. The basic idea of the greedy approach is to calculate the ratio value/weight for each item and sort the item on basis of this ratio. Then take the item with the highest ratio and add them until we can’t add the next item as a whole and at the end add the next item as much as we can. Which will always be the optimal solution to this problem.

A simple code with our own comparison function can be written as follows, please see sort function more closely, the third argument to sort function is our comparison function which sorts the item according to value/weight ratio in non-decreasing order.
After sorting we need to loop over these items and add them in our knapsack satisfying above-mentioned criteria.

A greedy algorithm has five components:

  1. A set of candidates, from which to create solutions.
  2. A selection function, to select the best candidate to add to the solution.
  3. A feasible function is used to decide if a candidate can be used to build a solution.
  4. An objective function, fixing the value of a solution or an incomplete solution.
  5. An evaluation function, indicating when you find a complete solution.

Solution:

Output:Execution of Fractional Knapsack Problem

Execution - Fractional Knapsack Problem

View More samples: Here!

There are two critical components of greedy decisions:

  1. Way of greedy selection. You can select which solution is best at present and then solve the subproblem arising from making the last selection. The selection of greedy algorithms may depend on previous selections. But it cannot depend on any future selection or depending on the solutions of subproblems. The algorithm evolves in a way that makes selections in a loop, at the same time shrinking the given problem to smaller subproblems.
  2. Optimal substructure. You perform the optimal substructure for a problem if the optimal solution of this problem contains optimal solutions to its subproblems.

Github: implementation

Reference:

  • https://www.guru99.com/fractional-knapsack-problem-greedy.html
  • https://www.geeksforgeeks.org/fractional-knapsack-problem