Professional Documents
Culture Documents
Dhulikhel, Kavre
ASSIGNMENT NO:3
Group: EE-Communication
Roll No:31052
Digital to Analog converter is an electronic circuit in which the binary form of signal (0’s and
1’s) to analog signal. In this circuit design, R-2R ladder method is used to design a 5 bit DAC.
1.Construction:
R- 2R ladder circuit is made by adding combination R & 2R resistor in cascaded form.
Each stage contains R-2R for each bit. The switch is connected between Vref and
Ground. This is controlled by binary input.
2.Digital Input and Switches:
Each tap is connected to a switch and rest of the other digital input bit. When bit is high
(1), the switch connects to a reference voltage (positive supply). When bit is low (0), the
switch connects to the ground.
3.Current Division and Summation:
The reference current (Iref) flows through the ladder, dividing equally at each tap
where a switch is closed (MSB side tap receives half the current compared to the LSB
side tap, and so on). Current from activated taps (based on the input bits) is then
summed using operational amplifiers (op-amps) to generate the final analog output
voltage.
4.Output voltage calculation:
For example, for the given switch position in the proteus i.e., 11111.
= 4.88 V
This output voltage is given to non-inverting terminal of another amplifier to convert the
output voltage from negative to positive value.
2. Develop a fuzzy logic controller for a particular application of your choice and
implement it with the help of Arduino or other microcontroller.
This project is automatic detection of harmful gas in atmosphere in smart kitchen system
using fuzzy logic controller. The system embedded system consists of Control unit i.e.,
Arduino which acts as a brain to control all the activities of the circuit, Sensing element i.e.,
gas sensor(MQ-135) which detects the presence of gas in the atmosphere, Power unit to
power the electrical equipment for the optical performance and Control element i.e., fan to
vary the output based on gas concentration.
The overall components of the circuit are shown below:
BATTERY
DC FAN(FAN)
GAS
SENSOR ARDUINO
WITH FUZZY
RULES
The system uses a Fuzzy Logic Controller (FLC) to ensure safety in a smart kitchen. The
fuzzy logic works with a combination of rules (conditions) that determine whether the
current environmental condition is disastrous or not. The sensor readings from the gas and
send values to the ARDUINO. Using these readings, the FLC on the Arduino determines
whether the conditions are safe or not and hence, sends an appropriate signal to turn on
the fan. The speed of the fan is decided based on the concentration of gas in the
surroundings using fuzzy logic controller. The fan’s speed will be neutral below the
threshold value and above this value the speed of the fan changes.
RULES
INFERENCE
Low Slow
Moderate Medium
High Fast
Software Simulation:
The circuit was implemented using DC fan,transistor as relay and diode as well as external
supply. Relay acts as a electronic switch which can which take really small amount of power to
drive high power equipments. For this relay switch circuit npn transistor was used as a relay.
Transistor works faster than relays for on/off swithching circuit.
Since,the Arduino can only provide 40mA to its digital pin at 5V,which is enough to light on the
LED but not the fan.So, external power supply is provides through the circuit. The transistor is
PMW’ed. Higher the value of PMW,higher will be the speed of fan and vice-versa. Since,the
speed of fan is predictd by the Fuzzy Logic based on the concentration of the gas in the
surroundings. This value is provided to the PMW pin i.e., Pin 9 of Arduino. If the concentration
of gas is higher,the the fan will spin at higher speed, if moderate fan will spin at moderate
speed and high concentration the fan will spin at high speed.
Electric fans function through a process known as induction, where the flow of electric charge
in a wire creates a magnetic field. Coiling the wire enhances the magnetic field, and in DC fans,
this field interacts with magnets to drive movement. When a fan stops, a diode can be used to
prevent potential damage from the small current generated as the shaft continues to spin. Fans
draw the most current during startup or when carrying a load, with stall current representing
the amount of current when forcibly stopped.
The voltage rating signifies the optimal operating voltage for a fan, and deviating from this
rating, whether higher or lower, can impact the fan's lifespan. Providing less than the rated
voltage may result in slower fan speed, and insufficient voltage during startup may prevent
movement. Understanding these principles is essential for effective fan design and operation.
Figure: Simulation of the circuit
Simulink output:
Hardware Implementation:
MQ-135 sensor was used to take the analog input from sensor and provide it to the
Arduino. The fan speed was varied by using the PWM pin of Arduino i.e., Pin 9. In this pin,
the 0 value gives 0% duty cycle whereas 255 value fives 100% duty cycle.
Arduino code:
#include <Fuzzy.h>
// Fuzzy
Fuzzy *fuzzy = new Fuzzy ();
// FuzzyInput
FuzzySet *low = new FuzzySet(100, 350, 350, 600);
FuzzySet *moderate = new FuzzySet(500, 750, 750, 1000);
FuzzySet *high = new FuzzySet(900, 1500, 1500, 2000);
// FuzzyOutput
FuzzySet *slow = new FuzzySet(20, 35, 35, 50);
FuzzySet *medium = new FuzzySet(40, 70, 70 ,100);
FuzzySet *fast = new FuzzySet(80, 120, 120, 150);
void setup()
{
// Set the Serial output
Serial.begin(9600);
// FuzzyInput
FuzzyInput *ppm = new FuzzyInput(1);
ppm->addFuzzySet(low);
ppm->addFuzzySet(moderate);
ppm->addFuzzySet(high);
fuzzy->addFuzzyInput(ppm);
// FuzzyOutput
FuzzyOutput *speed = new FuzzyOutput(1);
speed->addFuzzySet(slow);
speed->addFuzzySet(medium);
speed->addFuzzySet(fast);
fuzzy->addFuzzyOutput(speed);
// Building FuzzyRule
FuzzyRuleAntecedent *ifppmlow = new FuzzyRuleAntecedent();
ifppmlow->joinSingle(low);
// Building FuzzyRule
FuzzyRuleAntecedent *ifppmmoderate = new FuzzyRuleAntecedent();
ifppmmoderate->joinSingle(moderate);
// Building FuzzyRule
FuzzyRuleAntecedent *ifppmhigh = new FuzzyRuleAntecedent();
ifppmhigh->joinSingle(high);
void loop()
{
// Read the analog value from the gas sensor
int sensorValue = analogRead(A0);
fuzzy->setInput(1, ppm);
fuzzy->fuzzify();
analogWrite(9,speed);
delay(1000);
// wait 1 second
delay(1000);
}
The circuit was successfully implemented on the breadboard where motor was used as a
fan. The fan was off below 100ppm and then it changes its speed according to the
increasing/decreasing gas concentration in the atmosphere.
The YouTube link for the video is Automatic Gas sensor Exhaust Fan using Fuzzy Logic
(youtube.com)
FIGURE: HARDWARE IMPLEMENTATION OF THE CIRCUIT
FIGURE: HARDWARE IMPLEMENTATION OF THE CIRCUIT