anika_ch
Newbie level 3
i am working on a project "automatic gate control and track switching in railways".i m facing problems in doing the track switching part.i am not sure about wic hardware should be used to switch the track??????.i m using a toy train in dis project n m using 8051..if i want to stop the train den do i need to design a model train????n in that case do i need to use pwm????
i have used d following code to stop d train..but i m uncertain about the condition wic i shud give in the interrupt call....
plzz help me...
#include <reg51.h>
sbit PWMPIN=P1^0;
sbit SW =P1^7;
sbit IND =P1^3;
sbit my = P1^6;
unsigned char pwm_width;
void timer0() interrupt 1 {
if(my==1) { //Start of High level
my = 0; //Set flag
PWMPIN = 0; //Set PWM o/p pin
pwm_width =0x10 ;
TH0 = pwm_width; //Load timer
TF0 = 0; //Clear interrupt flag
return; //Return
}
else { //Start of Low level
my = 1; //Clear flag
PWMPIN = 0; //Clear PWM o/p pin
TH0 = 255 - pwm_width; //Load timer
TF0 = 0; //Clear Interrupt flag
return; //return
}
}
int main()
{
TMOD = 0x00;
EA = 1;
ET0 = 1;
TR0 = 1;
IE=0x82;
while(1)
{
SW=IND; }
return 0;
}
MOD: Using SMS language is not allowed in this forum. Next time you will get a warning.
i have used d following code to stop d train..but i m uncertain about the condition wic i shud give in the interrupt call....
plzz help me...
#include <reg51.h>
sbit PWMPIN=P1^0;
sbit SW =P1^7;
sbit IND =P1^3;
sbit my = P1^6;
unsigned char pwm_width;
void timer0() interrupt 1 {
if(my==1) { //Start of High level
my = 0; //Set flag
PWMPIN = 0; //Set PWM o/p pin
pwm_width =0x10 ;
TH0 = pwm_width; //Load timer
TF0 = 0; //Clear interrupt flag
return; //Return
}
else { //Start of Low level
my = 1; //Clear flag
PWMPIN = 0; //Clear PWM o/p pin
TH0 = 255 - pwm_width; //Load timer
TF0 = 0; //Clear Interrupt flag
return; //return
}
}
int main()
{
TMOD = 0x00;
EA = 1;
ET0 = 1;
TR0 = 1;
IE=0x82;
while(1)
{
SW=IND; }
return 0;
}
MOD: Using SMS language is not allowed in this forum. Next time you will get a warning.
Last edited by a moderator: