digital-to-analog converter lab 3 final report
TRANSCRIPT
1
Digital-to-Analog Converter
Lab 3 Final Report
The Ion Cannons:
Shrinand Aggarwal
Cameron Francis
Nicholas Polito
Section 2
May 1, 2017
2
Table of Contents
Introduction………………………………………………………………………………………..3
Rationale…………………………………………………………………………………………..3
Theory of Operation……………………………………………………………………….3
Theory of Interfaces……………………………………………………………………….3
Implementation……………………………………………………………………………………4
Explanation of Code and Circuitry………………………………………………………..4
Verification Testing……………………………………………………………………….4
Validation Testing………………………………………………………………………....4
Results from Integrated System…………………………………………………………...5
Discussion………………………………………………………………………………………....5
Value Statement…………………………………………………………………………………...6
Conclusion………………………………………………………………………………………...6
Appendices…………………………………………………………………………………...........7
Appendix A: Code, Block Diagrams, and Pinouts………………………………………..7
Appendix B: Bill of Materials……………………………………………………………13
Appendix C: Gantt Chart…………………………………………………………...........14
References………………………………………………………………………………..14
3
Introduction
In Lab 3, we explored the process of working with embedded systems. It is common in
industry to take a large project and break it into multiple smaller projects in order to create
smaller and easier problems. For this lab, our project was broken into four subsystems that were
integrated together to determine what component was in the black box. The subsystems were the
keypad which controlled the actions done by the system, a Digital-to-Analog Converter, a Digital
Potentiometer, and an Analog-to-Digital Converter. The system diagram can be found in
Appendix A.
Our group, The Ion Cannons, was assigned to the Digital-to-Analog Converter (DAC).
The DAC accepted digital signals from the keypad and outputted an analog signal to the digital
potentiometer. The outputs from the DAC were either a sinusoid or a square wave with 1 or 10
Hz frequency. This was determined by what the input from the keypad was. These inputs
determined the type of wave, the frequency of the wave, and when to start and stop sampling.
The analog signal created by the DAC was significant because it allowed the DigiPot and black
box to manipulate the signal. After the signal was manipulated, the ADC outputted a digital
signal that we used to successfully determine the characteristics of the black box.
______________________________________________________________________
Rationale
The DAC subsystem generates specific waveforms and receives messages from the
keypad.
Theory of Implementation
The main function of DAC is to convert a digital signal to a corresponding analog
sinusoidal or square wave. It allows the user to start, stop, and select the frequency and type of
the output waveform. The waves oscillate at a frequency of 1 Hz or 10 Hz with an amplitude
ranging from 0±0.05 𝑉 to 1±0.05 𝑉.
The DAC communicates with the Mbed LPC1768 microcontroller to output the
waveforms. The waveforms will then communicate with the DAC MCP4725 chip through I2C
serial communication. The converted analog signal from the DAC will then be output as the
input for the DigiPot subsystem.
Theory of Interfaces
The DAC uses the CAN bus interface to read the commands from the keypad. The DAC
and the CAN follow I2C communication protocol. I2C is synchronous and operates on master-
slave format. The CAN uses a 3.3V TTL logic signal to take inputs from the keypad and the
DAC output waveforms to the digital potentiometer.
____________________________________________________________________
4
Implementation
Explanation of Code and Circuitry
In order to realize the Digital-Analog Converter (DAC) system we used a LCP1768
Mbed Microcontroller, a MCP4725 DAC, and a MCP2551 CAN Bus. The Mbed held the main
code and sent commands to the DAC and the CAN bus to convert and transmit the signals
needed by the keypad. To do this, we connected the DAC to pins 9 and 10 of the Mbed to utilize
the I2C communication protocols. This allowed us to use the Fast 400 kHz mode. We connected
the CAN bus to the CAN rd and td terminals to pins 30 and 29 respectively. This allowed our
circuit to read the commands sent from the keypad.
Using C code as shown in Figure 1, we instantiated the DAC output to achieve the 400
kHz mode of the I2C bus and utilized the functionality of pins 9 and 10. The device address was
determined to be 0x62. The serial instantiation and CAN instantiation allows for communication
between the computer and the Mbed, and between the Mbed and the CAN Bus respectively. We
reserved and defined some variables to keep the code aesthetic.
As shown in Figure 2, the DAC initiates as soon as the can bus sends 1 byte of data.
Next, we coded a 1 Hz sine wave that initiates as soon as the keypad sends a value of ‘2’. The
can bus reads the data from the keypad and starts a for loop nested within a while loop that
creates a 1 volt peak-to-peak wave. This signal is outputted to the DigiPot and modified by that
circuit. The output continues until the stop command is sent to the DAC. In Figure 3, we coded a
10 Hz sine wave that initiates as soon as the keypad sends a value of ‘4’ using the same process
as the 1 Hz wave. For the 1 Hz square wave, we coded a repeating step function from 0 to 1 Volt.
The wave initiates when the keypad sends a value of ‘1’. In Figure 4, we used the same process
to create a 10 Hz square wave when the keypad sends a value of ‘3’. Lastly, we coded an
interrupt to bring all outputs to 0 V, when a value of ‘12’ is received from the keypad.
Verification Testing
Our circuit and code was fully functioning at the end of verification testing. We went
through the code and tested each wave to see if it was reaching the right voltage peak-to-peak
using an oscilloscope. We made sure that the frequency was correct and that there were no lapses
in the output waves. Next, we tested to see how well it communicated with the keypad. The
signal was not being read by our CAN bus, due to incorrectly wiring the received and transmitted
pins. Once resolved, the code responded to all inputs upon command.
Validation Testing
During integration testing, there were no major problems from our DAC module. All
waves were output continuously and stopped upon demand. The Digipot module had a few
problems due to the components frequently malfunctioning. It worked a few times and it was
5
able to manipulate all the waves sent out by our DAC. Figure 5 shows all components of the
system during integration testing.
Results
Our DAC group successfully completed our module. We were able to determine that the
black box inverted the signal and modulated the amplitude to be ¼ of the original signal as
shown in Figure 6. The Keypad was able to send all five signals essential to operate the DAC.
We output the signals to the DigiPot to be modified and those signals were input into the black
box. The ADC read the output of the black box and output the voltage values coming from the
black box. The ADC output the data onto a graph that showed the modified wave.
______________________________________________________________________________
Discussion
Approach to Module, Network Interface, and Debugging
Our team started working on the project and familiarized ourselves with the operations
and requirements of the DAC. After familiarizing ourselves with the data sheets of the DAC,
microcontroller, and the CAN bus, we observed that I2C communication protocols had to be
used to communicate within the Digital to Analog converter subsystem and CAN bus to
communicate with the keypad.
The debugging process mainly consisted of CAN bus related circuitry. We struggled to
get the right connection for successful communication with other subsystems. After changing
some lines in the code and integrating our DAC with other subsystems, the systems
communicated successfully.
The I2C bus master slave configuration is convenient for intra-circuit communication
whereas the CAN bus is efficient and inexpensive. SPI can also be used to communicate with
other subsystems. In our project, SPI would have not been the best choice since, the keypad
needs to communicate with only one subsystem at a time.
Modification to Design during Integration
The only modification our team made after integration and verification testing was to
change a few lines in the code. Since the DAC’s input depends upon the keypad, it was crucial to
get the right command values. After changing the input values in the code, our DAC successfully
received commands from the keypad and could output the waveforms to the DigiPot.
Changes to be made if Lab was Done Again
There were no major flaws that our team experienced as a whole. But minor changes on
the organization of the project teams might help. Our group was ahead of the schedule and were
waiting on the keypad team to give us the command values required to integrate the two
subsystems. Since the keypad was not ready to communicate with other subsystems, we could
6
not test or validate the DAC for a week past the schedule. If there was a set of common ground
rules and protocols, the efficiency of all teams would have improved.
______________________________________________________________________________
Value Statement
The DAC subsystem played an integral role in the functionality of the whole system and
the determining of the black box. The outputs were created using the Mbed microcontroller,
Mbed compiler based on C code, CAN bus communication, DAC interface, and a simple
physical circuit. The Mbed online compiler was user-friendly and led to easy coding, testing, and
debugging. The DAC interface and Mbed microcontroller had easy pinouts which helped
simplify our subsystem. Overall, the experience of collaborating with other small projects for the
full system was engaging, interesting, and fun. Our team feels that other people who complete
this lab will find the same benefits.
______________________________________________________________________________
Conclusion
The efforts of all four teams working together led us to the successful completion of the
project. Individually, we reached our goals in a timely fashion and verified the functionality of
our modules. The factors that kept us successful were good communication and a strong
commitment to the work at hand. Integration was the most stressful part of the project, but we
believe we all came out as better engineers because of the complications that we faced. We will
take these experiences and learn from them to improve our understanding of technology well into
our professional careers.
______________________________________________________________________________
7
Appendices
Appendix A: Code, Block Diagrams, and Pinouts
Figure 1: First Section of Code
Figure 2: Second Section of Code
8
Figure 3: Third Section of Code
Figure 4: Fourth Section of Code
9
Figure 5: Integration Testing
Figure 6: Oscilloscope Capture of System Output with Black Box
10
Figure 7: Diagnostics System Block Diagram
Figure 8: Communication Requirements
11
Figure 9: MBED Pinout
Figure 10: DAC Pinout
Figure 11: CAN Bus Transceiver
12
Figure 12: CAN Bus Pinout
Figure 13: Black Box Pinout
Figure 14: Black Box Pin Specifications
13
Appendix B: Bill of Materials
Item Price
Breadboard $20.00
120Ω Resistor $0.01
LCP1768 MBED Microcontroller $64.00
MCP4725 DAC $4.95
MCP2551 CAN Bus $1.22
TOTAL PRICE $90.18
14
Appendix C: Gantt Chart
Section Task Week
1
Week
2
Week
3
Week
4
Week
5
Week
6
Week
7
Introduction Understanding
the MBED
Team
Inventory
Individual
Subsystem
Learning about
DAC
Programming
DAC
Building DAC
Circuit
Testing DAC
Programming
CAN Bus
Testing CAN
Bus
Entire
Subsystem
Integration of
all subsystems
Testing entire
system
Wrap-Up Demonstration
CDR writing
References
EE 300W Canvas Page and Resources.
Online Mbed compiler. <https://developer.mbed.org/compiler/>
CAN Bus Datasheet. <http://ww1.microchip.com/downloads/en/DeviceDoc/21667f.pdf>