You are on page 1of 21

A Project Report

On

INTERFACE DAC AND SERIAL COMMUNICATION AND


GENERATE WAVEFORM WITH REQUIRED FREQUENCY
BEING RECEIVED FROM REMOTE PC

Submitted to partial fulfilment of requirement for the award

OF

MASTER OF ENGINEERING DEGREE

IN

AUTOMATIC CONTROL & ROBOTICS

Submitted to

Faculty of Technology & Engineering (3386)

THE MAHARAJA SAYAJIRAO UNIVERSITY OF BARODA, VADODRA


Affiliated

Submitted by:
Name Roll no PRN no
Amitkumar Hasmukhbhai Patel 259 2019033800134933
Supriya Kumari 260 2019033800133454
THE MAHARAJA SAYAJIRAO UNIVERSITY OF BARODA, VADODRA
Affiliated

FACULTY OF TECHNOLOGY & ENGINEERING

ELECTRICAL ENGINEERING DEPARTMENT

2020

CERTIFICATE

This is to certify that a project report, submitted along with the Domain entitled
“INTERFACE DAC AND SERIAL COMMUNICATION AND GENERATE WAVEFORM WITH
REQUIRED FREQUENCY BEING RECEIVED FROM REMOTE PC “has been carried out by
following students under my guidance in partial fulfilment for the degree of Master in
Engineering in AUTOMATIC CONTROL & ROBOTICS, Electrical Department of The
Maharaja Sayajirao University of Baroda during the academic year 2019-20.

Submitted by:

Name Roll no PRN no


AMITKUMAR HASMUKHBHAI PATEL 259 2019033800134933
SUPRIYA KUMARI 260 2019033800133454
ACKNOWLEDGEMENT

We would like to express our sincere gratitude to our supervisors Mr. Hiren Sir and Farah
Ma’am for providing their invaluable guidance, comments, suggestions and constant
support throughout this project.
We also thank our HOD for his permission and the golden opportunity to do this wonderful
project on the topic “Interface DAC and serial communication and generate waveform with
required frequency being received from remote PC”, which also helped us in doing a lot of
research and we came to know about so many new things.
Secondly we would also like to thank our friends and eneryone who helped us a lot in
completing this project within the limited time frame.
ABSTRACT

Function generator that generates certain shapes of waveforms at a wide range of


frequency is frequently needed for different processes and purpose in the field of
engineering testing & research. There are many ways in which waves are generated.
Aim of this project is to interface DAC and serial communication and generate waveform
with required frequency being received from remote PC using microcontroller..
Thus in this project interfacing of DAC0808 and serial communication with AT89C51
microcontroller is done in which 8-bit digital data is converted into analog signals then
current converted into voltage using 5k resistor before amplifying using LF351 operational
amplifier.
As RS232 is not compatible with microcontroller therefore MAX-232 IC is used to exchange
the TTL/CMOS logic to RS232 logic levels through the serial communication of
Microcontroller with the personal computer.
Different required delays is calculated and given to provide a range of variable waveforms
like sine wave etc.
CONTENT

Sr. no Title
1 Introduction
2 Hardware Units Requirement
2.1 AT89C51 Microcontroller(8051 family)
2.2 DAC0808
2.3 MAX232 IC
2.4 LF351 OPAMP
2.5 Resistors
2.6 Capacitors
2.7 Crystal Oscillator
2.8 DB9 connector
2.9 Transformer
2.10 5v Power Supply Circuit
2.11 Personal Computer
3 Software tools requirement
3.1 Keil μvision
3.2 Proteus Design Suite
4 Circuit connection diagram
5 Design & connections details
6 Waveform generation using DAC and 8051 microcontroller
7 Simulation program
8 Results
9 Conclusion
10 References
1. INTRODUCTION

In this demanding and exponentially growing industries where technological advancement


& automation need is at peak, Microcontrollers are wise choice. Microcontrollers are used
in automatically controlled products and devices, such as automobile engine control
systems, implantable medical devices, remote controls, office machines, appliances, power
tools and other embedded systems. Mixed signal microcontrollers are common, integrating
analog components needed to control non-digital electronic systems. In the context of the
internet of things, microcontrollers are an economical and popular means of data
collection, sensing and actuating the physical world as edge devices. Due to higher
automation control demand function generators requirement is also increasing because
Educational institutions and colleges as well as test engineers need a function generator
that generates certain shapes of waveforms at a wide range of frequency. The performance
of most electronic systems under test and in operation using the waveform generator are
basically to extract vital information based on the generated signals displayed on a scope,
and in some other case be used to initiate control for systems as per the need of user.
Various techniques have been adopted in the past, but with the use of microcontroller, it is
possible to design user friendly, compact, flexible, reliable and accurate system. The pattern
for the generation of waveform is find out and generated digital signal as per the required
waveform.
2. HARDWARE UNITS REQUIREMENT

2.1 AT89C51 Microcontroller(8051 family)


The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes
of Flash programmable and erasable read only memory (PEROM). The device is
manufactured using Atmel’s high-density nonvolatile memory technology and is compatible
with the industry-standard MCS-51 instruction set and pinout. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional nonvolatile memory
programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel
AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective
solution to many embedded control applications.
Important features:
• 4K bytes of Flash • a five vector two-level interrupt
• 128 bytes of RAM architecture,
• 32 I/O lines • a full duplex serial port
• two 16-bit timer/counters • on-chip oscillator and clock circuitry.
• static logic for operation down to zero frequency and supports two software selectable
power saving modes.
• The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and
interrupt system to continue functioning
• The Power-down Mode saves the RAM contents but freezes the oscillator disabling all
other chip functions until the next hardware reset.
Internal Architecture
2.2 DAC0808
The DAC0808 is an 8-bit monolithic digital-to-analog converter (DAC) featuring a full scale
output current settling time of 150 ns while dissipating only 33 mW with ±5V supplies.
Features and Electrical characteristics of DAC0808
• 8 bit parallel digital data input
• Fast settling time (typical value): 150 ns
• Relative accuracy at ±0.19% maximum error
• Full scale current match: ±1 LSB
• Non-inverting digital inputs are TTL and CMOS compatible
• High speed multiplying input slew rate: 8 mA/μs
• Power supply voltage range: ±4.5V to ±18V
• Low power consumption: 33 mW@ ±5V
• Maximum Power dissipation: 1000 mW
• Operating temperature range: 0ºC to +75ºC
2.3 MAX232
The MAX232 is an integrated circuit first created in 1987 by Maxim Integrated Products that
converts signals from a TIA-232 (RS-232) serial port to signals suitable for use in TTL-
compatible digital logic circuits. The MAX232 is a dual transmitter / dual receiver that
typically is used to convert the RX, TX, CTS, RTS signals
Features of Max232 IC
• Input supply voltage of 5V.
• Input voltage levels compatible with the TTL standard.
• Output voltage levels compatible with RS 232 standard.
• The low input current of 0.1microAmpere and output current of 24mA.
• It operates in a temperature range of -40 degree Celsius to +85 degree Celsius

2.4 LF351 OPAMP


LF351 is a high speed JFET input operational amplifier.
Features:-
• Internally trimmed offset voltage 10 mV
• Low input bias current 50 pA
• Low input noise voltage 25 nV/0Hz
• Low input noise current 0.01 pA/0Hz
• Low power consumption
• Output short-circuit protection
• High slew rate 16 V/us
• Low input-bias and offset current
• Latch up free operation
• Internal Frequency compensation

2.5 Resistors
A resistor is a passive two-terminal electrical component that implements electrical
resistance as a circuit element. In electronic circuits, resistors are used to reduce current
flow, adjust signal levels, to divide voltages, bias active elements, and terminate
transmission lines, among other uses.

2.6 Capacitors
A capacitor is a two terminal passive device which behaves as a charge storage device in
electric circuit. The most basic construction of a capacitor consists of two parallel
conductors (usually metallic plates) separated by a dielectric material. When we connect a
voltage source across the capacitor, the conductor (capacitor plate) attached to the positive
terminal of the source becomes positively charged, and the conductor (capacitor plate)
connected to the negative terminal of the source becomes negatively charged. Because of
the presence of dielectric in between the conductors, ideally, no charge can migrate from
one plate to other.
2.7 Crystal Oscillator
A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a
vibrating crystal of piezoelectric material to create an electrical signal with a precise
frequency

2.8 DB9 connector


DB9 is a commonly known connector used in Serial Asynchronous Data Transmission that
are are designed to work with the EIA/TIA 232 serial interface standard. RS-232 is the
standard for establishing serial data transfer between DTE(Data Terminal Equipment) and
DCE(Data Circuit-terminating Equipment). The letter A to E denotes the shell size, followed
by the number of pins. Male(M) or Female(F) denotes the gender of the part.

2.9 Transformer
• The centre-tapped transformer also known as two phase three wire transformer is
normally used for rectifier circuits.
• When a digital project has to work with AC mains a Transformer is used to step-down
the voltage and then convert it to DC by using a rectifier circuit.
• In a center-tapped transformer the peak inverse voltage is twice as in bridge rectifier
hence this transformer is commonly used in full wave rectifier circuits.
Features:

• Step-down Centre tapped Transformer


• Input Voltage: 220V AC at 50Hz
• Output Voltage: 24V, 12V or 0V
• Output Current: 1A
• Vertical mount type
• Low cost and small package

2.10 5v power supply circuit

2.11 Personal Computer


Personal computers are intended to be operated directly by an end user, rather than by a
computer expert or technician
3. SOFTWARE TOOLS REQUIREMENTS

3.1 Keil μvision


The software design adopts Keil μvision language. Keil μvision is used to develop program in
Embedded C.The Keil μvision Software development programs are used to assemble C
source files, link and locate object modules and libraries, create HEX files, and debug target
program.For saw-tooth and triangular waveforms, assume that one cycle involves 256
(maximum) increments, 256(maximum) decrements and 512 comparisons. The rate of
decrement of the counter for sawtooth and triangular waveforms is determined by its clock.

3.2 Proteus Design Suite


The Proteus Design Suite is wholly unique in offering the ability to co-simulate both high and
low-level microcontroller code in the context of a mixed mode SPICEb circuit simulation.
With this Virtual System Modelling facility, we can transform product design cycle and lower
costs of development. Proteus VSM improves efficiency, quality and flexibility throughout
the design process. Proteus Virtual System Modelling (VSM) combines mixed mode SPICE
circuit simulation, animated components and microprocessor models to facilitate co-
simulation of complete microcontroller based designs. It is possible to develop and test such
designs before a physical prototype is constructed.Proteus VSM also provides extensive
debugging facilities including breakpoints, single stepping and variable
display for both assembly code and high level language source.
4. CIRCUIT CONNECTION DIAGRAM
5. DESIGN & CONNECTIONS DETAILS

• AT89C51 microcontroller has 4 ports P0, P1, P2, P3. Each port has 8 pins (0-7).
• Port 2 is connected to DAC0808. DAC0808 is 16 pin IC where both sides lower 4 -4pins
are used for 8 bit data input, where pin 5 holds MSB of the digital data input and pin 12
holds LSB of the digital data input.
• Vref(+) at pin 14 is connected to 5V through 5K resistor. Vee(-) at pin 3 is connected to -
12V.
• In DAC0808 chip the digital inputs are converted to current. The output current is
known as Iout
• The total current provided by the Iout pin is basically a function of the binary numbers
at the input pins D0 - D7 (D0 is the LSB and D7 is the MSB) of DAC0808 and the
reference current Iref. The following formula is showing the function of Iout

• The Iref is the input current, must be provided into the pin 14. 2.0mA is used as Iref
• The output is taken from pin 4, which gives output in form of current. But the
requirement is of voltage, which is obtained by connecting a 5K resistor with it.
• We connect the Iout pin to the resistor to convert the current to voltage. But in real life
it may cause inaccuracy since the input resistance of the load will also affect the output
voltage. So practically Iref current input is isolated by connecting it to an Op-Amp with
Rf = 5KΩ as feedback resistor. The feedback resistor value can be changed as per
requirement. But the voltage obtained is of very low level, so as to amplify that IC LF351
is used.
• Port 3 is connected to MAX232 through pin P3.0 (RXD) and P3.1 (TXD) and DB9
connector is connected to it.
• As RS232 is not compatible with the microcontroller, a line driver is needed to convert
RS232’s signals to TTL voltage levels that is acceptable to 8051’s pins, so one of the
such converter is MAX232 is used. MAX 232 converts from RS232 voltage levels to TTL
voltage levels and vice versa.

6. WAVEFORM GENERATION USING DAC AND 8051 MICROCONTROLLER

The generation of a waveform using an 89C51 microcontroller utilizes an algorithm that


consists of many subroutines to produce the required waveform. Therefore,each
subroutine takes execution time which is different from that of another wave generation
and depending on the instructions used in the subroutine time duration is different for each
waveform.
6.1 Sine wave generation
For generating sine wave, at first we need a look-up table to represent the magnitude of
the sine value of angles between 0° to 360°. The sine function varies from -1 to +1. In the
table only integer values are applicable for DAC input. In this example we will consider 30°
increments and calculate the values from degree to DAC input. We are assuming full-scale
voltage of 10V for DAC output. We can follow this formula to get the voltage ranges.

6.2 Other waveforms generation


The creation of a square wave used the approach of setting the output port for half duration
and resetting for another half duration (i.e. 50% duty cycle).
The triangular wave can be generated using a software up/down counter, the rate at which
this counter is incremented (or decremented) determines the frequency and
accuracy of the generation process. It also can be achieved based upon either resetting the
up/down counter at the start of each cycle.The saw-tooth wave algorithm is achieved by
using software based on up/down counter that is incremented with a suitable STEP value
upto maximum value 255 and then reset to the value 0. The same thing is repeated forever.
7. SIMULATION PROGRAM

Program:

ORG 0000H
MOV DPTR,#LOOKUP //address of look-up table
REPEAT: MOV R1,#18
CLR A
NEXT: MOV R3,A // save A
MOVC A,@A+DPTR // fetch the value in look-up table
MOV P2,A //send to DAC
MOV A, 3 //retrieve A
INC A // next entry in the look-up table
DJNZ R1,NEXT
CLR A
MOV R2, #18 //negative cycle 180 to 360
NEXT1 : MOV R3,A //save A
MOVC A,@A+DPTR //fetch the value in look-up table
CLR C //clear carry before Subtraction
MOV R4,A // find negative value
MOV A,#0FFH
SUBB A,R4
MOV P2,A // send to DAC
MOV A, R3
INC A //next entry in look-up table
DJNZ R2, NEXT1
SJMP REPEAT // repeat cycle forever

LOOKUP: DB 128,150,171,191,209,225,238,247 //Look-up table


DB 252,255,253,247,238,225,209,191
DB 171,150
END
8. RESULTS

After serial communication when we give input to DAC , we get different waveforms at
different frequencies. For sine wave below output we received for look up table values
128,150,171,191,209,225,238,247,252,255,253,247,238,225,209,191,171,150
9. CONCLUSION
A device for DAC interfacing and serial communication and generate waveform with
required frequency being received from remote PC using 8051 microcontroller is designed
and built. The experimental results show that variable waveform of acceptable accuracy
could be obtained with a high degree of flexibility, small size and a small number of
components. The upper frequency range is limited by the switching frequency of the
microcontroller. Thus, the future work may include the multiprocessor or
multimicrocontroller implementation of the microcontroller-based function generator.

.
REFERENCES

1. Manish K Patel “ Microcontroller based embedded system


2. Vol. 3 |Issue 04, 2015 |ISSN(online) 2321-0613| IJSRD- International Journal for
Scientific Research & Developement
3. https://www.zseries.in/embedded%20lab/8051%20microcontroller/dac%20interfaci
ng.php#.XzmSj-gzbIV
4. https://www.tutorialspoint.com/interfacing-dac-with-8051-microcontroller
5. https://components101.com/max232-pinout-features-datasheet
6. http://codebloges.blogspot.com/2018/07/dacdigital-to-analog-conversion-
using_73.html?m=1

You might also like