Application of Microcontroller
Application of Microcontroller
But the signal from the sensors is analog and MCU does not
understand it.
Pa.2 P b.0
to LM
Pe.2 p b.7 35D
Osc1 Pd.0
Osc2
pd.7
20 To
Solid
state
relay
Initialize, I/O
PORTs,
LCd, ADC ,
Variables,
Conversion
once in 15s
No
Is No
Act.Value> Is Act.Value Is Act.Value
SP <SP ==SP
Off Heater & On Fan ON Heater & Off Fan Off Heater & Off Fan
Material Required:
Pic Microcontroller
Bipolar Transistor
Relay
Capacitor
Crystal
Resistor
Diode
void main() {
unsigned int temp;
float mV, ActualTemp;
const float SET_POINT = 30.0; // Set point temperature
PORTD = 0;
TRISD.f0=TRISD.f2=0;
INTCON = 0; // All interrupts disabled
ADCON0 = 0x40; // Pin RA2 is configured as an analog
input
TRISA = 0x04; while (1) {
ADCON1 = 0x80; // Rest of pins are configured as digital temp = ADC_Read(0); // A/D conversion. Pin RA0 is an
TRISA = 0xFF; // All port A pins are configured as inputs input.
ADCON0.F0=1;//ADC module on mV = temp * 5000.0 / 1023.0; // convert to millivolt
PIR1.F6 = 0; // interrupt setting ActualTemp = mV / 10.0; // convert to degree celcius
PIE1.F6 = 0; if (ActualTemp > SET_POINT) {
INTCON.F6 = INTCON.F7 = 1; portd.f0 = 1;
Delay_ms(2000); portd.f2 = 0;
ADCON0.F2 = 1; }
else if (ActualTemp < SET_POINT) {
portd.f0 = 0;
portd.f2 = 1;
}
else {
portd.f2 = 0;
portd.f0 = 0;
}
delay_ms(1000);
}
}
Material Required:
Pic Microcontroller
Bipolar Transistor
Relay
Capacitor
Crystal
Resistor
Diode
Example: Temperature Reading and Control
LM35 temperature
sensor converts
temperature into its
proportional analog
voltage value.
LM35 is three terminal
device.
Pin number one and
three are for 5- volt
voltage supply.
Pin two is analog voltage
output with respect to
temperature value.
Relation between
measured temperature
and analog output
voltage is: 1 oC = 10m volt
Select A/D input channel (ADCON0)
Data to LCD
MCU’s guide
on how to
control the
temperature
To
Solid PIC16F84a
state 40
relay EA Vcc
Vin
Pa.2 P b.0 D0
to D7 A/D
p b.7
Osc1 Pa.1 OE
Osc2 LM
pa.0 SOC
20 35D
Wait for
conv. time
Call ADC
Issue OE
signal
No
Is No
Is Act.Value Ret
Act.Value>
UL <LL
Yes Yes
Off ON
Heater Heater
Water Level Controller using e-level sensor
Note: 1) Refer to the data sheet of e-level sensor . and write theory on level sensor
(Resistance inverse to Level)
nothing. It simply waits for some time to pass. Such waste of time is an unacceptable
An interrupt is generated on every timer register overflow and every interrupt routine
When it’s value reaches 400, the port B is incremented by 1. The whole procedure is
performed ‘behind the scenes’, which enables the microcontroller to do something else.
Further Read C-Programming for PIC
Assignment
DC MOTOR SPEED
CONTROL
Using Microcontroller!