You are on page 1of 13

Control Systems Project Report

Balancing Of Beam with Two Fans

Submitted By: 2009-MC-01 Sidra Haroon 2009-MC-09 Awais Ahmad 2009-MC-14 Sidra Yaseen

Submitted To: MissAminaYounus

DEPARTMENT OF MECHATRONICS & CONTROL ENGINEERING University of Engineering and Technology, Lahore

30thMay, 2012

INTRODUCTION:
Our primary task was to balance the beam with the help of fans on two sides of the beam. Initially the beam should not be balanced; it will be balanced when the input power is supplied. When input power will be supplied then the microcontroller will allow a particular PWM to the fans. The PWM supplied by controller can be same or different for both of the fans. In this way the beam will be balanced. Our project has basically 3 phases associated with it. 1. Mechanical Design 2. PCB Design 3. Coding of Microcontroller

WORKING:

MECHANICAL DESIGN:
In this phase, the hardware or mechanical part of project was designed. We have designed the required beam assembly in Solid Edge.

COMPONENTS:

Name
Beam bearings Springs Nuts and bolts Fans

Specification
30x10cm Taken out of old fan To keep the support of beam at centre position For fastening according to requirement 9x9cm

Fig1:

Fig 2:

PCB DESIGN:

ISIS Design:

ARES Design:

RESULT AND CONCLUSIONS:


1

APPENDIX A
CODE:
#include<p18f452.h> #include<math.h>

#pragma config OSC=HS,OSCS=OFF #pragma config PWRT=OFF,BOR=ON,BORV=27 #pragma config WDT=OFF #pragma config DEBUG=OFF,LVP=OFF,STVR=OFF

//////////// Function Declarations ////////// void msdelay(unsigned int time); void sys_init(void); void RPM_R(int percent); void RPM_L(int percent); void ADC_Avg(void);

////////////// Global Variables ///////////// unsigned int unsigned float unsigned char char long float count=0,balance=0; feedback,setpoint,k,kp=0,ki=0,kd=0; pwm=0,pwm_R=0,pwm_L=0; error=0,pre_error=0,tilt=0; integral=0,derivative=0;

void main (void) { sys_init(); //all system initializations

balance=50; kp=1.5; kd=40; //ki=0.1; while(1) { ADC_Avg(); error=setpoint-feedback; tilt=setpoint-balance;

//beam balanced at 'feedback=50'

if (setpoint>balance) { k=0.2; } else { k=0.3; } pwm_R=50+(k*tilt)+(kp*error)+(kd*derivative);//+(ki*integral); pwm_L=50-(k*tilt)-(kp*error)-(kd*derivative);//-(ki*integral);

//////////// IN CASE OF ACTUATOR SATURATION ///////////// if ((pwm_R>100)&&(pwm_L<0)) { pwm_L=0; pwm_R=50; } else if ((pwm_L>100)&&(pwm_R<0)) { // // // // // // //

pwm_L=50; pwm_R=0; } else { pwm_R=pwm_R; pwm_L=pwm_L; }

// // // // // // // //

//////////////////////////////////////////////////////////

RPM_L(pwm_L); RPM_R(pwm_R); //integral=integral+error; derivative=error-pre_error; pre_error=error; } }

void msdelay(unsigned int time) { unsigned int i,j; for(i=0;i<time;i++) for(j=0;j<135;j++); }

void sys_init(void) { TRISC=0x00;

TRISD=0x00; TRISB=0x00;

TRISA=0xFF; ADCON0=0X81; ADCON1=0xC0; CCP1CON=0b00001100; CCP2CON=0b00001100; PR2=255; T2CON = 0b01111011; T2CONbits.TMR2ON=1; //Frequency selection of pwm //Timer 2 settings for pwm //Select Pwm mode of CCP modules

PORTC = 0x00; PORTD = 0x00; RPM_L(100); RPM_R(100); } void RPM_R(int percent) { CCPR1L = percent*2.55; } void RPM_L(int percent) { CCPR2L = percent*2.55; } void ADC_Avg(void) { int i; //conversion from %age into CCPRxL //conversion from %age into CCPRxL

ADCON0=0X81; feedback=0; for(i=1;i<6;i++) { msdelay(1); ADCON0bits.GO=1; while(ADCON0bits.DONE==1); feedback=ADRES+feedback; } feedback=feedback/5; feedback=feedback/10.24;

//channal 0 select

//averaging loop

//average //conversion in %age

ADCON0=0X89; setpoint=0; for(i=1;i<6;i++) { msdelay(1); ADCON0bits.GO=1; while(ADCON0bits.DONE==1); setpoint=ADRES+setpoint; } setpoint=setpoint/5; setpoint=setpoint/10.24; }

//channal 1 select

//averaging loop

//average //conversion in %age

APPENDIX B

Pin Configuration of Voltage Regulator:

Pin Configuration of Potentiometer:

Pin1=Vin Pin2=Vout Pin3=GND

You might also like