Embedded Lab Course with PIC18F4550
by IIT Bombay 2017-18
Prerequisites: Knowledge of μC, embedded-C programming, MPLAB IDE, debugging, comm. Protocols
Getting things done: Installing MPLAB and Introduction to PIC board
Kindly go through this video tutorial. This board is powered by USB. For programming the device, USB bootloader mode is used as it's much faster and economical to program than PIC emulator by Microchip. Linker file provided is necessary to build program with this controller.
Check FAQs section incase of any queries or comments below. Do not get confused with header files used in code. It's just a means to shorten the length of the program. The syntax might change as per controller used but the algorithm remains the same. The below course is strictly performed on PIC18F4550 board. If you are using any other μC, study it's Datasheet thoroughly.
Revision of basics of C- programming:
- Store 10 different numbers in 10 consecutive memory locations. Then clear these memory locations (Use array to store numbers in memory and its pointer to clear content)
- Find the sum of N numbers starting from 1 and store the partial sum values in N consecutive memory locations. Your program should result in having 1, 3, and 6 in initial memory locations. The value of N should be taken between 10-20.
- C-program to read 10 numbers from one set of location and copy these numbers to a different set of location.
- C-program to sort 5 numbers (stored in memory location) in an increasing order using any sorting algorithm. Store the sorted numbers in some other memory location. (contents of the original array should not be destroyed or re-ordered.)
Solution
Port reading and LCD interfacing:
To read the switch status and accordingly display the status on the corresponding LED.
Write a program that will display two lines of text on the 16x2 LCD display so that they are left-aligned. The lines are stored in the form of null-terminated strings.
Modify the program to display a single line of text which has more than 16 characters, as a scrolling display. Use the string “My first lab program works! ” as the string to display.
Write a program to interface the same LCD in 4bit mode.
ADC interfacing:
To sample the voltage on the analog input line and display the value on the LCD. Use a 1KΩ pot whose fixed terminals will be connected to the VDD (3.3V) and VSS (0V) of the board and the variable terminal shall be connected to the AnalogIn. Verify voltage manually on DMM.
Timers and Interrupts:
Write a function that generates PWM, a square wave of given duty cycles as an output on one of the port pins using one of the timers of the PIC18F4550 MCU.(The frequency of the signals remains constant & can be between 1-10 kHz)
20 % [when switch RB5 is ON]
40 % [when switch RB6 is ON]
60 % [when switch RB7 is ON]
Interface 16x2 LCD
Write a program to measure and display the amplitude of a sine wave with a DC offset which is applied externally to onboard ADC (use Function Generator to generate a sine wave of 100 Hz, with an offset of peak value of the signal. Make sure that the input sine wave is always positive, the amplitude of the signal never goes beyond 3V.)
Using part-A, write a function that generates a square signal whose duty cycle depends on the peak voltage of the sine wave measured by the ADC in part-C.
20% DC if the peak voltage is between 0V to 1V.
40% DC if the peak voltage is between 1V to 2V.
60% DC if the peak voltage is between 2V to 3V.
Serial Communication using UART:
Write a program to send a string to computer from a microcontroller using UART. Capture data in the terminal and record it.
DAC Interfacing:
Write a program to generate Sawtooth wave of 3.3v & 1kHz at the output of DAC 0808.
SPI Protocol:
Write a program to interface MCP4921 DAC with PIC18F4550 using SPI protocol.
Setup for SPI with MCP4921Data ="1000-0000-0000" with gain 1. Expected output is 2.5v when the VREF is 5v
RTC using I2C Protocol:
Write a program to send Date & Time to RTC- DS1307, Read from IC continuously, and Display this information on 16x2 LCD using PIC18F4550.
Specifications
Operating Circuit of DS1307
R=10kOhm
No comments:
Post a Comment