Aims
• To create a simple signal modulator
• To report on the program's design and operation
Equipment
• PIC Trainer and ICD3 in-circuit debugger
• MPLAB X Integrated Development
Environment software
• Laboratory CRO and signal generator
Task
Write a PIC program to enable the PIC trainer board to be used as a signal generator with a modulation input. The modulator should generate a sine wave carrier on DAC channel A whose amplitude or frequency is controlled by an analog signal read from ADC channel 2. The carrier frequency should be selectable over the range 100 Hz to 10 kHz, as determined by the positions of switches 1, 2, and 3 (RB2, RB3 and RB4) on DIP S1 on the main board. For testing purposes, when all 3 switches are off, the modulator should produce a 100 Hz unmodulated sine wave. The type of modulation — whether amplitude modulation (AM) or frequency modulation (FM) — should be selectable by setting DIP S1 switch 4 (RB5). In AM mode, the depth of modulation should be such that when the modulating signal input is 0V the output amplitude is 0V peak-to-peak, and when the modulating input is 5V the output amplitude is 5V peak-to-peak. In FM mode the depth of modulation should be such that when the modulating signal swings between 0V and 5V the output frequency varies by around 20% of its nominal value.
You can verify that your modulator is working correctly by connecting a signal generator to the modulation input and monitoring the output signal on a CRO. Note that the figure above shows a realistic picture of amplitude modulation (assuming the modulating signal is adjusted to a suitable frequency, amplitude, and offset), but the FM signal exaggerates the depth of modulation.
Report
Write a report on the design and performance of your program. The report should be between 1500 and 2500 words (around 5 typed pages) not including appendices, and should contain the following sections:
• Introduction: A brief description of the task your program is solving and any necessary instructions on how to configure the hardware and run the program.
• Development process: An account of the process you followed in developing your solution, including any difficulties you faced and how you overcame them.
• Code outline: An overview of your final code, including a brief description of the purpose of each module. Note that this description should complement the documentation in the code itself.
• Design Decisions: A discussion of the key design decisions you made in writing your code, including alternatives you considered and the reason why you made the decision you did.
• Performance Evaluation: A clear indication of how much of the problem your program solves, and experimental data to verify that your program works as claimed.
• Appendix: A full listing of your code. MPLABX can produce a formatted listing, but you'll probably need to adjust the print settings so that you've included all appropriate information.