I'm starting to lose my mind with this one. The more I try to break down the problem the more confused I get. Long story short:
My Digispark ATtiny85 (clone) does not boot if powered externally under certain (and almost random) circumstances. Sometimes it does boot and run correctly but after some seconds of operation it freezes and I have to plug it off and on again.
I have tested it both with a 9V battery and a 12 V PSU. I also tested different Digispark boards (all from the same batch and supplier, though).
Trying to track the problem down I hooked up an electrolytic capacitor across Vin and GND and, to my surprise, even though the waveform does look way smoother and cleaner this way, IT DOES NOT BOOT!. How is this possible? It was a 47 uF / 50V cap, but I tried other values too with the same result. I can't figure out why this is happening.
The funny part is that if I remove the cap, let the Digispark boot, and connect it to the circuit afterwards, then I can operate it and it does not freeze anymore. So the cap helps the operation but it does not let the board boot (???).
-The oscilloscope is attached to the output pin of the 7805 onboard regulator.
-The capacitor (when connected) is connected across the Vin and GND of the board.
DrDiettrich:
Do not power a display from the on-board regulator! Use a separate PSU for the display, or power everything from a 5V PSU.
Hi. First of all, thank you for your reply! Could you elaborate on that? This would be the first time that I have issues connecting a display to the onboard regulator... I'm measuring a power consumption of around 40 mA which should be not much for a 7805 to handle (as far as I know).
It doesn't even get hot. Is there anything more that I'm not taking into consideration?
You are right, 40mA is not much. But the ripple indicates a power problem. I'd put a capacitor near the display.
The boot problems may result from a too small RESET capacitor, that releases the RESET signal before the operating voltage has stabilized. Does it work after you press the Reset button?
DrDiettrich:
You are right, 40mA is not much. But the ripple indicates a power problem. I'd put a capacitor near the display.
The boot problems may result from a too small RESET capacitor, that releases the RESET signal before the operating voltage has stabilized. Does it work after you press the Reset button?
After long hours of testing I think I'm starting to see what's happening (or part of it).
There's an active buzzer connected directly to P3. This buzzer SHOULD NOT BE ON until the program sets P3 HIGH. But just after powering the board and BEFORE even the program starts, it stays 5 seconds (the time to allow uploading a new program) in which P3 is set to an "undefined" state (around 3V). This does not make the buzzer beep audably but it seems to be causing spikes and adding noise to the circuit. It's constantly switching in an "almost active" state. Those spikes and noise, for whatever reason, make the microcontroller crash or at least it stays on that state forever and never finishes booting.
-How could I make P3 stay ALWAYS LOW from the beggining until it's really supposed to be HIGH?
-Is it mandatory to use a resistor when connecting a 5V active buzzer to a digital pin?
-Even the ripple caused by the display doesn't seem to be the main responsible of not letting the board boot, why is it causing it? I can definitely see my Vin oscillate when it's plugged in...
Thank you so much for your help in advance, this one is being really hard for me to figure out.
Powering the 7805 from a 1k:2k voltage divider.
No input cap one the 7805.
No (fixed) output cap on the 7805.
Display powered from the aTtiny85 pin.
LDR powered from the same pin.
Switch/divider powered from the same pin.
No decoupling on the chip.
No (delayed) reset circuit.
All of the above needs to be corrected, especially item #1.
Leo..
DrDiettrich:
Pull up or down resistors are required for output pin states defined from power up.
Thank you. I tried adding a pull down resistor with no luck... If I am not wrong this should be required, for example, if I had a high impedance load on that pin (the gate of a mosfet, for example). But I have a buzzer which requires around 10-15 mA so as far as I know it should be serving as a "pull down" already and the pin should not be floating when configured as high impedance for that short amount of time. Am I wrong?
What I am seeing now is that P3 on Digispark ATtiny85 has some components already connected which may be causing trouble...
What do you think? Do you know any other way to sort this out that doesn't imply adding a component? (I have already produced the PCB...). Thank you again.
Wawa:
Powering the 7805 from a 1k:2k voltage divider.
No input cap one the 7805.
No (fixed) output cap on the 7805.
Display powered from the aTtiny85 pin.
LDR powered from the same pin.
Switch/divider powered from the same pin.
No decoupling on the chip.
No (delayed) reset circuit.
All of the above needs to be corrected, especially item #1.
Leo..
Hi Wava. I don't understand what do you mean by "powering the 7805 from a 1:2k voltage divider". If I am not wrong I am not powering it from a divider! It is the internal 7805 from the Digispark board which is wired directly from the Vin pin. Then it powers the board (ATtiny85) and all the components that you decide to connect to the 5V pin.
The 1:2k voltage divider is just connected to an output pin (P4) as a program signal to be used for another purpose. Am I missing something? Thanks in advance.
Pin 3 and 4 are used for the USB interface. If you are using USB you should not use those pins. I guess the buzzer signal causes the bootloader to crash. Do you use bootloader? If not remove it and you should be OK.
Also note you should not write the PB3 and PB4 high due to the Zener diodes. At least not for long.
Smajdalf:
Pin 3 and 4 are used for the USB interface. If you are using USB you should not use those pins. I guess the buzzer signal causes the bootloader to crash. Do you use bootloader? If not remove it and you should be OK.
Also note you should not write the PB3 and PB4 high due to the Zener diodes. At least not for long.
I am not not using the USB. In fact, once the program is uploaded, I just power up the board with 12V to Vin and that's all. Yes, I also think that the bootloader crashes due to the buzzer. What do you mean by if I use the bootloader? I just need to upload the code and that's all. The board has the bootloader that came with it (clone board).
I definitely need to write the PB3 and PB4 high at some point in my program. But I assume that there are current limiting resistors that will protect the Zeners, right? (R1 & R2). I hope it is possible to use those pins!
Is there a way to disable the bootloader that doesn't imply needing an extra arduino or programmer? Thank you!
Smajdalf:
Pin 3 and 4 are used for the USB interface. If you are using USB you should not use those pins. I guess the buzzer signal causes the bootloader to crash. Do you use bootloader? If not remove it and you should be OK.
Also note you should not write the PB3 and PB4 high due to the Zener diodes. At least not for long.
Also what's the difference between uploading the program choosing "Digispark - Default 16.5MHz" and "Digispark - 16MHz NO USB" on the Arduino IDE? I tried both but seem to behave the same...
I don't know if there is an easy way for the bootloader to disable itself. But I think it is a good thing to have an ISP programmer. If you decide to program the ATTiny85 using the ISP you can also remove the Zener diodes, removing quite large unnecessary load of the output pin, power regulator and battery.
Smajdalf:
I don't know if there is an easy way for the bootloader to disable itself. But I think it is a good thing to have an ISP programmer. If you decide to program the ATTiny85 using the ISP you can also remove the Zener diodes, removing quite large unnecessary load of the output pin, power regulator and battery.
Again, thank you for your reply! Finally I have found the solution to my problem. Like you said, the bootloader was "the answer" or an easy fix.
In case it helps anyone in the future:
SOLUTION: I downloaded the "DigiDucky" firmware (micronucleus-1.11-entry-jumper-pb0-upgrade) which skips that 5 second delay time. I found it here: https://sites.google.com/site/csapractical/DigiDucky.zip That way the pin does not stay floating during 5 seconds messing with the buzzer and the buzzer does not mess with the boot process or cause any spikes. Now I just need to hook up P0 and GND to upload a program but that's not a problem at all.