Go Down

Topic: tiny85 self power-off (Read 1 time) previous topic - next topic

larryd

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

JoshNZ

Aww jeez I just lost my entire reply  :'(  :'(  Hopefully i don't miss anything, thanks for replies let me go through them.

Paul if you can see that working then there's nothing wrong with it but I couldn't get my head around it. The LDO has to be powered off as its quiescent current is high, so the uC has to be powered directly from the battery. This means the PWM signal going to the servos has to be 8.4V (at full charge) which is outside their parameters. Even if they are powered from the reg. I could switch them through the 5V rail but that is two more transistors anyway.
Yeah Li-ions sorry, force of habit from other hobbies. I'm powering the servos from the 5V reg, how else would I do it? The stall currents combined are within parameters.

Sherman I think you are right, and it does power up when connecting PB0 as you say, I'm not sure what I was observing the first time maybe I didn't have that wire in yet. I will give your circuit a try.

Ed i had a friend here who suggested the same thing and i tried it, the circuit still powered up upon connecting PB0 to the gate.

Larry I'll come back to that diagram I hope i can get away with something involving less components than that. CB will be starting to get packed!

JoshNZ

#17
Aug 15, 2020, 07:43 am Last Edit: Aug 15, 2020, 07:44 am by JoshNZ
Happy to update that the circuit is working now, using an N-channel fet in the uC circuit which switches a P-channel fet in the circuit above the regulator.

I have a delay at the beginning of my setup function as functions below it seemed to be skipped entirely, or behaved irregularly, I assumed while the voltage supply was settling down and becoming stable. Is it common practice to do this? Even so, I am noticing a significantly longer delay when switching on with the switch now. I wouldn't have thought the time for the FETs to respond would be observable by me. But I will play with that delay at the beginning anyway.


TomGeorge

#18
Aug 15, 2020, 08:18 am Last Edit: Aug 15, 2020, 08:31 am by TomGeorge
Hi,
What MOSFETs are you using?
Do they have Drain-Source diodes fitted?
Are they logic level MOSFETS?
What LDO are you using and have you checked its datatsheet to see if it needs bypass caps?

Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

TomGeorge

#19
Aug 15, 2020, 08:41 am Last Edit: Aug 15, 2020, 08:42 am by TomGeorge
Hi,
Sorry but I had to redraw that diagram.


Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

edmcguirk

#20
Aug 15, 2020, 03:19 pm Last Edit: Aug 15, 2020, 03:58 pm by edmcguirk
edit - whoops, I didn't see the whole second page of responses after this quoted question. I am starting to read them now...

Second edit - Ok I have to admit that I don't know how or if an LDO works when its ground is disconnected. That could invalidate anything I suggest below. Perhaps somebody could enlighten me on that topic. Certainly thanks to TomGeorge for redrawing the circuit so it makes sense.

==========================================

I'm not sure I understand what you're suggesting.  Perhaps you could post a schematic showing your fix.

Drawing a circuit is inconvenient at the moment but simply deleting the wire connecting the microcontroller ground to the LDO ground and adding a wire connecting the microcontroller ground to the battery negative should correct the turn off problem.

That way the mosfet gate will see only 5V when PB0 is high and ground when PB0 is low if the DPST switch is off.

However, when the DPST switch is on, PB0 will be connected to 8v in the OP drawing. That also needs to be corrected, possibly with an added diode in front of the 220 resistor.

Original drawing for reference:

ShermanP

Hi,
Sorry but I had to redraw that diagram.


Tom... :)
Thanks for doing that.  I'm assuming he has caps on the LDO, though not shown.  Also, it may not matter in this case, but technically R3 should be moved to the other side of the R2 junction to avoid having a divider when PB0 goes high.



Paul__B

I must have lost an edit here!  :smiley-eek:

R3 is unnecessary as you are not attempting to PWM the power source.  :smiley-roll:

JoshNZ

I thought R3 was necessary to limit the inrush current if the Fet?

I do have caps on the LDO as per data sheet yes.

The N channel is an IRL540N, the P is a SUP53P06-20. Both just what I had on hand. This was supposed to be a one day project hah.

Didn't look into the diodes Tom, what issue might it cause if they don't? Thanks for redrawing.

I'll check where R3 is, it may be right and may have just incorrectly drawn it. My perfboard is a bit of a bird's nest

TomGeorge

#24
Aug 16, 2020, 03:40 am Last Edit: Aug 16, 2020, 03:41 am by TomGeorge
Hi,
Update;


Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

larryd

No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

6v6gt

Also see this thread which is for a similar requirement:
https://forum.arduino.cc/index.php?topic=699181.15

Your latching circuit design needs the button to be held in by the user for long enough for the Arduino to start and set pin 0 high. Pin 0 should be brought high as early as possible in the sketch, otherwise it's performance will be erratic.

Smajdalf

I didn't notice anyone mentioning this: you CANNOT power the ATTiny from the unregulated batteries! It will die!

I think your problem is already solved. Do you understand what was wrong in the original idea or do you need more help?

JoshNZ

Smajdalf I definitely missed that but you're right as per the datasheet, 5.5v max. Lucky i didn't try. Not that I'm short on those uCs in my container.

I have a working circuit now yes, thanks. I don't explicitly understand the voltage values that caused the first circuit to fail but I understand the principal yes.

I wonder if I can ask you guys another question here in the wrong forum (sorry!) but pertaining to this project - I just ran into a millis() overflow problem, I assume the tiny only being 16-bit rolls over after 65 seconds or so. Anyway I read the workaround of using unsigned longs but... I cannot find anywhere online why it works. Or more specifically, why the below code would print 2? :smiley-confuse: Where would one learn that unsigned long -4,294,967,294 = 2?

Code: [Select]
void setup() {
    Serial.begin(115200);
 
    unsigned long a = 1;
    unsigned long b = 4294967295; //unsigned long maximum value
 
    Serial.println(a-b);     
}
 
void loop() {
}

6v6gt

Try it in the widows 10 calculator set in programmer mode and hex mode:

1 - FFFFFFFF

The answer is:

FFFF FFFF 0000 0002

and mask out the upper 32 bits (that is, the FFFFFFFF) of the 64 bit value

Unsigned Long (uint32_t) is 32bit even on an ATtiny85

Go Up