??? 11/25/09 10:42 Read: times |
#171156 - Its working Responding to: ???'s previous message |
Thanks members for helping me out...
There was some problem with the hardware and not the program...i did not connect the Opto-couplers that were feeding into the 74LS132 properly... Daniel, you were correct..have to fire the Triac nearer to the zero line... I've tried to put in all the comments as well with my final code.... Now i will this to control a Eddy current motor with this program with some changes and of course help from you guys...sorry if i've missed any comments... #include <reg51.h> #include <generic.h>//this contains the functions for delays(sec, mili sec and micro sec) sbit GREEN = P3^6; //Indication LED sbit YELLOW = P3^7; //Indication LED sbit output_ = P1^2;//Output connected to the Triac Trigger bit START = 0; //Start the Trigger bit STOP = 1; //Stop the Trigger /*============================================================================= SET FREQUENCY : 50Hz Each half of the AC cycle lasts 0.01 sec. and the timer counts 0000h to FFFFh in this time. We will control this time and switch on and off pin 1.0 that is the output. We will take the ext int 0 negetive edgs as the start point. /*=============================================================================*/ char set_point_L = 0x00, set_point_H = 0x00; /*==============EXTERNAL INTERRUPT 0 SUBROUTINE================================*/ /* When there is the Negetive edge at the P3^2 the control jumps to the ISR This routine first stops the timer, then loads the desired values into TH0 and TL0 using set_point_H and set_point_L respectively. Then starts the timer and then eventually triggers the Triac. */ void ex0_isr (void) interrupt 0 { TR0 = 0; //Stop timmer TL0 = set_point_L; //Loading the initial value, lower Byte - thus reseting timmer TH0 = set_point_H; //Loading the initial value, Higher Byte - thus reseting timmer TR0 = 1; //start timmer output_ = STOP; //Stops the Trigger } /*====================TIMER INTERUPT 0 SUBROUTINE==============================*/ /* When the timer overflows it stops the trigger. I here stop the timer as well so that it does not keep on counting. */ void timer0_ISR (void) interrupt 1 { output_ = START; //starts trigger TR0 = 0; //Starts the timer } /*=============================================================================*/ void initialize_global_interupt(void) { IE = 0x83; //10000011 global enable, ext int 0 ,timer int 0 and timmer int 1 (for baud rate) enabled } /*=============================================================================*/ void initialize_timer_0(void) { TR0 = 0; TMOD = 0x01; //00000001Set Mode(16-bit timer with reload) TL0 = 0x00; //Loading the initial value, lower Byte TH0 = 0x00; //Loading the initial value, Higher Byte } /*=============================================================================*/ void initialize_external_int_0(void) { IT0 = 1; //making the external interupt edge trigerred } /*============================================================================= Here the counter counts from values of "set_point_L,set_point_H" upto "FFFFh" Now then the ext-interupt-1 occurs, the trigger is switched ON and when the timmer interrupt overflows occurs the the trigger is switched OFF. Now if we load the value FFF1h then the trigger is switched on for FFF1h to FFFFh. Thus this gives us lowest intensity. Whereas if we load the value DBFEh the trigger is switched on for DBFEh to FFFFh. Thus this gives us Highest intensity. /*=============================================================================*/ void main (void) { //Here we indicate that the main function has sucessfully commenced GREEN = 0; YELLOW = 0; sec_wait(1); GREEN = 1; YELLOW = 1; msec_wait(200); //Here we start the initilization of interrupts initialize_timer_0(); initialize_external_int_0(); initialize_global_interupt(); while(1) { /*Here we start with the lowest intensity as the trigger is on for FFF1h to FFFFh*/ set_point_L = 0xFF; set_point_H = 0xF9; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xF3; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xED; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xE7; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xE7; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xE1; sec_wait(1); /*Here we have the Highest intensity as the trigger is on for DBFEh to FFFFh*/ set_point_L = 0xFF; set_point_H = 0xDB; sec_wait(1); /*Now again the intensity starts ti dimish************************************/ set_point_L = 0xFF; set_point_H = 0xE1; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xE7; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xE7; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xED; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xF3; sec_wait(1); set_point_L = 0xFF; set_point_H = 0xF9; sec_wait(1); } } /*====================================*/ |
Topic | Author | Date |
Intensity control | 01/01/70 00:00 | |
show some CODE | 01/01/70 00:00 | |
Dear Erik | 01/01/70 00:00 | |
where are the comments? | 01/01/70 00:00 | |
We can't read your mind | 01/01/70 00:00 | |
Erik & Richard | 01/01/70 00:00 | |
What prevents you from putting in the required comments? | 01/01/70 00:00 | |
While putting in comments i saw one error | 01/01/70 00:00 | |
Hmmmm... | 01/01/70 00:00 | |
Jitter | 01/01/70 00:00 | |
still no luck | 01/01/70 00:00 | |
We have not seen the schematics | 01/01/70 00:00 | |
Its working | 01/01/70 00:00 | |
Another Program to test my interrupt !! | 01/01/70 00:00 | |
Code legibility![]() | 01/01/70 00:00 |