1. The document contains 5 microcontroller programming assignments involving using timers and interrupts to generate frequencies, transmit data over serial, and monitor turbine system parameters.
2. The last assignment involves designing a control and monitoring system for a turbine that measures temperature, pressure, and RPM using an ADC, pressure switch, and timer, and controls the turbine based on the readings.
3. Interrupts and timers are used to measure the parameters periodically and transmit the readings over serial communication.
2. Q : 1 Write a program to to out 1KHZ frequency by using CCP(compare mode) ?
void interrupt(void);
void main() {
CCP1CON=0x02;
PIR1.CCP1IF=0;
PIE1.CCP1IE=1;
CCPR1L=0xC4;
CCPR1H=0X09; //set value (2500 dec) annd in 9c4 in HEX
INTCON=0xc0;
TRISC.F2=0;
T1CON=0x08;
INTCON.TMR1IE=1;
INTCON.TMR1IF=0;
TMR1L=0x00; //we set as a counter
TMR1H=0X00;
T1CON.TMR1ON=1;
while(1){}
}
void interrupt(void){
if(PIR1.CCP1IF)
{
PIR1.CCP1IF=0;
}
}
3. Q: 2 Write a program to Out different Frequencies using Switch ?
If Sw1==1 frequency out = 1KHZ
Sw2 == 1 Frequency out = 2KHZ
Sw3== 1 Frequency out = 3Khz
int count = 0;
void main()
{
TRISD.F0=0;
T0CON=0x08;
INTCON.TMR0IE=1;
INTCON.TMR0IF=0;
TMR0L=0XF0;
TMR0H=0XD8;
PORTD.F0=1;
count=1;
T0CON.TMR0ON=1;
INTCON.GIE=1;
TRISB.F0=1;
TRISB.F1=1;
TRISB.F2=1;
PORTB=0X00;
while(1)
{
if(portb.f0=1)
{
count=0;
}
if(portb.f1=1)
{
count=1;
}
if(portb.f2=1)
{
count=2;
}
}
}
void interrupt()
{
if( INTCON.TMR0IF==1)
{
if(count==0)
{
INTCON.TMR0IF=0;
5. Q : 3 write a program to ON OFF LED 1SEC delay through Timer.
# define led PORTD.F0
int count=0;
void main (){
TRISD.F0=0;
T0CON=0X08;
INTCON.TMR0IE=1;
INTCON.TMR0IF=0;
TMR0L=0XF0;
TMR0H=0XD8;
led=1;
INTCON.TMR0ON=1;
INTCON.GIE=1;
INTCON.PEIE=1;
while(1){
if(count==249){
count=0;
INTCON.TMR0ON=0;
TMR0L=0XF0;
TMR0H=0XD8;
led=~led;
delay_ms(1000);
INTCON.TMR0ON=1;
//INTCON.TMR0IF=0;
10. Q : Design a control and monitoring system of turbine system
Monitoring parameter are
1: temperature
2: Pressure
3: RPM sensor to measure Revolution per/min of Turbine
LM35 for temperature
Pressure switch for Measure pressure
Frequency meter for RPM
If temp> 100 || pressure switch is ON then make the turbine
void setintterupt();
void ADCset();
#define turbine portb.f4
void interrupt(void);
void serial_sent(float f,int a,int f);
char *data_;
float temp;
int i,count;
int result;
char start;
int pressure,RPM;
int seccount,ExternalFreCount,Frequency=0;
void serial_setting();
void serial_setting()
{
RCSTA=0x90;
TXSTA=0X20;
RCSTA.SPEN=1;