Hello everyone, I hope your doing well. I trying to control the brightness of a high power led with a IRF830 MOSFET and an attiny 85. To control the brightness/ pwm, I'm using a 1 mega ohm potentiometer on pin 3 on the attiny 85, using it's 10 bit ADC. I used a map command to map the 10 bit value to an 8 bit value, which is hooked up to the MOSFET to control the brightness of the high power led. Now I don't know if 8 bits is fast enough for the human eye not to see it flicker, but I can see the test led flicker at any position on the potentiometer if it is not at o or 1023. So what do I do? I checked the oscilloscope, and I see an AC sine wave!!!! Oscillating at 60Hz? I check the power supply (linear) and there was some ripple, but I fixed that with a 10uF capacitor. It had a very small impact on that weird flicker on the test led. Can anyone help? Here the simple code wrote:
int val;
void setup()
{
pinMode(6,1);
}
void loop()
{
val = analogRead(A2);
val = map(val, 0, 1023, 0, 255);
analogWrite(6, val);
}
Hi Portal. Suggest you put the attiny aside for a moment and connect all the other components up to another arduino like an uno. Do you get the same problem? If so, you can now use serial to send the adc values back to the pc. Any sign of a similar variation in those numbers?
One thing that came into my mind straight away was to try replacing the 1M pot with a 10K pot or less. The signal to noise ratio might be poor with that high value pot letting so little current into the adc input. They are high impedance but do need a small current to work with.
Well a quick look at a IRF830 mosfet datasheet shows that it is NOT a logic level mosfet so all it's specs are based on a gate/source signal level of +10vdc, not the +5vdc outputs that your 85 works with.
retrolefty:
Well a quick look at a IRF830 mosfet datasheet shows that it is NOT a logic level mosfet so all it's specs are based on a gate/source signal level of +10vdc, not the +5vdc outputs that your 85 works with.
Hi Lefty, I looked at the data sheet too and saw this:
Gate-Source Threshold Voltage VGS(th) 2.0 - 4.0 V
So I thought that meant that the fet would begin to switch on at 4V, and probably lower, so 5V should switch it on reasonably well.
Why was that wrong, and what part of the data sheet should I have looked at? I saw the part that said that the Rds(on) would be 1.5Ohms at 10V. I can't see a chart that describes how Rds varies with Vgs.
Threshold Voltage VGS(th) is the gate voltage where source/drain just starts to conduct, perhaps just millamps. Logic level mosfets typically have threshold values of 1-2vdc. Look at all the maximum current ratings and minimum Ron values, there are specified with a 10vdc gate voltage applied. You need a true logic level mosfet or additional external components to raise the gate voltage.
I don't have a 10k potentiometer, but you know I should get one. Also I noticed that testing with a 100k potentiometer, the led was dim and there was less flicker. As far as the IRF830 goes, I don't know, It controls both test and high power leds fine, so I will stick to that unless it does not work. I think the potentiometer is definitely the problem with the current issues. So I will try it with a 100k pot as see the results, I used all my 10k's up with other projects. Thank you so much for helping me.
Cheers! Dylon J.
You've probably checked this already, but so so often if I'm scoping something and see 60hz, it's due to having a shoddy ground connection. Are you sure that all your grounds are tied together and that your scope probe is properly grounded?