TLDR; ATtiny85 "not working" as expected when powered from 4.7-5VDC but works fine
at 5.3VDC or below 4.7VDC.
I am testing a very simple sketch that just blinks a couple of LEDs using a loop in software
and is driving the LEDs using a couple of N-channel FETs.
Both gates are pulled low using a 1Megohm resistor.
And driven high by the ATtiny85.
LEDs are resistor current limited to about 1-amp @5VDC.
I am using Pin-5 (Port0) and Pin-6 (Port1) to drive the FET/LED combos.
While trying to run this right at 5VDC I am not getting any output on Port1 and am getting some 'abnormal' output on Port0.
Also Port0 when powered from 4.7-5V appears to be 'pulled high'
Not sure if the FET is somehow causing this and the gate is going positive.
I will have to get a scope on here just to be sure nothing is oscillating.
What's odd is that I'm getting absolutely no activity on port 1 (Pin6) like the program is never
making it to that part and maybe the chip is resetting.
The reset pin(1) looks like clean 5V no noise or pulses.
I do indeed have a .1 µF capacitor soldered from Pins 4-8.
And have a 470 µF cap on the 5V rail to (-).
Power looks clean.
I've not put a scope on things yet but am about to.
If I simply turn the voltage up to 5.3V everything is working perfectly and see no problems.
Same if I turn it down to 4.6V
Very annoying..
It just means it won't work on a PC USB port power or a small battery bank for the moment until I figure this out.
I'll update this as I figure out what the heck is going on.
Am wondering if I missed anything obvious I should be doing.
I also tried putting a 100K resistor from gate to (-) instead of just the 1-MegOhm.
Made no difference.
1. Is it a fresh ATtiny85? What is the type number - given on the top of the chip? 2. What are the values of the Fuse Bytes and Lock Byte? 3. Are you running it using internal oscillator or external? 4. Is it standalone or belongs to a breakout board like Digispark? 5. How are you preapring the sketch -- Arduino IDE or Microchip Studio Assembler? 6. How do you upload sketch into the MCU -- using Arduino as ISP or Programmer?
Standalone (but programming the chip on a different board I made myself as a shield)
I can use this board to program from an UNO (UNO as ISP) or from a common 10-pin connector
using an external programming ISP board.
Arduino IDE
I can upload either way. Arduino as ISP or using a USBTinyISP board that I have.
Code works and runs as expected on my programming/test board (Running at 5V) and sticking a logic probe
on the output pins.
It's doing the weird stuff on my standalone test board that has the FET drivers and higher power LEDs.
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(0, HIGH); // turn the LED on (HIGH is the voltage level)
delay(20); // wait for a second
digitalWrite(0, LOW); // turn the LED off by making the voltage LOW
delay(80);
digitalWrite(0, HIGH);
delay(20);
digitalWrite(0, LOW);
delay(80);
digitalWrite(0, HIGH);
delay(20);
digitalWrite(0, LOW);
delay(80);
digitalWrite(0, HIGH);
delay(20);
digitalWrite(0, LOW);
digitalWrite(1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10); // wait for a second
digitalWrite(1, LOW); // turn the LED off by making the voltage LOW
delay(80);
digitalWrite(1, HIGH);
delay(20);
digitalWrite(1, LOW);
delay(80);
digitalWrite(1, HIGH);
delay(20);
digitalWrite(1, LOW);
delay(80);
digitalWrite(1, HIGH);
delay(20);
digitalWrite(1, LOW);
delay(750); // wait for a second
}`Use code tags to format code for the forum`
"Fairly fresh" means that I have played around with the fuses a bit and then set them back to how they came.
Should be Internal clock and /8
Instructions running at 1MHz.
Do you have a schematic? Do you power the 1A leds from the same source that you use for your At85? Could that power led draw mor than your power source can provide, causing a power dip, that resets the MCU?
A 1000 UF cap may help
When I created some strobelights for an RC airplane I had to add an RC filter (20 ohm resistor with a 470UF cap behind it) to stop the powerleds from crashing the Attiny13
Yes,
I'm providing enough power (current capability) (5 AMP supply).
And 1000 microfarads on the supply line now.
I'm also going to write a logic high and then clear it on the 3rd pin a single time upon bootup.
This will tell me if it is resetting or not.
The whole arrangement is working perfectly at 5.3V or higher and at 4.7V or lower.
But not right where I want it to work at 5V..
Life: LOL
Understood, however I am not very well versed or efficient/fast in drawing schematics up or using software to do this.
I also may have it figured out soon and not have to figure out how to make a schematic.
If I can figure it out and fix it I will try that first before side-tracking to figure out how to make a presentable schematic.
Meanwhile I have included a 3-second pin toggle at startup on a 3rd pin.
From this I was able to tell that yes, the chip is resetting.
So now I need to determine exactly why.
Logic probe shows no obvious dip or drop in supply, reset line does not change.
But it is somehow getting triggered to reset.
I'll try a much bigger cap on the 5V supply line just to see if that helps.
OK for the moment I ended up putting a 10K resistor between Port0 (Pin5) and the FET gate connection (which already has 1Megohm to ground) (-).
This stopped my ATTiny85 from resetting every time this particular FET was being switched on.
Now it's working flawlessly across the expected supply voltage range.
And it works fine on a PC USB port for power or a small battery bank/cellphone charger.
Certainly some progress.
I am using completely "random" FETs pulled from computer motherboards or power supplies.
I'd have to pull the datasheets to get more specific.
But FET/LED combo #2 is not having this problem.
This is just for fun and learning.
This is not any production unit or hardware that needs to be duplicated.
I am just getting more familiar with the software and using this to do it and have some fun as well.
LEDs that pull a little over an amp of current each are a lot of fun.
And these are RGB.
High Fuse Byte (HF = 0xD7 = 1101 0111) indicates that BOD (Brown-out Detection) is disabled. I don't see any reason for the MCU to enter into RESET state due to transient power dip. Your ATtiny should work well for Vcc = 2.7V - 5.5V provided that each output pin does not source (sink) 10 mA at Vcc = 5V. At Vcc = 3V, the source current of an output pin is 5 mA.
I would suggest to perform an experiment this way: 1. Connect a variable DC supply at Vcc-pin of ATtiny85 and set it at 5V. Please, connect 0.1uF (100 nF) capacitor between Vcc-pin and GND-pin as close as possible.
2. Connect a LED with PB0-pin with a 200-300 ohm resistor in series.
3. Upload sketch to blink LED at 1-sec interval with equal ON/OFF times.
4. Slowly vary the Vcc supply from 3V to 5.5V and observe the behavior of the MCU in respect of smooth blinking of LED.
i think without the resistor the gate of the FET sucks so much current from the Attiny, that it crashes. The 10K is a bit overkill, I would suggest 470 Ohm. That is enough to protect the Attiny, but with 10K it takes a long time for the FET gate to charge and if a FET gate is not fully charged (saturated) the FET will have higher internal resistance and therefore produce more heat.
The video I have from the strobelight is posted above.
But, FET/MOSFET is a voltage sensitive device and NOT current. Does it matter if we put a series resistor or NOT at the gate of FET? The FET will turn ON as long the applied voltage is greater than the thresold voltage which is usually from 0.5V to 4.0V.
Good, so you got it working but not knowing why. As @hmeijdam already pointed out, providing a circuit diagram would help (you). It doesn't need to be fancy, draw one by hand or use some online site.
Correct, it is a voltage sensitive device, but the gate is also a capacitor. In the datasheet you can find the gate capacitance mentioned. And a capacitor needs a certain amount of current to charge or discharge. The higher the series resistor the longer it takes to charge/discharge.
It could also mean that w/o a resistor, the FET turns on as fast as it can, creating a voltage drop in the circuit. But it's pure speculation, we need a diagram. This whole does not work in a narrow voltage range doesn't make much sense at all, and I do not criticize @n8lbv here, get me wrong.
I will draw up a schematic when I get a chance but wanted to play first.
Putting ground or direct 5V on the FET gate did not cause my attiny to reset like it does when getting
pulsed from the ATTiny pin.
It is weird.
I also appear to be getting "full on" with the 10K resistor and if it's slower it's not noticeable in the strobe effect.
It's working perfectly with that resistor inline.
Fun!
2. Take a picture of the diagram by your mobile camera. 3. If ncessary crop the picture and share it with your friend by Messenger Box. 4. From your PC, Open the Messenger Box where you shared the picture. 5. Copy the image (picture) and paste here in the compose wndow of the post.