Professional Documents
Culture Documents
Submitted By: 2009-MC-01 Sidra Haroon 2009-MC-09 Awais Ahmad 2009-MC-14 Sidra Yaseen
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:
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;
//////////// 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)) { // // // // // // //
// // // // // // // //
//////////////////////////////////////////////////////////
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
//channal 0 select
//averaging loop
//channal 1 select
//averaging loop
APPENDIX B