0% found this document useful (0 votes)
124 views

PIC Simple Signal Generator

Simple Signal Generator, capable of generating repeating or non-repeating electronic signals with the use of Pulse Width Modulation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views

PIC Simple Signal Generator

Simple Signal Generator, capable of generating repeating or non-repeating electronic signals with the use of Pulse Width Modulation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Application: Simple Signal Generator

Remark: Capable of generating repeating or non-repeating electronic signals with the use
of Pulse Width Modulation.

1) Draw a high-level block diagram to show the inputs/output devices and any other
modules connected with the microcontroller. Briefly explain the diagram.

Power Supply

PIC18F4550
PRESET LCD
Microcontroller

PIC18F4550 controller has in-built 10-bit PWM module known as CCP module. CCP stands for
Capture/Compare/PWM. There are two CCP modules (CCP1 and CCP2), this means we can
generate two PWM signals on two different pins.
• An analog input should be given to the microcontroller. For that, a keypad is used.
• PIC18F4550 has 13 channels which mean 13 analog input signals can be converted
simultaneously using the module. 8 clock inputs which can be chosen as we need, are
available for conversion and the module can be configured in auto triggering mode.
• In PIC18F4550, only Timer2 can be used for PWM generation. TMR2 is a 16-bit Timer2
register which is used to hold the count. (All PWM modules in a PIC Microcontroller
uses Timer 2 for its operation, so you cannot set different frequencies for different PWM
modules)
• LCD displays the necessary PWM waveforms and also the relevant details.
• Power is supplied through a regulated power supply.

2) State all the assumptions you have made.


• This is assumed to be done with PIC18F4550.
• It generates only one type of wave.

3) Briefly explain the communication modes you will be using in your system.
• LCD communicates with parallel communication mode with the microcontroller.
• PIC18F4550 has an inbuilt EUSART (Enhanced USART).
4) State if you are using Analog to Digital or Digital to Analog converters in your system.
State why? If you are not using AD converters, briefly explain why.

There is no any use of converters in this design as an inbuilt ADC module is there in the
microcontroller. Therefore, we can give the input of preset directly into the analog pins. And also
the LCD displays the digital value 1 as 1V and 0 as 0V. Therefore, any DAC is not needed in the
design.

5) Draw a flowchart to represent the logical flow of your system.


6) Write the C code to implement your project.

#include<pic.h>

#define __XTAL_FREQ_

void main() {
TRISC = 0;
PORTC = 0;
TRISA = 0X0f;
PORTA = 0;
TRISB =0XFF;//PUSH BUTTON

T2CON = 0X04;
CCP1CON = 0X0C;
PR2 = 99;
TMR2 = 0;

ADCON0 = 0X41;
ADCON1 = 0X0E;
OPTION_REG = 7;
TMR0 = 0;

INTEDG = 1;
INTE = 1;
GIE = 1;

while (1) {
if (T0IF == 1) {
GO = 1;
while (GO == 1) {
}
CCPR1L = ADRESH;
ADRESL = ADRESL >> 2;
CCP1CON = CCP1CON & 0X0F;
CCP1CON = CCP1CON + ADRESL;
T0IF = 0;
}
}
}

void interrupt isr() {


if (INTF == 1) {

T2CON = 0X04;
CCP1CON = 0X0C;

CCPR1L = 0XCD;
CCPR1H = 0X00;

}
INTF = 0;
}
7) Write an assembly program to generate the required delay as a separate program using
timers.

org 0x00
goto start

start bsf STATUS, RP0 ;switch to Bank 1


movlw 0x10
movwf TRISA ;PORTA all output
movlw 0x00
movwf TRISB ;PORTB all output
movlw 07h ;00000111
movwf OPTION_REG ;Counter mode, falling edge, prescaler set to maximum
bcf STATUS, RP0 ;switch to Bank 0
movlw 0xC8
movwf COUNT

main bcf PORTB,0


movf TMR0,0
sublw .200
btfss STATUS, Z
goto main ; keep looping until timer reaches 200
decfsz COUNT,1 ;if set, decrement COUNT
goto main ;if count is not yet zero, repeat the loop
main2 bsf PORTB,0 ;if count reaches zero, set PORTB.0
movf TMR0,0 ;repeat process to delay turn off
sublw .200
btfss STATUS, Z
goto main2
decfsz COUNT,1
goto main2
goto main
end

You might also like