Você está na página 1de 13

Digital-to-Analog Converter Subsystem

By Team 7even: Abylay Bakishev, William Renner, Zhao


Yanzhe

Table of contents:
1. Introduction
2. Rationale
3. Implementation
4. Discussion
5. Conclusion
6. Appendices

Introduction
The goal of Laboratory 3 is to characterize the input-output response of a black
box circuit using a diagnostic suite. The diagnostic suite has 4 mbed controllers:
the Digital-to-Analog Converter (DAC) subsystem, the Digital Potentiometer
(DigiPot) subsystem, the Analog-to-Digital Converter (ADC) subsystem and
keypad subsystem. The keypad sends different commands to the other subsystems
through a common CAN bus. Each command has a different operation on
subsystems. The system requirements for the DAC subsystem part are to create
square and sinusoidal waves at 1 Hz and 10 Hz spanning 0 to +3.3 V. Then the
DAC subsystem output is modulated by DigiPot to have a voltage range of 0 to +1,
2, 3, 4, or 5 V. The modulated output waveform needs to be send to the black box.
Finally, the ADC subsystem needs to sample the output of the black box at 100 Hz
and output the samples to a PC terminal over USB or save locally on the mbed.

Our team were assigned for the DAC subsystem. In order to correctly
characterize the output from the black box circuit we required to create a waveform
of appropriate shape and frequency. Since the output of the DAC subsystem used
as an input for our black box, it plays an important role in sampling and analyzing
the resultant output.
In order to complete our task, we have created code for the mbed controller. The
switch-case structure of the code outputs required waveform depending on
commands received from Keypad through the CAN (Controller Area Network)
bus.

Rationale
The Digital-to-Analog Converter (DAC) is the main part of our system which
generates different types of waveforms. The DAC subsystem can be controlled by
the user through the Keypad which connects to our system through a CAN bus.
The requirements of our DAC subsystem were:
receive commands from the Keyboard subsystem to stop/start and select the
waveform
create a square or sinusoidal wave at 1 Hz or 10 Hz spanning 0 to +3.3V
The output of our subsystem is received by the DigiPot and modulated to a desired
voltage range.

Our subsystem needs to be connected to a common data bus in order to receive


commands from the Keypad. We chose to use CAN (Controller-area Network), it
is a bus standard designed to allow microcontrollers and devices to communicate
with each other without a host computer. The CAN specifications use the terms
"dominant" bits and "recessive" bits where dominant is a logical 0 (actively driven
to a voltage by the transmitter) and recessive is a logical 1 (passively returned to a
voltage by a resistor) so that it prevents messages from colliding with each other on
the CAN bus. If one node transmits a dominant bit and another node transmits a
recessive bit then there is a collision and the dominant bit "wins".

Implementation

For the code of the DAC we had 2 major parts. We had a DAC control function
that created subprograms for each type of wave and a main function that
interpreted the CAN input signal and and used the DAC sub functions to generate
the wave.
Main Function

The main function is featured above. It establishes a group ID that is used to


determine if the signal is meant for our device or not and then it reads a number
sent by the keypad with our group ID and starts to generate a certain waveform
based on what that number is. We worked with the keypad group to determine
what number would cause what type of wave. We used an if statement with the
subprograms from the DAC program to generate the waves as well as printf
statements to let us troubleshoot.
DAC program

In order to generate two waveforms at different frequencies, our group used a


while loop to generate the required waveforms in real-time in unison with a
microsecond counter. We set the frequency by changing the time period of the
waveforms. The time period would be 0.1 seconds for the frequency of 10 Hz
while the time period would be 1 second for the frequency of 1 Hz. Our group used
the following methods to generate the sinusoidal waves and square waves.

For the square wave, the voltage changed every half time period. To accomplish
this, we used the modulus operator to calculate the remainder and determine how
far into a cycle the loop was. The time unit is set in microsecond since we are
looking for the most accurate waveform after the delay. When the frequency is set
at 1 Hz, the voltage is equal to 3.3 volts if the reminder is less or equal to 0.5
seconds. We can also regard it as the first half part of one time period. The voltage
is equal to 0 volts when the remainder is greater than 0.5 second. The principle also
works when the frequency is set at 10 Hz, but instead we need to compare the
value with 0.05 seconds. For the sinusoid wave, since the range of the sine wave is
from -1 to 1, we add 1 in the function in order to shift the wave above the x-axis.
So, the range of the sine wave is changed to 0 to 2 volts and then we produced the
3.3 volts peak to peak sine wave by multiplying a factor of 3.3/2. We adjusted
some of these values do to a slightly different output than what was expected, this
was done largely through guess and check but our final output ended up being
exactly what we needed.

Block Diagram

Verification Testing
In this project, 3 groups cooperated together to complete the overall system
including the keyboard subsystem, Digital-to-Analog Converter subsystem, and
Digital Potentiometer. The keyboard subsystem controls the settings and
parameters of the other two groups. The keypad subsystem sends commands to the
DAC subsystem to start/stop and select the waveform and to the Digital
Potentiometer subsystem to select waveform amplitude. Also, the keypad
subsystem receives user input from a digital keypad, which is then interpreted into
the commands via the mbeds coding. For our DAC group, the physical integrated
circuit diagram is shown below:

Testing
For the method of testing, we connected the output of the DAC converter chip to
the oscilloscope to verify whether the waveform and frequency matched up with
the desired values. The ideal waveforms and frequencies were sinusoid waves at 1
Hz and 10 Hz, and square waves at 1 Hz and 10 Hz. The requirements for
verification were that the error should less than 10%, which means our frequencies
should be in the range from 0.9, Hz to 1.1 Hz for 1 Hz and 9 Hz to 11 Hz for 10
Hz. After testing initially, we adjusted our values on got the output below;

Sinusoidal Waves at 1 and 10 Hz


Square wave at 1 and 10 Hz
As displayed above, our circuit completes the outlines objectives. our full 3 part
circuit was demonstrated in class and several outputs are displayed below. The
yellow line is the output from our 3 part circuit while the green is the output from
the black box.
Black box analysis
A series of diagnostic tests using the integrated system were carried out on a black
box circuit of unknown contents. Based on the response to these tests, the black
boxs transfer function was determined to be approximately:

Vout = 1-.01Vin

This equation was determined by examining the output of sine and square waves at
frequencies of 1 Hz and 10 Hz and amplitudes of approximately 1, 2, 3, 4, or 5 V.
In actuality, due to limitations of the DAC equipment and the digipot design, the
actual amplitudes of the inputs were slightly different from the ones listed here.
Regardless, the gain of the black box was still easily found from these values
accounting for a small amount of deviation due to limitations of our system.

Based on the transfer function of the black box circuit, it was inferred that the
circuit was likely an inverting op amp with a fractional gain of 0.1, with a positive
offset of 1 volt achieved by the application of 1 volt to the non-inverting terminal.

Discussion
Our system will receive the command from the keyboard system through the
CAN bus. So we selected MCP2551 as the receiver. Its a chip that could be driven
by 5 volt with low current and then responded with operations and the transmission
rate of it could be as high as 1 Mb/s. In the implementation, we checked the Can
bus message every second. We want to see if the correct ID could be received
successfully from the CAN bus. The TA also tell us a way to debug the code when
we get some trouble with it on the mbed system. We also implemented a logging
system. If the message is sent to our group as a command, the current status will go
back to the terminal on the PC through the USB serial port. Beside the CAN bus,
another bus called SPI bus could also be used in this project. It is a synchronous
serial data link which could be used in short distance, and single master
communication. In order to transfer information, one master device communicating
in master/slave mode are used in it with other slave devices. But using the SPI will
have some disadvantages as there are many existing variations, which make it
difficult to find development tools like host adapters which support those
variations. And its more expensive than the CAN bus. So, we decided to use CAN
bus based on those considerations.
We then optimized the accuracy of our output signal. We found that change
the interval to microseconds will improve the amplitude accuracy. But the accuracy
of the amplitude and the accuracy of the frequency could not be protected at the
same time. The higher delay resolution, the higher amplitude accuracy, and the
lower frequency accuracy. Based on many tests we did, we found that setting the
time interval to 1000 microseconds will reach the equilibrium point.
In the first lab, we read the assignment handout and then we built the
diagnostics system block diagram. We figured out that the DAC subsystem we are
going to implement will receive the command from the keyboard subsystem and
then sent out the analog signal wave Through the CAN bus which will be a voltage
signal. As the lab should be finished in five weeks, we made a schedule to plan for
it. Besides the regular lab time, we also did some extra group meetings in order to
finish it on time. As this project will need the cooperation with other groups, we
contacted each group in our section well and discussed with them to find out a way
to solve the problem. As we need to receive the command from the group who do
the keyboard subsystem. We try to follow their process in order to keep our
cooperation. In my mind, this is really a good lab as we not only learned skills
from the lab, but also improved our communication skills by cooperating with
other group members.

Conclusion
In this project we integrated the mbed LPC1768 microcontroller, MCP2551 CAN
Bus Transceiver and MCP4725 DAC Interface to design a waveform generator for
the system. At the final week of demonstration, our DAC subsystem was able to
successfully receive commands from the Keypad subsystem and generate desired
signal. Since the complete system operated correctly we achieved our goal of
characterizing the black box. During this project, we had an experience on one of
the most important skill for our future career - a system engineering process. All of
the processes like design, integration, verification and validation tests were studied
and applied during this project. Finally, the project was good and useful exercise
on our programming, team building and technical writing skills.

Appendices
Bill of materials (DAC subsystem)

Item Price per unit Quantity


mbed LPC1768 69.00 $ 1
microcontroller
MCP2551 CAN Bus Transceiver 1.18 $ 1

MCP4725 Breakout Board 4.95 $ 1


(DAC)

Total Cost: 74.83 $

Você também pode gostar