View Single Post
  #23   Spotlight this post!  
Unread 30-03-2004, 00:07
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Something's wrong

Quote:
Originally Posted by SuperDanman
Okay, thanks for your help so far - I've gotten it to work more or less. Some things, however, are still bugging me.

To drive my LED's, I'm using a BS107P FET. The LED lights up and 'dims' as according to the potentiometer position, but its bugging me that I can still detect the flicker. I don't think I should be detecting any flicker - I set timer2 up with a 1:1 prescaler, so each tick is 100ns (10Mhz). The period register is set at 0x40 (64), so one period of my PWM signal should be 64 * 100ns, or .0064 seconds. This means the period repeats itself 156.25 times in a second... if you think of the period as one "frame", that would be 156.25 frames per second - about 5 times faster than television's 30fps. If television seems smooth at 30fps, how come 156 flashes per second results in a flicker?

If my reasoning is wrong and 156Hz does in fact produce a noticible flicker, is there anyway I can do to reduce this flicker? For example, would adding a capacitor to smoothen the square wave work?
Actually, 64 * 100ns = 0.0000064 seconds or 156.25KHz. I'd be more inclined to say that you're seeing (literally) A/D noise. Set the duty cycle to a constant and see if the effect goes away.

Edit: Another thing to look at is your FET. The gate of a FET is generally highly capacitive. The PIC18F8520 may have trouble driving the gate at these frequencies given that there is a 330 ohm resistor between the two. Try lowering the frequency to a few hundred hertz and see what happens.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org

Last edited by Kevin Watson : 30-03-2004 at 00:12. Reason: Added stuff.