8/2/2019 colz doc(1)
1/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 1
1.INTRODUCTION
1.1 MICROCONTROLLER BASED AIR DRYER
The operation of the dryer is under the control of a MCU through a pneumatic
micro-solenoid valve set. Instrument pressure gauge indicates condition of each air
operated valve. Air pressure On=valve Open. A mimic board on the control panel
also indicates the state of the valves. When the dryer is operating, the MCU outputs
energize the electro-pneumatic solenoid control valves SV1-SV6. Solenoid SV1 and SV2
: control the air supply to the main inlet valves v1 and v2 and instrument gauge pv1 and
pv2. Solenoids SV3 and SV4. Control the air supply to the reactivation purge valves V3
and V4 and instrument pressure gauges PV3 and PV4. Solenoids SV5 and SV6. Control
the air supply to the automatic drain valves V5 and V6 and instrument pressure gauges
PV5 and PV6.
To filter and dry, free air compressed at 400bar saturated with oil/water vapour at
45degrees ensuring the removal of hydrocarbons, true oilvapour to less than 0.005ppm
with final filtration of 1 micron particles and dried to a dewpoint of -65degrees measured
at 760mm Hg. Pre filter: Fitted with a permanent cleanable, stainless steel separator and
replaceable coalescing. It removes large liquid and solid contaminants 3 micron and
larger. Oil adsorption filter: the first stage will reduce the liquid oil content in the air
down to 0.1mg, whilst removing all free moisture and dirt particles. The carbon canister
located in the second stage contains a deep bed of activated carbon which after filtration
can result in oil levels and vapours removed to less than 0.005ppm.
The drying plant consists of two adsorbers which contain sufficient desiccant to
dry the flow of compressed air to the dewpoint required. At the end of each adsorption
period the compressed air inlet valves V1 and V2 are operated and divert the flow of
compressed air to the adsorber which has been freshly reactivated. When the changeover
of the air flow has been completed, reactivation of the desiccant in the adsorber coming
off drying duties is started. The wet compressed air entering the drying plant is diverted
8/2/2019 colz doc(1)
2/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 2
to the adsorber on drying duty by either valve V1 or V2 depending on which adsorber is
on drying duty. The compressed air will then pass up through the desiccant in the
adsorber where the watervapour will be removed from the air and retained in the pores of
the desiccant. The dry compressed air will leave the adsorber through the non-returnvalve and leave the plant via the after filter.
The drying or adsorption period is of 22.5 minutes duration and during this time
the wet compressed air will pass through the adsorber on drying duty. The dryer is fully
automatic under the control of a microcontroller which controls the sequence operation of
the compressed air inlet valves, reactivation purge valves and filter auto-drain valves. The
dryer is controlled using PIC16F887 Microcontroller.
8/2/2019 colz doc(1)
3/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 3
1.2BLOCK DIAGRAM:
Fig1: Block diagram
At Programmable Controller:
Acquisition and Processing of information from analog signals of field
sensors.
Commanding of field elements like control valve.
Execution of process algorithms in cyclic mode.
Parameter display in local LCD display
Alarm
The air dryer system requires programmable interrupt controller for valve
operations, pressure transmitters, and buzzer. Six analog channels are required for this
purpose. PC-UART communication card is required to store the pressure value
continuously for every 1sec for offline analysis. A pressure transmitter is required to
measure the pressure whether it is in the range or out of the range. When the pressure is
low, one LED1 glows with warning alarm1. When the pressure is high, another LED2
glows with warning alarm2.
8/2/2019 colz doc(1)
4/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 4
2.HARDWARE
2.1 Implemented Hardware Circuit Block Diagram:
Fig2.1: Hardware circuit
List of Used Hardware components:
1. 7805 ICvoltage regulator
2. Capacitors -0.33F, 33F,1F
3. Heat Shield
4. Amplifier-UDN 2981(O/P-50 Volts)
5. 24V Power Supply.6. Buzzer
7. Crystal oscillator-8MHz
8. LCD-4x20 display
9. Max 232-IC
10.PIC microcontroller
8/2/2019 colz doc(1)
5/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 5
2.2 PIC 16F887:
2.2.1 PIN DIAGRAM:
Fig2.2.1: Pin diagram
8/2/2019 colz doc(1)
6/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 6
2.2.2 PINOUT DESCRIPTION:
8/2/2019 colz doc(1)
7/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 7
8/2/2019 colz doc(1)
8/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 8
8/2/2019 colz doc(1)
9/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 9
2.2.3 INPUT/OUTPUT PORTS:
In order to synchronize the operation of I/O ports with the internal 8-bit organization
of the microcontroller, they are, similar to registers, grouped into five ports denoted by A,
B, C, D and E. All of them have several features in common: for practical reasons, many
I/O pins are multifunctional. If a pin performs any of these functions, it may not be used
as a general-purpose input/output pin. Every port has its satellite, i.e. the corresponding
TRIS register: TRISA, TRISB, TRISC etc. which determines the performance of port
bits, but not their contents. By clearing any bit of the TRIS register (bit=0), the
corresponding port pin is configured as an output. Similarly, by setting any bit of the
TRIS register (bit=1), the corresponding port pin is configured as an input. This rule is
easy to remember 0 = Output, 1 = Input.
Port A is an 8-bit wide, bidirectional port. Bits of the TRISA and ANSEL registers
control the Port A pins. All Port A pins act as digital inputs/outputs. Five of them can
also be analog inputs (denoted by AN):
RA0 = AN0 (determined by the ANS0 bit of the ANSEL register)
RA1 = AN1 (determined by the ANS1 bit of the ANSEL register)
RA2 = AN2 (determined by the ANS2 bit of the ANSEL register)
8/2/2019 colz doc(1)
10/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 10
RA3 = AN3 (determined by the ANS3 bit of the ANSEL register)
RA5 = AN4 (determined by the ANS4 bit of the ANSEL register)
Similar to bits of the TRISA register determine which of the pins are to be configured as
inputs and which ones as outputs, the appropriate bits of the ANSEL register determine
whether pins are to be configured as analog inputs or digital inputs/outputs.
Each bit of this port has an additional function related to some of the built-in peripheral
units, which will be described in later chapters. This chapter covers only the RA0 pins
additional function since it is related to port A and the ULPWU unit.
Fig2.2.3: MCU I/O Ports
8/2/2019 colz doc(1)
11/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 11
2.2.4 ANALOG-TO-DIGITAL CONVERTER (ADC) MODULE:
The Analog-to-Digital Converter (ADC) allows conversion of an analog input
signal to a 10-bit binary representation of that signal. This device uses analog inputs,
which are multiplexed into a single sample and hold circuit. The output of the sample and
hold is connected to the input of the converter. The converter generates a 10-bit binary
result via successive approximation and stores the conversion result into the ADC result
registers (ADRESL and ADRESH). The ADC voltage reference is software selectable to
be either internally generated or externally supplied. The ADC can generate an interrupt
upon completion of a conversion. This interrupt can be used to wake-up the device from
Sleep.
Fig2.2.4: Block diagram of the ADC.
ADC Configuration
When configuring and using the ADC the following functions must be considered:
8/2/2019 colz doc(1)
12/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 12
Port configuration
Channel selection
ADC voltage reference selection
ADC conversion clock source Interrupt control
Results formatting
PORT CONFIGURATION
The ADC can be used to convert both analog and digital signals. When converting analog
signals, the I/O pin should be configured for analog by setting the associated TRIS and
ANSEL bits. See the corresponding Port section for more information.
CHANNEL SELECTION
The CHS bits of the ADCON0 register determine which channel is connected to the
sample and hold circuit. When changing channels, a delay is required before starting the
next conversion. ADC Operation for more information.
ADC VOLTAGE REFERENCE
The VCFG bits of the ADCON0 register provide independent control of the positive and
negative voltage references. The positive voltage reference can be either VDD or an
external voltage source. Likewise, the negative voltage reference can be either VSS or an
external voltage source.
CONVERSION CLOCK
The source of the conversion clock is software selectable via the ADCS bits of the
ADCON0 register. There are four possible clock options:
FOSC/2
FOSC/8
FOSC/32
FRC (dedicated internal oscillator)
The time to complete one bit conversion is defined as TAD. One full 10-bit conversion
requires 11 TAD periods as shown in Figure .
8/2/2019 colz doc(1)
13/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 13
2.3PIEZO BUZZER:
The piezo buzzer produces sound based on reverse of the piezoelectric effect. The
generation of pressure variation or strain by the application of electric potential across a
piezoelectric material is the underlying principle. These buzzers can be used alert a user
of an event corresponding to a switching action, counter signal or sensor input. They are
also used in alarm circuits.
The buzzer produces a same noisy sound irrespective of the voltage variation
applied to it. It consists of piezo crystals between two conductors. When a potential is
applied across these crystals, they push on one conductor and pull on the other. This,
push and pull action, results in a sound wave.Most buzzers produce sound in the range of
2 to 4 kHz.
Fig2.3 Piezo buzzer
A Piezo buzzer is made from two conductors that are separated by Piezo crystals. When a
voltage is applied to these crystals, they push on one conductor and pull on the other. The
result of this push and pull is a sound wave. These buzzers can be used for many things,
like signaling when a period of time is up or making a sound when a particular button has
been pushed. The process can also be reversed to use as a guitar pickup. When a sound
wave is passed, they create an electric signal that is passed on to an audio amplifier.
8/2/2019 colz doc(1)
14/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 14
2.4 EASYPIC6 Development Board:
The EasyPIC6 development system is an extraordinary development tool suitable
for programming and experimenting with PICmicrocontrollers from MICROCHIP. The
board includes an on-board programmer with mikroICD support (In-Circuit Debugger)
providing an interface between the microcontroller and pc. It is simply expected to write
a code in some of the compilers, generates a hex file and program your microcontroller
using the PIC flash programmer..Numerous on-board modules, such as 128x64 graphic
LCD display, 2x16 LCD display, on-board 2x16 LCD display, keypad 4x4, port expander
etc., allow you to easily simulate the operation of the target device.
Fig2.4: Easypic6 development board
8/2/2019 colz doc(1)
15/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 15
.
Supported Microcontrollers
The EasyPIC6 development system provides eight separate sockets for PIC
microcontrollers in DIP40, DIP28, DIP20, DIP18, DIP14 and DIP8 packages. These
sockets allow supported devices in DIP packages to be plugged directly into the
development board.
There are two sockets for PIC microcontrollers in DIP18 package provided on the board.
Which of these sockets you will use depends solely on the pinout of the microcontroller
in use. The EasyPIC6 development system comes with the microcontroller in a DIP40
package.
Jumpers next to the sockets are used for selecting functions of the microcontroller pins:
8/2/2019 colz doc(1)
16/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 16
PIC microcontrollers normally use a quartz crystal for the purpose of stabilizing clock
frequency. The EasyPIC6 provides two sockets for quartz-crystal. Microcontrollers in
DIP18A, DIP18B, DIP28 and DIP40 packages use socket X1 (OSC1) for quartz-crystal.
If microcontrollers in DIP8, DIP14 and DIP20 packages are used, it is necessary to move
quartz crystal from socket X1 to socket X2 (OSC2). Besides, it is also possible to replace
the existing quartz-crystal with another one. The value of the quartz-crystal depends on
the maximum clock frequency allowed. Microcontrollers being plugged into socket 10F
use their own internal oscillator and are not connected to any of the aforementioned
quartz-crystal sockets.
On-board USB2.0 PIC flash programmer:
The PIC flash programmer is an obligatory tool when working with microcontrollers.
The EasyPIC6 has an on-board PIC flash programmer with mikroICD support which
allows you to establish a connection between the microcontroller and your PC. Use the
PIC FLASHprogrammer to load a hex file into the microcontroller.
There are two ways of programming PIC microcontrollers: Low Voltage and High
Voltage programming modes. The PIC flash programmer uses solely High Voltage
programming mode during its operation. This mode requires voltage higher than the
8/2/2019 colz doc(1)
17/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 17
microcontrollers power supply voltage (the range between 8V to 14V, depending on the
type of the microcontroller in use) to be brought to the MCLR/Vpp pin in order so that
the process of programming/debugging may be performed. The low voltage
programming mode can be enabled/disabled using configuration bits of themicrocontroller. If the low voltage programming mode is enabled, the programming
process is initiated by applying a logic one (1) to the PGM pin. Unlike this mode, the
High Voltage programming mode is always enabled and the programming process starts
by applying a high voltage to the MCLR/Vpp pin.
All PIC microcontrollers have the Low Voltage programming mode enabled by default.
In some rare cases, in order to enable the microcontroller to be programmed in the High
Voltage programming mode, it is necessary to apply a logic zero (0) to the PGM pin,
which prevents the
microcontroller from entering the Low Voltage programming mode. Depending on the
microcontroller in use, it is possible to select one of the following pins RB3, RB4 and
RB5 to be used as the PGM pin.
Fig2.4.1: flash programmer
8/2/2019 colz doc(1)
18/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 18
IN CIRCUIT DEBUGGER:
The mikroICD (In-Circuit Debugger) is an integral part of the on-board
programmer. It is used for the purpose of testing and debugging programs in real time.
The process of testing and debugging is performed by monitoring the state of all registerswithin the microcontroller while operating in real environment. The mikroICD software
is integrated in all compilers designed by mikroElektronika (mikroBASIC,mikroC
andmikroPASCAL). The mikroICD debugger communicates with the PC through the
programming pins which cannot be used as I/O pins while the process of the program
debugging is in progress.
POWER SUPPLY:
The EasyPIC6 development system may use one of two power supply sources:
1. +5V PC power supply through the USB programming cable;
2. External power supply connected to a DC connector provided on the development
board.
The MC34063A voltage regulator is used for enabling external power supply voltage to
be either AC (in the range of 7V to 23V) or DC (in the range of 9V to 32V). Jumper J6 is
used as power supply selector. When using USB power supply, jumper J6 should be
placed in the USB position. When using external power supply, jumper J6 should be
placed in the EXT position. The development system is turned OFF/ON by changing the
setting on the OFF/ON switch respectively.
8/2/2019 colz doc(1)
19/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 19
Fig2.4.2: Power supply
The programmer uses the MOSFET switch for suspending power supply on the
development system during programming. When the process of programming is
complete, the programmer enables the development system to be supplied with power.
RS-232 COMMUNICATION INTERFACE:
RS-232 serial communication is performed through a 9-pin SUB-D connector and
the microcontroller USART module. In order to enable such communication, it is
necessary to establish a connection between RX and TX communication lines
(handshakinglines CTS and RTS are optionally used) and microcontroller pins provided
with USART module using a DIP switch. The microcontroller pins used in such
communication are marked as follows: RX receive data, TX transmit data, CTS
clear to send and RTSrequest to send. Baud rate goes up to 115kbps.
The USART (universal synchronous/asynchronous receiver/transmitter) is one of
the most common ways of exchanging data between the PC and peripheral components.
In order to enable the USART module of the microcontroller to receive input signals with
different voltage levels, it is necessary to provide a voltage level converter such as MAX-
202C.
8/2/2019 colz doc(1)
20/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 20
Fig2.4.3: RS-232C
The function of DIP switches SW7 and SW8 is to determine which of the microcontroller
pins are to be used as RX and TX lines. The microcontroller pinout varies depending on
the type of the microcontroller.
USB Communication:
The USB connector enables PIC microcontrollers with a built-in USB
communication module to be connected to peripheral components. In order to enable
USB communication, it is necessary to change the position of jumpers J12 from left-hand
to right-hand, thus connecting the USB DATA lines (D+ i D-) to RC4 and RC5
microcontroller pins and the RC3/VUSB pin to capacitors C16 and C17. If USB
communication is not used, jumpers J12 should be left in the left-hand position. The
status of USB communication (OFF/ON) is indicated by LED. Figures show schematics
of the most commonly used microcontrollers with integrated USB module.
8/2/2019 colz doc(1)
21/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 21
Fig2.2.4: USB Communication
DS1820 TEMPERATURE SENSOR:
Serial communication enables data to be transferred over one single
communication line while the process itself is under the control of the master
microcontroller. The advantage of such communication is that only one microcontroller
pin is used. All slavedevices have by default a unique ID code, which enables the master
device to easily identify all devices sharing the same interface.
DS1820 is a temperature sensor that uses 1-wire standard for its operation. It is capable of
measuring temperatures within the range of -55 to 125C and provides 0.5C accuracy
for temperatures within the range of -10 to 85C. Power supply voltage of 3V to 5.5V is
required for its operation. It takes maximum 750ms for the DS1820 to calculate
temperature with 9-bit resolution. The EasyPIC6 development system provides a separate
socket for the DS1820. It may use either RA5 or RE2 pin for communication with the
microcontroller. Jumper J11s purpose is selection of the pin to be used for 1 -wire
communication. Figure 10-5 shows 1-wire communication with microcontroller through
the RA5 pin.
8/2/2019 colz doc(1)
22/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 22
Fig2.4.5: Temperature sensor
A/D Converter:
An A/D converter is used for the purpose of converting an analog signal into the
appropriate digital value. A/D converter is linear, which means that the converted number
is linearly dependent on the input voltage value. The A/D converter built into the
microcontroller provided with the EasyPIC6 development system converts an analog
voltage value into a 10-bit number. Voltages varying from 0V to 5V DC may be supplied
through the A/D test inputs. Jumper J15 is used for selecting some of the through the
potentiometer or the microcontroller pin. The value of the input analog voltage can be
changed linearly using potentiometer P1.
LEDs
LED is a highly efficient light source. When connecting LEDs it is necessary to place a
current limiting resistor the value of which is calculated using formula R=U/I where R is
referred to resistance expressed in ohms, U is referred to voltage on the LED and I stands
for LED diode current. A common LED diode voltage is approximately 2.5V, while the
current varies from 1mA to 20mA depending on the type of LED diode. The EasyPIC6
development system uses LEDs with current I=1mA. The EasyPIC6 has 36 LEDs which
visually indicate the logic state of each microcontroller I/O pin. An active LED diode
8/2/2019 colz doc(1)
23/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 23
indicates that a logic one (1) is present on the pin. In order to enable LEDs, it is necessary
to select appropriate port PORTA/E, PORTB, PORTC or PORTD using the DIP switch
SW9.
PUSH BUTTONS
The logic state of all microcontroller digital inputs may be changed using push buttons.
Jumper J17 is used to determine the logic state to be applied to the desired
microcontroller pin by pressing the appropriate push button. The purpose of the
protective resistor is to limit maximum current thus preventing a short circuit from
occurring. Advanced users may, if needed, disable such resistor using jumper J24. Just
next to the push buttons, there is a RESET button which is not connected to the MCLR
pin. The reset signal is generated by the programmer.
Fig2.4.6: PUSH BUTTONS
Input/Output Ports
Along the right side of the development system, there are seven 10-pin connectors whichare connected to the microcontrollers I/O ports. Some of the connectors pins are directly
connected to the microcontroller pins, whereas some of them are connected using
jumpers. DIP switches SW1-SW5 enable each connector pin to be connected to one pull-
8/2/2019 colz doc(1)
24/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 24
up/pull-down resistor. Whether port pins are to be connected to a pull-up or pull-down
resistor depends on the position of jumpers J1-J5.
Fig2.4.7: I/O portsPull-up/pull-down resistors enable voltage signal to be brought to the
microcontroller pins. The logic level at pin idle state depends on the pull-up/pull-down
jumper position. The RB0 pin along with the relevant DIP switch SW2, jumper J2 and
RB2 push button with jumper J17 are used here for the purpose of explaining the
performance of pull-up/pull-down resistors. The principle of their operation is identical
for all the microcontroller pins. In order to enable PORTB pins to be connected to pull-
down resistors, it is necessary to set jumper J2 in the lower position, thus providing8x10K resistor network with a logic zero (0V). To bring a signal to the RB0 pin, it is
necessary to set switch 1 on the DIP switch SW2 to the ON position. This will cause the
microcontroller RB0 pin to be pulled down to the low logic level (0V) in its idle state.
Jumper J17, used to determine the pin logic state provided by pressing push-buttons,
should be set in the opposite position of jumper J2. Accordingly, every time you press the
RB0 push button, a logic one (1) will appear on the RB0 pin.
8/2/2019 colz doc(1)
25/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 25
2.5 UDN2981AMPLIFIER:
Recommended for high-side switching applications that benefit from separate logic and
load grounds, these devices encompass load supply voltages to 50 V and output currents to -500
mA. These 8-channel source drivers are useful for interfacing between low-level logic and high-
current loads. Typical loads include relays, solenoids, lamps, stepper and/or servomotors, print
hammers, and LEDs. All devices may be used with 5 V logic systems TTL, Schottky TTL,
DTL, and 5 V CMOS. The UDN2981A, UDN2982A, and A2982SLW are electrically
interchangeable, will withstand a maximum output off voltage of 50 V, and operate to a
minimum of 5 V. All devices in this series integrate input current limiting resistors and output
transient suppression diodes, and are activated by an active high input. The suffix A (all
devices) indicates an 18-lead plastic dual in-line package with copper lead frame for optimumpower dissipation. Under normal operating conditions, these devices will sustain 120 mA
continuously for each of the eight outputs at an ambient temperature of +50C and a supply of 15
V. The suffix LW (UDN2982LW only) indicates an 18-lead surface mountable
wide-body SOIC package; the A2982SLW is provided in a 20-lead wide-body SOIC package
with improved thermal characteristics. The UDN2982A, UDN2982LW, and A2982SLW drivers
are also available for operation over an extended temperature range to -40C. To order, change
the prefix UDN to UDQ or the suffix SLW to ELW. These packages are available in Pb
(lead) free variants (suffix -T), with 100% matte-tin lead frame plating.
FEATURES
_ TTL, DTL, PMOS, or CMOS Compatible Inputs_ 500 mA Output Source Current Capability_ Transient-Protected Outputs_ Output Breakdown Voltage to 50 V_ DIP or SOIC Packaging
8/2/2019 colz doc(1)
26/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 26
8-CHANNEL SOURCE DRIVERS
2981 CHANNELSOURCE DRIVERS
Fig 2.5:2981 AND 2982 8-CHANNELSOURCE DRIVERS
8/2/2019 colz doc(1)
27/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 27
8/2/2019 colz doc(1)
28/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 28
8-CHANNELSOURCE DRIVERS
Fig2.5.1
8/2/2019 colz doc(1)
29/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 29
2.6 LCD:
LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is very
commonly used in various devices and circuits. These modules are preferred over seven
segments and other multi segment LEDs. The reasons being: LCDs are economical;
easily programmable; have no limitation of displaying special & even custom
characters (unlike in seven segments), animations and so on.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,
namely, Command and Data.The command register stores the command instructions
given to the LCD. A command is an instruction given to LCD to do a predefined task like
initializing it, clearing its screen, setting the cursor position, controlling display etc. The
data register stores the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD.
Pin Diagram of LCD:
http://www.engineersgarage.com/content/seven-segment-displayhttp://www.engineersgarage.com/content/seven-segment-displayhttp://www.engineersgarage.com/content/ledhttp://www.engineersgarage.com/microcontroller/8051projects/create-custom-characters-LCD-AT89C51http://www.engineersgarage.com/microcontroller/8051projects/create-custom-characters-LCD-AT89C51http://www.engineersgarage.com/microcontroller/8051projects/display-custom-animations-LCD-AT89C51http://www.engineersgarage.com/microcontroller/8051projects/display-custom-animations-LCD-AT89C51http://www.engineersgarage.com/microcontroller/8051projects/create-custom-characters-LCD-AT89C51http://www.engineersgarage.com/microcontroller/8051projects/create-custom-characters-LCD-AT89C51http://www.engineersgarage.com/content/ledhttp://www.engineersgarage.com/content/seven-segment-displayhttp://www.engineersgarage.com/content/seven-segment-display8/2/2019 colz doc(1)
30/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 30
Pin Description of LCD:
Pin No Function Name
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
4 Selects command register when low; and data register when high Register Select
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7
8-bit data pins
DB0
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB614 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-
8/2/2019 colz doc(1)
31/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 31
2.7OPERATION OF AIRDRYER:
The operation of the dryer is under the control of a PLC through a pneumatic
micro-solenoid valve set. Instrument pressure gauge indicates condition of each air
operated valve. Air pressure On=valve Open. A mimic board on the control panel
also indicates the state of the valves. With power supplied to the dryer and the isolator
QO1 switched on the supply will illuminate power on lamp H1 and energize power trip
relay. When the compressor run contact across terminals is closed, this brings on dryer
run lamp H6. It also starts the PLC, the hour counter HC, and the alarm delay timer T1.
On compressor or dryer start up, the function of the alarm delay timer is to delay all the
alarm functions until the air system between the compressor and dryer itself pressurizes
and the pressure in each adsorber vessel is correct dependent upon the position of PLC. It
also inhibits the alarm output from the dew-point meter. Thereafter all alarms are
functional until the dryer is switched off.
When the dryer is operating the PLC outputs energize the electro-pneumatic
solenoid control valves SV1-SV6. Solenoid SV1 and SV2 : control the air supply to the
main inlet valves v1 and v2 and instrument gauge pv1 and pv2. Solenoids SV3 and SV4.
Control the air supply to the reactivation purge valves V3 and V4 and instrument pressure
gauges PV3 and PV4. Solenoids SV5 and SV6. Control the air supply to the automatic
drain valves V5 and V6 and instrument pressure gauges PV5 and PV6. Outputs Y6 and
Y7 are used to monitor the pressurization alarms. Delay timers T2 and T3 monitor the de-
pressurization alarms. The pressure in the vessels is monitored by programmable pressure
switches. All lamps apart from the power-on lamp have a lamp test facility. Press lamp
test button S2 to energize lamp test relays LT, LT1 and LT3.
The dryer malfunction warning lamps are intended to indicate failure of dryer
adsorber vessels to depressurize or pressurize during each purge cycle. In the event of
failure each warning lamp is latched on until the reset button is pressed. The pressure
8/2/2019 colz doc(1)
32/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 32
switch contacts are subjected to a timer delay, the relevant contact being selected by the
PLC outputs Y6 or Y7 or timers T2 and T3.
FAIL TO DEPRESSURISE: Pressure switch contacts are set to close on a falling
pressure of 25 bar. If the pressure in the vessel on reactivation doesnt fall below this
pressure within the time set by timers T2 or T3 or pressurize during reactivation, then
warning lamps Failed to depressurize will be illuminated. Alarm lamps H4 and H2
would be latched on and relay contacts will be closed giving no volt contacts across
terminals for remote alarm and compressor shutdown. Relay contacts would be open to
de-energize delay timer T1 and prevent any spurious or further alarms. The alarm lamp
will remain illuminated until the re-set button S1 is pressed or power to panel is switched
off or lost. The alarm relay will remain latched until re-set.
FAIL TO PRESSURIZE: pressure switch contacts are set to close on a raising pressure of
200bar. Should at any time the pressure in the vessel going on stream fail to reach the set
pressure, PLC outputs Y6 or Y7 energize respective relays R4 or R2 and the warning
lamps Fail to pressurize will be illuminated. Alarm lamps H5 or H3 would be latched
on and relay contacts will be closed giving no volt contacts across terminals for remote
alarm and compressor shutdown. Relay contacts would be open to de-energize delay
timer T1 and prevent any spurious or further alarms.
DEW POINT ALARM SOUNDER: If the dryer fails to achieve the required dewpoint,
the dew-point warning lamp on the mimic diagram will illuminate and the sounder will
sound. The sounder can be silenced by pressing the alarm mute button.
ALARM DELAY TIMER T1: timer T1 is set to hold off the alarm circuits for a period of
time to allow circuits on pressurize and depressurize to settle.
POWER TRIP RELAY: Timer PTR holds the alarm circuit off for a set period to allow
delay in operating main control panel dryer failure flag relay. This prevents compressor
lockout and dryer shutdown in the event of minor breaks in control panel supply voltage.
The dryer is designed that upon loss of power, the air solenoid valves de-energize and
8/2/2019 colz doc(1)
33/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 33
shutoff the control air supply to the main inlet, purge and drain valves V1-V6, leaving the
plant in a safe condition.
Main air circuit:
For the purpose of description, assume that the left hand Adsorber AD1 of the drying
plant is on drying duties and the desiccant in the right hand Adsorber AD2 is being
reactivated. The wet compressed air enters through the pre-filter and 3 stage oil
Adsorption filter as mounted on the Dryer plant. The compressed air then passes through
the air operated inlet valve V1 and up through Adsorber AD1 wher water vapour will be
removed and retained in the pores of the desiccant. The dry air will leave the adsorber
through the left hand non-return valve at the top of the plant.a small volume of the drycompressed air leaving Adsorber AD1 passes through the activation flow control orifices.
The dry air passes through the combined filter and orifices which regulates the flow of
Activation air and expand it to Approximately 30 psig. It then passes in to the top saction
of Adsorber AD2.
Adsorber AD1 pressure Gauge PG3 reading high.
Adsorber AD2 pressure Gauge PG4 reading low.
The dry expanded air entering the top part of Adsorber AD2 will pass down through the
desiccant and pick up the water vapour adsorbed during the previous drying cycle. The
moisture laden air leaves the adsorber through the bottom connection and passes through
activation purge Valve V4 and out of the plant via the activation air silencer S1. Adsorber
AD2 pressure Gauge PG4 reading low.the reactivation air passes down through Adsorber
AD2 for 4 minutes 20 seconds of the period. The activation purge Valve V4 the closes
and the reactivation air continues to flow and increase the pressure in Adsorber AD2.
During the reaming 7 minutes the pressure increase until both Adsorber Vessels are at
line pressure.
8/2/2019 colz doc(1)
34/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 34
Adsorber AD2 pressure Gauge PG4 rising to full pressure. At the end of the cycle, inlet
valve V2 will open and V1 will close 20 seconds later and the changeover of the air flow
will be completed. Adsorber pressure Gauge PG3 and PG4 both reading high. Activation
purge valve V3 now opens and the pressure in adsorber AD1 will reduce and activation
of the desiccant will proceed.
Adsorber AD1 pressure guage PG3 reading low. Adsorber AD2 pressure guage PG4
reading high. The activation air flow is maintained by the fixed flow restrictor orifice and
the pressure at which activation takes place is controlled by the purge orifice in the outlet
pipework coupling of the activation purge valve. Air then leaves the drying plant through
the after filter and back pressure maintain valve.
8/2/2019 colz doc(1)
35/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 35
DRYER TIMING CHART:
8/2/2019 colz doc(1)
36/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 36
3.SOFTWARE:
The software that runs in the programmable controller has been developed in
Mikro C . The program is implemented using the Mikro C PRO PIC v.4.600 which
provides the libraries that can be used to develop real time applications. The real time
task named as Main Task executes the application code in cyclic manner. This Main Task
has to be initialized using the INIT task. In each cycle of this cyclic task the value for the
hardware watch-dog timer is set. If the execution time for the current cycle exceeds the
watch-dog timer value, then the microcontroller is interrupted and the interrupt service
routine brings the system to a predefined safe state.
The software that runs in the programmable controller has been developed inMikro C. The program is implemented using the Mikro C PRO IDE, These libraries can
be used to develop real time applications. OSA is a cooperative multitasking real-time
operating system (RTOS) for Microchip PIC-controllers PIC16, for Atmel AVR 8-bit
controllers, and for STMicroelectronics STM8. RTOS allows the programmer to focus
on problem-oriented tasks (algorithmic, mathematical etc.) and not have to worry about
secondary tasks. All secondary tasks are performed by OSA's kernel:
switching between parallel processes (e.g. keyboard scanning, output data
to LCD, switching relays);
checking timeouts, counting delays;
finding the ready task with the highest priority and executing it;
data exchange between different tasks using semaphores, messages, queues
etc.
8/2/2019 colz doc(1)
37/61
8/2/2019 colz doc(1)
38/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 38
3.2 INTRODUCTION TO MIKROC PRO FOR PIC
The mikroC PRO for PIC is a powerful, feature-rich development tool for PIC
microcontrollers. It is designed to provide the programmer with the easiest possible
solution to developing applications for embedded systems, without compromising
performance or control. PIC and C fit together well: PIC is the most popular 8-bit chip in
the world, used in a wide variety of applications, and C, prized for its efficiency, is the
natural choice for developing embedded systems. mikroC PRO for PIC provides a
successful match featuring highly advanced IDE, ANSI compliant compiler, broad set of
hardware libraries, comprehensive documentation, and plenty of ready-to-run examples.
Features
mikroC PRO for PIC allows you to quickly develop and deploy complex applications:
Write your C source code using the built-in Code Editor (Code and Parameter
Assistants, Code Folding, Syntax Highlighting, Auto Correct, Code Templates,
and more.)
Use included mikroC PRO for PIC libraries to dramatically speed up the
development: data acquisition, memory, displays, conversions, communicationetc.
Monitor your program structure, variables, and functions in the Code Explorer.
Generate commented, human-readable assembly, and standard HEX compatible
with all programmers.
Use the integrated mikroICD (In-Circuit Debugger) Real-Time debugging tool to
monitor program execution on the hardware level.
Inspect program flow and debug executable logic with the integrated Software
Simulator.
Generate COFF(Common Object File Format) file for software and hardware
debugging under Microchip's MPLAB software.
Active Comments enable you to make your comments alive and interactive.
8/2/2019 colz doc(1)
39/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 39
Get detailed reports and graphs: RAM and ROM map, code statistics, assembly
listing, calling tree, and more.
mikroC PRO for PIC provides plenty of examples to expand, develop, and use as
building bricks in your projects. Copy them entirely if you deem fit thats whywe included them with the compiler.
3.2.1 RTOS:
There are several commercially available, shareware and open-source RTOS systems for
the PIC microcontroller family. Brief details of some popular RTOS systems are given in
this section. Salvo is a low-cost, event-driven, priority-based, multitasking RTOS
designed for microcontrollers with limited program and data memories. It can be used for
many microcontrollers, including the 8051 family, ARM, Atmel AVR, M68HC11,
MS430, PIC microcontroller family and others. Salvo is written in ANSI C and supports
a large number of compilers, including Keil C51, Hi-Tech 8051, Hi-Tech PIC C-18,
Microchip MPLAB C18 and many others. A demo version (Salvo Lite) is available for
evaluation purposes. The SE and LE versions are for systems requiring smaller number of
tasks with less features, while the Pro version is the top model aimed for professional
applications. The Pro version supports unlimited number of tasks with priorities, event
flags, semaphores, binary semaphores, message queues and many more features.
Real-time operating systems are built around a multi-tasking kernel which controls the
allocation of time slices to task. A time slice is the period of time a given task has for
execution before it is stopped and replaced by another task. This process, also known as
context switching, repeats continuously. When context switching occurs, the executing
task is stopped, the processor register are saved in memory, the processor register of the
next available task are loaded in the CPU, and the new task begins execution. An RTOS
also provides task-to-task message passing, synchronization of task, and allocation of
shared resources to tasks.
8/2/2019 colz doc(1)
40/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 40
The basic parts of an RTOS are:
Scheduler
RTOS services
Synchronization and
The scheduler:
A scheduler is at the heart of every RTOS, as it provides the algorithms to select the tasks
for execution. Three of the more common scheduling algorithm are:
Cooperative scheduling
Round-robin scheduling
Preemptive scheduling
CO-OPERATIVE SCHEDULING:
Co-operative scheduling cannot satisfy real-time system needs, since it cannot support the
prioritization of tasks according to importance. State machine construct is a simple form
of a co-operative scheduling technique.
ROUND-ROBIN SCHEDULING:
In this one it assigned an equal share of CPU time. A counter tracks the time slice
for each task. When one tasks time slice completes, the counter is cleared and the task is
placed at the end of the cycle. Newly added tasks are placed at the end of the cycles with
there counters cleared to zero.
TASK 1 TASK 2 TASK 3 TASK 1 TASK 2
Fig 3.2.1(a)
8/2/2019 colz doc(1)
41/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 41
PREEMPTIVE SCHEDULING:
It is a real-time scheduling algorithm it is priority based, and each task is given a priority.
The task with highest priority gets the CPU time. Real-time systems generally support
priority levels ranging from 0 to 255, where 0 is highest priority and 225 is the lowest.
priority
Time
Fig3.2.1(b): Preemptive scheduling
In a real-time system a task can be in any one of the following states
Ready to run
Running
Blocked
When a task is first created, it is usually ready to turn and is entered in the task list. From
this state, subject to the scheduling algorithm, the task can become a running task. The
task will run if it is the highest priority task in the system and is not waiting for resource.
The kernel usually provides an interface to manipulate task operations. Typical task
operations are:
Creating a task
Deleting a task
Changing the priority of a class
TASK 1
TASK 2 TASK 2
TASK 3
TASK 1
8/2/2019 colz doc(1)
42/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 42
Changing the state of a task
TASK STATES
RTOS MANAGEMENT OF TASKS:
8/2/2019 colz doc(1)
43/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 43
3.2.2 OSA:
OSA is a cooperative multitasking real-time operating system (RTOS) for
Microchip PIC-controllers PIC16, PIC18, PIC24, dsPIC, for Atmel AVR 8-bit
controllers, and for STMicroelectronics STM8. RTOS allows the programmer to focus
on problem-oriented tasks (algorithmic, mathematical etc.) and not have to worry about
secondary tasks. All secondary tasks are performed by OSA's kernel
switching between parallel processes (e.g. keyboard scanning, output data
to LCD, switching relays);
checking timeouts, counting delays;
finding the ready task with the highest priority and executing it;
Data exchange between different tasks using semaphores, messages, queues
etc.
A task in OSA is a C-function. This function must contain an infinite loop which has
inside it at least one service that switches task context. A simple task can look like this:
void SimpleTask (void)
{for (;;) // Infinite loop
{OS_Yield(); // Unconditional context switching
}}
Scheduler
The serviceOS_Run() is a macro that contains an infinite loop calling the scheduler.
This service should be called at the end of function main (). It gives full control to the
OSA kernel. The scheduler examines all active tasks and looks for the ready task with
highest priority. When the task is found, the scheduler executes it.OS_Run() is a macro.
This macro contains global labels; thus this service can be used only once in the program.
8/2/2019 colz doc(1)
44/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 44
So program can look like this:
void main (void)
{
OS_Init();
OS_Task_Create(...);
OS_Task_Create(...);
// Create all the tasks you need
// ...
OS_Run();
}
The scheduler scans all active tasks (i.e. those created by serviceOS_Task_Create
and finds all those ready to execute. Then the scheduler compares the priorities of all
ready tasks and gives control to the highest priority one of them. There is one exception:
when one of the tasks is in a critical section, only this task can get control; other tasks are
skipped by the scheduler in this case.
If, while scanning all tasks, the scheduler finds a ready task with priority = 0 (highest)
then the scheduler stops the search and gives control to this task. This increases the
scheduler's speed.
Events and priority
Task states
To synchronize tasks, the system uses events. For example, we have two active tasks
(created by service OS_Task_Create): one of them measures temperature, and the other
8/2/2019 colz doc(1)
45/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 45
displays the measured value on a screen. The second task cannot display data if there is
no measured value. While the first task makes measurements, the second task waits. After
the temperature is measured (in other words, the event has taken place), the second task
becomes ready to run. And then the second task can be executed.
Thus all tasks can have one of five states:
not active task was not created or was deleted
Waiting task is waiting for some event
Ready the expected event occurred but the task did not get control yet
Running task is executing
Paused task is paused. It is still active but can't get control.
In order for a task to get control, two conditions must be met:
1. The event expected by the task occurs (task becomes ready)
2. The task's priority must be higher than the priorities of other ready tasks.
Priority:
All tasks have a priority from 0 (highest) to 7 (lowest). There are three priority
modes (levels): disabled priorities - all assigned priorities are ignored. This is the fastest
and compact mode. But it does not allow assigning higher priority for more important
tasks.
Normal priorities - each task have it's own priority. If there are several ready tasks, then
the task with the highest priority will get control. If several ready tasks have the same
priority, then they will be run in round-robin mode. This mode has two disadvantages:
8/2/2019 colz doc(1)
46/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 46
when there is an always ready task with high priority, no low priority tasks will get
control; when two or more tasks have the same priority and they wait for the same event,
only one of them always will get the control
Extended priorities- all tasks get control according to their priority. For example, if
there are two always ready tasks with priorities 3 and 4, then one of them will get 55-60%
of control (with priority 4) and other - 40-45%. The advantage of this mode is that all
tasks guaranty will get the control. But in this mode system requires 2 addition bytes of
RAM per each task. Read Speed characteristics to learn more about speed of scheduler in
different modes. The priority mode is defined once on the compilation stage by setting
constant
OS_PRIORITY_LEVEL in osacfg.h.
#define OS_PRIORITY_LEVEL OS_PRIORITY_DISABLE // For disable
priorities
#define OS_PRIORITY_LEVEL OS_PRIORITY_NORMAL // For normalpriorities
#define OS_PRIORITY_LEVEL OS_PRIORITY_EXTENDED // For extended
priorities
8/2/2019 colz doc(1)
47/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 47
3.2.3PROGRAM CODE//******************************************************************************
//Title : Micro Controller Based Air Drier System
//Purpose: Demonstration of Air Drier Project with OSA RTOS features
//Authors: Students
//Date of Creation:
//Date of Last Modification:
//
// PIC16F887 EasyPIC6 OSA RTOS
//
//******************************************************************************
#include
#include //------------------------------------------------------------------------------// Configuration bits:
// - internal RC-oscilator
// - WDT OFF// - low-voltage programming OFF
// - debugging OFF
//------------------------------------------------------------------------------//------------------------------------------------------------------------------
// Define outputs where leds are connected
//------------------------------------------------------------------------------#define LOW_PRESSURE_ALARM RD6_bit
#define HIGH_PRESSURE_ALARM RD7_bit
//------------------------------------------------------------------------------// Timer's parameters:
// - prescaler = 4,
// - postscaler = 1,
// - count limit = 250
//
// Fosc = 8 MHz.//
// TMR2 interrupt period = 4 * 1 * 250 * Tcyc = 1 ms
//
//------------------------------------------------------------------------------
#define PR2_CONST 250-1
#define TMR2_PRS 1 // prs = 4
#define TMR2_POST 0 // post = 1
#define T2CON_CONST (TMR2_POST
8/2/2019 colz doc(1)
48/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 48
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
//------------------------------------------------------------------------------// Declaration of all Variables
// --------------------------------------------------------------------
unsigned long int temp_res,temp, secs,cnt,x;
float engcur;
unsigned long int msec,count;
bit START,bAnalog,bAlarm,STOP;
int i,k,te;
float engval;
char txt[10];
//******************************************************************************
// Interrupt service routine. (Interrupt occures every 1 ms)//******************************************************************************
void interrupt (void)
{if (PIR1.TMR2IF == 1)
{
OS_Timer();
msec++;
if (msec%1000 ==0)
{
secs++; // 1 sec generation
bAnalog=1;}
if(secs>1350)
{
cnt=0;
secs=0;
}
PIR1.TMR2IF = 0;
if (STOP==1)
{
PORTB=0;
}
}
}
void Tone1() {
Sound_Play(659, 250); // Frequency = 659Hz, duration = 250ms
}
void Tone2() {
Sound_Play(800, 250); // Frequency = 698Hz, duration = 250ms
}
8/2/2019 colz doc(1)
49/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 49
//******************************************************************************
// Tasks
//******************************************************************************
//------------------------------------------------------------------------------
void Task_T1 (void)
{
for (;;){
if (START==1)
{
/************VP1 *******/
if(secs>=0 && secs =675 && secs
8/2/2019 colz doc(1)
50/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 50
{
//DO NOTHING ;
}
else
{
STOP=1;
}}
else
{
PORTA.B3=0;
}
/************VP4 *******/
if(secs>=27 && secs =810 && secs =135 && secs
8/2/2019 colz doc(1)
51/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 51
{
PORTA.B6=1;
if(PORTD.B5 ==1)
{
//DO NOTHING ;
}
else{
STOP=1;
}
}
else
{
PORTA.B6=0;
}
}
}}
//--------------------------------------------------------------------------------------------------
void Task_T2 (void)
{for (;;)
{
OS_Cond_Wait(bAnalog);
bAnalog=0;
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
te=temp_res;
k=1;for(i=0; i
8/2/2019 colz doc(1)
52/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 52
for (;;)
{
OS_Cond_Wait(bAlarm);
bAlarm=0;
if (engcur > 55.0) // Checking for High Pressure Dew Limit
{
HIGH_PRESSURE_ALARM =1;Tone1();
}
else if (engcur < -55.0) // Checking for Low Pressure Dew Limit
{
LOW_PRESSURE_ALARM =1;
Tone2();
}
}
}//******************************************************************************
// Perifery init
//******************************************************************************
void init (void)
{
//------------------------------------------------------------------------------
// I/O ports setup
//------------------------------------------------------------------------------
ANSEL = 0x04; // AN2 is configured as Analog InputANSELH = 0x00;
PORTB = 0;
PORTC = 0;
PORTD = 0;
TRISA = 0X04;
TRISB = 0;
TRISC = 0;
TRISD = 0x3F;
UART1_init(9600);
START =1;
//------------------------------------------------------------------------------
// Timer setup
//------------------------------------------------------------------------------
PR2 = PR2_CONST;
T2CON = T2CON_CONST | 0x04;
8/2/2019 colz doc(1)
53/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 53
//------------------------------------------------------------------------------
// Interrupts setup
//------------------------------------------------------------------------------
PIR1 = 0;
PIR2 = 0;
INTCON = 0;
PIE1.TMR2IE = 1; // Enable TMR2 interrupt
INTCON.PEIE = 1; // Enable periphery interrupts
// Global interrupts will be enabled
// in main just before running scheduler
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,txt); // Write text in first row
Lcd_Out(1, 1, " Dew Point: ");
// Print degree character, 'C' for Centigrades
Lcd_Chr(2,13,223); // Different LCD displays have different char code for degree
// If you see greek alpha letter try typing 178 instead of 223
Lcd_Chr(2,14,'M');
/*-----------------------------------------------------------------------------*/
// Initilisation of Sounds
/*-----------------------------------------------------------------------------*/
Sound_Init(&PORTC, 3);
}
//******************************************************************************
// MAIN
//******************************************************************************
#pragma funcall main Task_T1
#pragma funcall main Task_T2
#pragma funcall main Task_T3
void main (void)
{init(); // Init perifery
OS_Init(); // System init
// Creating Tasks
OS_Task_Create(1, Task_T1); //
OS_Task_Create(2, Task_T2);
OS_Task_Create(3, Task_T3);
8/2/2019 colz doc(1)
54/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 54
OS_EI(); // Enable interrupts
OS_Run(); // Run scheduler
}
//******************************************************************************// END
//******************************************************************************
8/2/2019 colz doc(1)
55/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 55
4. Verification and Validation:
Verification is intended to check that a product, service, or system (or portion
thereof, or set thereof) meets a set of initial design requirements, specifications, and
regulations. In the development phase, verification procedures involve performing special
tests to model or simulate a portion, or the entirety, of a product, service or system, then
performing a review or analysis of the modeling results. In the post-development phase,
verification procedures involve regularly repeating tests devised specifically to ensure
that the product, service, or system continues to meet the initial design requirements,
specifications, and regulations as time progresses.[citation needed] It is a process that is
used to evaluate whether a product, service, or system complies with
regulations, specifications, or conditions imposed at the start of a development phase.
Verification can be in development, scale-up, or production. This is often an internal
process.
Validation is intended to check that development and verification procedures for a
product, service, or system (or portion thereof, or set thereof) result in a product, service,
or system (or portion thereof, or set thereof) that meets initial requirements,
specifications, and regulations. For a new development flow or verification flow,
validation procedures may involve modeling either flow and using simulations to predict
faults or gaps that might lead to invalid or incomplete verification or development of a
product, service, or system (or portion thereof, or set thereof). A set of validation
requirements, specifications, and regulations may then be used as a basis for qualifying a
development flow or verification flow for a product, service, or system (or portion
thereof, or set thereof). Additional validation procedures also include those that are
designed specifically to ensure that modifications made to an existing qualified
development flow or verification flow will have the effect of producing a product,
service, or system (or portion thereof, or set thereof) that meets the initial design
requirements, specifications, and regulations; these validations help to keep the flow
qualified.[citation needed] It is a process of establishing evidence that provides a high
http://en.wikipedia.org/wiki/Wikipedia:Citation_neededhttp://en.wikipedia.org/wiki/Specificationhttp://en.wikipedia.org/wiki/Wikipedia:Citation_neededhttp://en.wikipedia.org/wiki/Wikipedia:Citation_neededhttp://en.wikipedia.org/wiki/Specificationhttp://en.wikipedia.org/wiki/Wikipedia:Citation_needed8/2/2019 colz doc(1)
56/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 56
degree of assurance that a product, service, or system accomplishes its intended
requirements. This often involves acceptance of fitness for purpose with end users and
other product stakeholders. This is often an external process.
It is sometimes said that validation can be expressed by the query "Are you building the
right thing?" and verification by "Are you building it right?" "Building the right thing"
refers back to the user's needs, while "building it right" checks that the specifications are
correctly implemented by the system. In some contexts, it is required to have written
requirements for both as well as formal procedures or protocols for determining
compliance.
Test cases for all the failure and success cases
Test case1:
The control logic is initially tested in the Lab setup as the below procedure.
1.Valves commanding ON /OFF checked on the LEDs
2.Analog Data current loop simulated from CA11 and Pressure value is logged at PC
every one sec and display on LCD
3. Alarm is generated and tested for the frequency.
8/2/2019 colz doc(1)
57/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 57
S.No Test Case Expected
Output
Observed
Output
Action
1 Case 1-valves
are commanded
but sts not
availabe
Reset all the
valves-stop the
program
Same as
expected
Reset all
variables
2 Case 2-checked
for the alarm1-
dewpoint
8/2/2019 colz doc(1)
58/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 58
Test Setup:-
1.For Valves Control and Valve Micro Switch status is available or not
8/2/2019 colz doc(1)
59/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 59
USART Terminal picture for logging of data:
8/2/2019 colz doc(1)
60/61
Electronics and Instrumentation Engineering
Dept Of EIE Page 60
CONCLUSION:
The logic for reading the valve status and logging the pressure and to glow the
LED according to the setpoint was successfully ported onto the PIC16F887 MCU and
was tested in simulation mode for all possible conditions and the results are found to be
satisfactory. The system was designed to be as a general purpose real time embedded
system where all ports are configurable as per the requirements and any specific or
general purpose application can be easily ported into the system. The system developed
was interface to a general purpose personal computer for displaying all process values
and recording all the values for offline analysis.
Scope of the Project in the near Future:
Instead of logging the data at PC, the data can be stored in EEPROM card and can be
interfaced to the PC for offline analysis.
8/2/2019 colz doc(1)
61/61
Electronics and Instrumentation Engineering
BIBLIOGRAPHY:
Books Referred:
1. PIC microcontrollers by
-Douglas Ibrahim
Websites:
1. http://www.mikroe.com/eng/products/view/297/easypic6-development-system/
2. http://ww1.microchip.com/downloads/en/DeviceDoc/41291D.pdf
3. http://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS
_Processors/
4. http://www.pic24.ru/doku.php/en/osa/ref/introduction/intro
http://www.mikroe.com/eng/products/view/297/easypic6-development-system/http://www.mikroe.com/eng/products/view/297/easypic6-development-system/http://ww1.microchip.com/downloads/en/DeviceDoc/41291D.pdfhttp://ww1.microchip.com/downloads/en/DeviceDoc/41291D.pdfhttp://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://www.pic24.ru/doku.php/en/osa/ref/introduction/introhttp://www.pic24.ru/doku.php/en/osa/ref/introduction/introhttp://www.pic24.ru/doku.php/en/osa/ref/introduction/introhttp://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://rtos.com/news/detail/New_Textbook_Explains_RealTime_Programming_of_MIPS_Processors/http://ww1.microchip.com/downloads/en/DeviceDoc/41291D.pdfhttp://www.mikroe.com/eng/products/view/297/easypic6-development-system/Top Related