Discussion in "8051 Discussion Forum" started by    zen bEaR    Feb 7, 2008.
Thu Feb 07 2008, 11:36 am
#1
hi,
i am trying to control the speed of a dc motor using pwm with an ir led and detector feedback system .the motor has an obstruction which blanks out the ir light. the program is such that, when a falling edge is detected, it jumps to the isr ,calculates time between this interrupt and the previous and determines whether the speed is too fast or too slow and then adjusts the pwm duty cycle (i'm using a pin on p2 for that) accordingly.

everything seems to be working fine, but there is a strange problem. the microcontroller seems to be going into the isr at the falling edge(which it is supposed to) as well as the rising edge( not supposed to happen!).

i initially thought it was because of noise coming to the int0 pin(p3.2) from the ir detector ckt( a simple transistor based ckt) so i added 2 not gates( 7404) to act as a buffer. the waveform on the oscilloscope seems to be clean, but the microcontroller is triggering at the falling edge as well as the rising edge

anybody have an idea as to what is going on?please help!
Thu Feb 07 2008, 12:11 pm
#2
how can you be sure that micro is going to ISR on rising edge also? have you detected this somehow?

try to write a simple program with same setup.. with ISR to toggle LED on a port PIN and keep motor on lowest speed so that you can easily figure out the working.
Thu Feb 07 2008, 07:05 pm
#3
yes i have..i wrote a small test prog which keeps p2.0 low normally but in the isr of int0 i keep it high for a short duration(long enough to see on the cro) i then move the motor by hand slowly.. now, when the light is blocked it is a falling edge and the micro goes to isr, p2.0 is high for a while and goes low. (the light is still blocked) now, when i remove the obscruction, it is rising edge but i can see p2.0 go high again and come back low after a while-meaning isr is executing again.

also- when the micro is in the socket of my test board, if i check the voltage between supply and ground (pin 40-vcc and pin 20-gnd) it is very noisy- not a straght dc line at 5 volts. when i remove the micro from the socket, it is clean..is this supposed to happen? shouldnt power supply be clean even with the micro in the socket
Thu Feb 07 2008, 07:14 pm
#4
can we have your piece of code cause the 51 understands the difference between the two ..(rising and fallin edges..) wud like to see how u have configured it!!... :-)
Thu Feb 07 2008, 09:44 pm
#5

#include <reg52.h>

unsigned int i;
sbit led=P1^1;
void interrupt0(void) interrupt 0
{
	led=1;
for(i=0;i<50000;i++);      //keep it on for a while 

}

void main(void)		  //main function
{
IT0=1;			//int 0 is edge triggered
IE=0x83;		//enable all ints along with tr0(not used here actually) intr and int0                  

       while(1)
         {   led=0;
        
         }
 
}

Thu Feb 07 2008, 09:45 pm
#6
thats the test prog i'm running, not the motor speed control
Thu Feb 07 2008, 10:29 pm
#7
if this is really happening
the on ly thing i can think of cud be the noise.. as u already checked...
because...

If the external interrupt is set to edge activation then the external source must ensure the pin is kept high for one complete machine cycle and then low for one complete machine cycle



now u ruC identifies high to low transition ... then may be u shud try with a pulldown on the into- bar... never faced such problem.. so didnt test it...
still you can try to pull down the INT0-PIN to GND with may be a 1K register... :-|
Thu Feb 07 2008, 10:35 pm
#8
what about the noise when i check the power supply pins (vcc and gnd)
when the uC is inside the socket? is that supposed to happen? when i remove the uC the noise is gone. :-|
Fri Feb 08 2008, 08:13 am
#9
Have you bypassed the supply properly(and close to the controller's Vcc pin)?
And does the waveform at pin3.2 look ok in the scope?
Fri Feb 08 2008, 10:50 am
#10
actually, all waveforms are quite clean as long as the uC is out of its socket..when i put the uC into the board, theres noise at every pin(even port pins) the board is hand soldered by me.. does anyone have experience with making their own boards? i have a feeling theres more to the dev-board than just the minimum circuitry of crystal and capacitors+ power on reset cktry.. :-s

i'm using an atmel AT89c52 btw.(not that it matters..)


[ Edited Fri Feb 08 2008, 10:52 am ]

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am