Arduino Forum

Using Arduino => General Electronics => Topic started by: JoshNZ on Aug 13, 2020, 11:37 am

Title: tiny85 self power-off
Post by: JoshNZ on Aug 13, 2020, 11:37 am
Hello all,

I'm working on a useless box project here, it is powered by 2xlipos and a 5v LDO, and an attiny85 MC.

The switch i'm using is a double pole so i had this idea that, in resting state everything would be powered off. When throwing the switch one of the poles would connect the lipo to a mosfets gate (IRL540N) which would then switch on the LDOreg, and everything would fire up, which works good.
Obviously the box then switches the switch off, and in the mean time I have had the MC take over driving the mosfet gate via an output pin and 220ohm resistor (i figured this can be high ohms, because it's not driving the gate open, just taking over holding it open).

My idea was then to timeout the program after the switch being off for x time and write the mosfet gate pin low, which has a pull-down resistor on it. Then it would all power off until the next time the switch was thrown.

The last bit is where I'm having a problem. I've written the pin low but I can still hear the servos humming and holding their position so they obviously have power. If I pluck the wire off the mosfet control pin, then all goes silent and the servos relax.

I fear I am probably embarrassing myself by asking but, what am i missing hah...

Thanks in advance of course.
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 13, 2020, 12:29 pm
I think i've found my answer which has been answered before, sorry about that.

Just so it's not a wasted post, my understanding is enough current is leaking from the control pin to keep the mosfet energized?

I'll have a go at adding in a second P-mosfet
Title: Re: tiny85 self power-off
Post by: DrAzzy on Aug 13, 2020, 04:15 pm
Please draw a schematic (hand drawn and photographed with your phone is fine, and better than fritzing and that kind of crap)....

But first thought is, if you're using an LDO and running something on batteries, you've already lost the war.

My thought is - keep the uC powered full time by the batteries, but in power-down sleep mode until it receives user interaction. then it turns on the fet to do it's thing with the motors, cloe box, and go back to sleep....
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 13, 2020, 10:50 pm
I had thought of that but something made me stray away from it. I think that would mean powering the servos by regulated 5v but the pwm signal would be as much as 8.4v. it's outside their parameters anyway.

The LDO is below the fet like you say, the 10ma quiescent wasn't going to work, shame it's not 10ua. I'll draw a circuit later today.
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 14, 2020, 12:42 am
Here's the circuit I don't know that it was going to be any clearer with a scribble on paper sorry!

If the battery were connected to that circuit it should remain powered off as the FETs gate is held low by the 10k pull-down resistor. But it doesn't. Regardless of what I set PB0 to, output/input and written HIGH or LOW, it drives the gate as soon as the lipo pack is live.

If I disconnect PB0, then the circuit operates as it should, the upper pole of the switch drives the gate and as the arm opens the switch, it all powers down.

PB0 being written LOW, is still leaking enough current that the gate remains driven...? Which doesn't make a whole lot of sense to me on second thought actually, why can you ever drive a gate with a uC in that case.

Anyway, I've read about switching the power supply with a P-channel FET instead, and driving its gate with the N-channel FET. i.e. hold the P-channel gate low while operating, then let the P-channel go high with a pullup when powering off.

Edit: I drew MOSFET on high side accidentally, it is on low side as reflected in updated circuit below

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377390)
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 14, 2020, 12:56 am
It is a gift for my 10 month old niece who is coming out of surgery today, my brother says she likes switches. But yes, still, I wish I never started it  :smiley-lol:

It is surprisingly difficult to tune the timing of its responses right, to give it 'personality' rather than look like a weird automated machine.

In any case, it'd be great to just have 1 switch and leave it on the shelf indefinitely without a current drain.

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377374)
Title: Re: tiny85 self power-off
Post by: pmagowan on Aug 14, 2020, 08:51 am
You could use a small relay.  It would use more current while it was on but could switch completely off without the sensitivities of the transistor.
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 14, 2020, 11:50 am
I've considered that too and I've got one in the box but I'm not quite there yet. Even if I did it'd bug me not knowing why this doesn't work =/.
Title: Questions, questions.
Post by: Paul__B on Aug 14, 2020, 02:00 pm
OK, that circuit never works, by definition.  :smiley-roll:

So, what is wrong with the sleep mode of the ATtiny85, and why are you using two LiPos?  I see 18650 rechargeables.

I hope you do not propose to use the regulator to drive the servo motor!  :smiley-eek:

Or are you going to power a servo motor with 8.4 V?  :smiley-eek:  :smiley-eek:
Title: Re: tiny85 self power-off
Post by: Bjerknez on Aug 14, 2020, 02:28 pm
Is it just me, or is the ground wired wrong in the schematic?
Title: Re: tiny85 self power-off
Post by: Bjerknez on Aug 14, 2020, 02:29 pm
Ahh... forget it. Sorry :)
Title: Re: tiny85 self power-off
Post by: ShermanP on Aug 14, 2020, 05:10 pm
I think what may be happening is that when you turn off the switch, then bring PB0 low, you are disconnecting the circuit ground from the battery ground, and the entire circuit potential then rises to the potential of the battery positive, which IS  connected - about 8V.  No current flows, but if you measure the voltage at the regulator's OUT pin, and at PB0, and even the processor's ground pin, all with respect to battery ground, I think you will find a positive voltage.  But this may not be correct because it would power up automatically when you first connect the battery, even with the switch off.  So I don't know.

I'm so used to seeing high side switching that I'm having trouble figuring out how to make this work.  But I strongly supect you're going to need a transistor in the PB0 line.  I think perhaps a PNP, with the emitter connected to PB1 and the base connected to PB0 through a resistor, then the collector connected to the 220R resistor to the mosfet gate.  To maintain power, you would bring PB1 high, and PB0 low.  That turns on the transistor, which brings the gate high.

But when you make PB0 and PB1 high impedance (inputs), there's no voltage differential between the emitter and the base, and no current flow, so the PNP transistor turns off.

I don't know if that's clear.  If I get some time later today I'll draw it up.
 
Title: Re: tiny85 self power-off
Post by: ShermanP on Aug 14, 2020, 06:49 pm
Here's a drawing of what I tried to suggest above.  But on reflection, I think the emitter can just be tied to the 5V supply instead of PB1.  Also, I've replaced the 220R resistor with a diode.  You don't really need the resistor, but when the switch is closed, you have 8V coming back into the PNP, and I frankly don't remember what happens when the collector is at a higher voltage than the emitter.  It's possible no current would flow anyway at these voltages, and you won't need the diode.

So the PNP conducts only when the EB voltage exceeds 0.6V and current flows through that junction.  If the processor brings PB0 low, that condition is satisfied, and 5V will flow to the mosfet and maintain power when the switch is off.  But when PB0 goes back high, or becomes high impedance, no current will flow through the base, the PNP turns off, and the pulldown resistor on the gate turns the mosfet off.  The voltages at the processor may rise towards the 8V battery voltage, but there still will be no differential between the 5V pin and PB0 that would lead to turning on the PNP.

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377483)
Title: Re: tiny85 self power-off
Post by: edmcguirk on Aug 14, 2020, 07:53 pm
Maybe I'm just confused but I think the MC is connected to mosfet switched power and toggle switched ground. When the toggle switch opens, the MC floats to battery and the mosfet gate floats to battery.

If the MC ground is removed from the mosfet switched ground and connected directly to the battery ground, I think it should work as expected. Right?

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377390)

edit - yes I am confused. The both the MC power and MC ground are switched by the mosfet. However the results and the fix should still be the same.
Title: Re: tiny85 self power-off
Post by: ShermanP on Aug 14, 2020, 10:48 pm
edit - yes I am confused. The both the MC power and MC ground are switched by the mosfet. However the results and the fix should still be the same.
I'm not sure I understand what you're suggesting.  Perhaps you could post a schematic showing your fix.
Title: Re: tiny85 self power-off
Post by: larryd on Aug 14, 2020, 10:59 pm
Some ideas, FYI

 http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-off   (http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-off)

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377552)






Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 14, 2020, 11:41 pm
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!
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 15, 2020, 07:43 am
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.

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377602)
Title: Re: tiny85 self power-off
Post by: TomGeorge on Aug 15, 2020, 08:18 am
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.. :)
Title: Re: tiny85 self power-off
Post by: TomGeorge on Aug 15, 2020, 08:41 am
Hi,
Sorry but I had to redraw that diagram.
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377602)
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377608)
Tom... :)
Title: Re: tiny85 self power-off
Post by: edmcguirk on Aug 15, 2020, 03:19 pm
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:
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377390)
Title: Re: tiny85 self power-off
Post by: ShermanP on Aug 15, 2020, 04:47 pm
Hi,
Sorry but I had to redraw that diagram.
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377602)
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377608)
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.


Title: Re: tiny85 self power-off
Post by: Paul__B on Aug 16, 2020, 12:30 am
I must have lost an edit here!  :smiley-eek:

R3 is unnecessary as you are not attempting to PWM the power source.  :smiley-roll:
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 16, 2020, 02:26 am
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
Title: Re: tiny85 self power-off
Post by: TomGeorge on Aug 16, 2020, 03:40 am
Hi,
Update;
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=377690)

Tom... :)
Title: Re: tiny85 self power-off
Post by: larryd on Aug 16, 2020, 05:56 am
I've been using this dual MOSFET for this circuit.

AO4614B

 http://www.aosmd.com/pdfs/datasheet/AO4614B.pdf       (http://www.aosmd.com/pdfs/datasheet/AO4614B.pdf)

(https://http2.mlstatic.com/ao4614b-2-piezas-4614b-ao4614-D_NQ_NP_945308-MLM29153603852_012019-F.jpg)






Title: Re: tiny85 self power-off
Post by: 6v6gt on Aug 16, 2020, 06:38 am
Also see this thread which is for a similar requirement:
https://forum.arduino.cc/index.php?topic=699181.15 (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.
Title: Re: tiny85 self power-off
Post by: Smajdalf on Aug 16, 2020, 09:31 am
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?
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 17, 2020, 08:22 am
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() {
}
Title: Re: tiny85 self power-off
Post by: 6v6gt on Aug 17, 2020, 09:15 am
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
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 17, 2020, 10:02 am
I know it's 2 I just don't know why or what the logic to that is. What arithmetic is happening to arrive there?

And yes but the 16 bit timer will mean millis is back to zero after 65535ms? Otherwise I have a problem that's disappeared for a reason I'm unaware of
Title: Re: tiny85 self power-off
Post by: 6v6gt on Aug 17, 2020, 10:40 am
The millis() function on an ATtiny85 actually uses an 8 bit timer, timer 0.
But that is irrelevant. An interrupt from the timer maintains a 32 bit counter with a rollover of approximately 50 days.

Maybe explain how you determined there was a rollover in your case.

As for the arithmetic.

Instead of 1 - 0xFFFFFFFF, imagine 1 - 0xFF  

0 - 0xFF is 1 because if you add 1 to 0xFF you get a rollover to 0  (assuming you are working with unsigned 8 bit values).
So 1 - 0xFF is 2 , 2 - 0xFF is 3  etc.

Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 17, 2020, 11:44 am
I had set a while loop to run while millis() - prevmillis < period and I thought I saw it skip some of it but I was playing around with other stuff maybe I just got something wrong.
I changed prevmillis from an int to an unsigned long and whatever else I did, fixed it.

I'm not going to post my code, you guys don't need the stress  :D  :D. I couldn't get softwareservo or servo8bit libraries to work reliably and since the uC has no other functionality I've written PWM output with for loops. Too crude for this forum  :o

Thanks for the explanation! And thanks to all who chimed in. I'll post a pic when I get the finish on
Title: Re: tiny85 self power-off
Post by: 6v6gt on Aug 17, 2020, 12:51 pm
I had set a while loop to run while millis() - prevmillis < period and I thought I saw it skip some of it but I was playing around with other stuff maybe I just got something wrong.
I changed prevmillis from an int to an unsigned long and whatever else I did, fixed it.
. . .
millis() does skip some values because it is based on ticks of 1024uS, not 1mS. Some millisecond values simply get lost. For example, you never see a millisecond value of 42.
See https://www.best-microcontroller-projects.com/arduino-millis.html (https://www.best-microcontroller-projects.com/arduino-millis.html)

However, if you were using an incorrect data type, that is more likely to have been the problem.
Title: Re: tiny85 self power-off
Post by: Paul__B on Aug 17, 2020, 01:07 pm
For example, you never see a millisecond value of 42.
HHGTTG?  :smiley-lol:
Title: Re: tiny85 self power-off
Post by: 6v6gt on Aug 17, 2020, 01:24 pm
HHGTTG?  :smiley-lol:
I never thought of that, but that could well have inspired Douglas Adams.
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 18, 2020, 10:44 am
All finished up this evening, at long last. The wood is swamp kauri, always forget how nice a finish it takes.

I decided to have a go at etching a board rather than using perfboard and am super glad I did, what a neat little process. I'm delighted with the results for a first attempt. Unfortunately after all that discussion about the resistor being in the wrong place, I managed to take it from the right place on my breadboard then draw, and place it in the wrong place on the board =(. It does divide but I only lose .1v or so on the N channel gate by my math.

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378022)

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378024)

And a vid if anyone is interested.
https://youtu.be/xDmV8Vz2OVU (https://youtu.be/xDmV8Vz2OVU)
Thanks again for the responses
Title: Re: tiny85 self power-off
Post by: pmagowan on Aug 18, 2020, 11:05 am
nice, has a good character
Title: Re: tiny85 self power-off
Post by: ShermanP on Aug 18, 2020, 06:38 pm
I think it's wonderful.  Well done.
Title: Re: tiny85 self power-off
Post by: larryd on Aug 18, 2020, 09:39 pm
Well we now need to see a video showing the actual operation ;).



Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 18, 2020, 09:48 pm
Did you miss the YouTube link Larry? Or you mean under the hood. It's exactly what you'd expect there's not much to show, a servo for the lid and one for the arm. The head is stuck on the lid by a piece of tig wire holding it at the right angle hah
Title: Re: tiny85 self power-off
Post by: larryd on Aug 18, 2020, 10:06 pm
Yes, I didn't see the link.

Very funny.  + +

Going to make a few for Xmas presents this year.

Nice finish on the wood and box nice joints !



Will you copy the final sketch here and a final schematic ?






Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 18, 2020, 11:29 pm
I would but, you'd find it funnier than the vid itself.

I'd rather you program it the way you would, then if I make a couple more for presents, I can use your sketch xD.
I would genuinely like to see how someone experienced would do it without libraries. I'm not super confident with timers and even if I was, strategically I don't know which bits would go in interrupt routines and the main loop.

Other than mine being a manual hack there are two reasons Id discourage it, one I discovered with these servos in particular I only need 2 pulses to make a servo track for and hold that position, for as long as it's powered up. So my for loops only iterate 3 times when max speed is allowable. And secondly my PWM wave form isn't strictly correct, the off time is fixed and not balanced with the on time for consistent period (i.e.. 20ms - on time). Both may cause other servos to fail or behave erratically. Lucky for me neither matter in this case.
These servos came out of a model helicopter, my guess is they have a "hold last position" function for if the RX fails.

I'll post the schematic when im at my computer later.
Title: Re: tiny85 self power-off
Post by: larryd on Aug 19, 2020, 02:46 am
Normally when you succeed 'or not' you share your results plus or minus like others have shared with you in the previous 42 posts.

These forums are here to help others who come across this thread with the same questions.





Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 19, 2020, 05:21 am
Sure, if it can be constructive I suppose but heed above advice as it will likely not work for most I guess...

The sketch and board layout reflects the fixed N-channels gate resistor and is not how mine is but, in any case...
Enjoy, with a grain of salt!

Actually one constructive thing I could add, I lightened my switch by swapping out the spring for one with less stiffness. I opened a few pens and found one that compressed easier. Cut to approx length then stretched until slop in switch was taken up. The servo struggled with the factory switch, but much snappier performance after this. I also machined an extension for the toggle knob, for leverage initially but it was probably not necessary. It does add to the look.

My only other thought is the hit switch function requires the switch to toggle for the function to complete (doing so improved response time). If someone unknowingly put their coffee on the box and bumped the switch, the servo would likely burn out and the circuit would run until batteries were flat. I thought I could timeout that function but that would disappoint the tough users who want to wrestle with the switch. You would only save the servo (not the batt), as there would be no way to power off the LDO with the switch held open, the best you could do is relax the servo then sleep the uC, and it'd require manually cycling. So I left as is. I'm sure there's a clever way around it.
Title: Re: tiny85 self power-off
Post by: larryd on Aug 19, 2020, 07:48 am
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378115)

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378117)


Nice job.

This will help others.





Title: Re: tiny85 self power-off
Post by: larryd on Aug 19, 2020, 08:03 am
On the code, add a few more comments to help yourself remember 1 year from now ;).

Also, you might want to look into using State Machine coding in future sketches and how to create timers using the millis() function to remove all the delay() calls.

There are some examples of both in the tutorial forum on this web site.

Continue to have fun with this new hobby.

Did you cut the box joints with a router ?



Title: Re: tiny85 self power-off
Post by: 6v6gt on Aug 19, 2020, 08:33 am
The build quality and finish are very fine.
Also, I haven't made my own PCB for decades. Is that chemically etched ?
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 19, 2020, 08:41 am
Haha good thought but I don't plan on using the sketch again if there ever was a 2.0.

I'll have a read up on state machine coding. I'm aware of utilising millis but i figured since there's nothing to do during delays, simple was better.

The box joints are done on a jig I made for my table saw. Another trick I was delighted to see work so well. Basically a 2 part sled, the front part you clamp your work to which has a pin the width of the saw kerf as a guide, which can slide between 'fingers' on the back piece (which is stuck in the table saw channels). You make the fingers by ripping a length of square stock the width of desired tenons, and cut it into 2xWidth lengths and stand every second one up.

I'll go fish it out if you want, a photo that might be easier hah.
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 19, 2020, 08:48 am
6v - yes chemically etched, I had 30% hydrochloric acid lying around and bought a tiny bottle of hydrogen peroxide from a pharmacy in town for a few bucks. I'm looking for an excuse to try it again now haha.

The mask was printed on toner transfer paper and ironed onto the board. I exported the PCB layout into photoshop and manually added a bigger 'blob' to each device pad. The editing process per device in EagleCAD was arduous.
Title: Re: tiny85 self power-off
Post by: larryd on Aug 19, 2020, 08:51 am
It would be nice to see the jig.

I use a router/table with a jig for making box joints but nothing over 3/8".



I like jigs (Edit: all tools ;) ).

If you have not seen the tips in this thread (700+ posts), you might find some interesting ideas.

https://forum.arduino.cc/index.php?topic=445951.0 (https://forum.arduino.cc/index.php?topic=445951.0)



Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 19, 2020, 10:32 am
This one will do whatever size, if you can be bothered changing the fingers. It looks more complicated than it is but the back piece is just an open backed box with rails, holding a row of square stock alternating laying/standing. Some random size stock is cut at each side to hold them all firm. And the front bit just has a pin that matches the saw kerf. Finely tuned with an angle grinder and drill... So with the work clamped to the front, the saw can only cut an area that the pin can move between.

Pieces tap together tight with a mallet, right off the saw. Obviously only does square joints but it's great for knocking drawer carcasses together. If you were doing a lot you'd run a dado blade.

I too suffer from the tool and jig related sicknesses hah. Cool thread, thanks.

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378140)

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378142)
Title: Re: tiny85 self power-off
Post by: larryd on Aug 19, 2020, 06:42 pm
Thank you.

There are also many ideas on YouTube.



Hey, that's the same table saw I have, great minds . . .





Title: Re: tiny85 self power-off
Post by: larryd on Aug 19, 2020, 07:06 pm
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378205)

The bit is wrong here, should be 1/4" up spiral.
This jig is for 1/4" box joints, also have one for 3/8".
Use a 1/4" brass bar to set the bit distance from the fence and the bit height is set to 4/1000" proud the wood thickness.
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378207)

Some 1/4" box joint boxes.
(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378209)





Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 20, 2020, 02:31 am
Yeah looks good, similar sort of principle. The relationship I've had with my router over the years is complex haha...

You'd like the last jig I built, being a wood worker. Not that it's anything to do with electronics but since we're way off track anyway...

It holds logs while you cut them into timber :smiley-lol: Seriously it's a sickness...

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378251)

(https://forum.arduino.cc/index.php?action=dlattach;topic=700141.0;attach=378253)
Title: Re: tiny85 self power-off
Post by: larryd on Aug 20, 2020, 03:25 am
The log stays stationary and the band saw moves, nice.

I'm in love :).



Big shop, big jigs  :smiley-lol:

Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 20, 2020, 06:06 am
I'll PM you a vid it's quite a neat toy. I decided i wasn't going to buy timber forever so had this idea i'd build a mill and feed myself. After one day milling I had more timber than I'll use in several years so I don't know where I'm at now hahah might become a side gig.
Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 23, 2020, 12:56 am
It looks like 2.0 will come around quicker than I thought. I want one for my own table now haha.

I wondered if someone might point me in the right direction with how you would do this properly, using interrupts as if you were doing it on a uC that was busy with other tasks. Not that this will be any different but I might as well make a learning experience of it.

I'm not asking someone to write my program but perhaps a few lines if pseudo code to point me in the right direction. What would the ISR do and what would the main loop look like?
Title: Re: tiny85 self power-off
Post by: larryd on Aug 23, 2020, 03:04 am
" It looks like 2.0 will come around quicker than I thought."

;)



Interrupts are really meant for fast events.

There is quite a bit of information on interrupts kicking around.

What do you have in mind ?



Suggest you look at getting rid of delay()s in lieu of BWD, also study 'State Machine' programming.

It's tempting to use delay()s but the proper way (whatever proper means) is to 'always' write your sketches in a non blocking fashion.



Title: Re: tiny85 self power-off
Post by: larryd on Aug 23, 2020, 03:09 am
Here are two threads you might find interesting; there are many others too (better than) on this web site.

https://forum.arduino.cc/index.php?topic=525240.0     (https://forum.arduino.cc/index.php?topic=525240.0)

https://forum.arduino.cc/index.php?topic=597331.0    (https://forum.arduino.cc/index.php?topic=597331.0)



Title: Re: tiny85 self power-off
Post by: JoshNZ on Aug 23, 2020, 03:21 am
I realise that, hence my interest in progressing with this version.

My thoughts are run one timer with a 20ms period which at each overflow, runs a blocking routine for 1-2ms using a software delay to position servo. This would continuously run, and I'd manipulate the variables from the main loop, with non blocking delays and your state machine coding to select responses (when I get around to reading up on that xD...)

From the reading around I've done, it appears to be an uphill battle trying to run the ON duty cycle with a timer while maintaining the resolution needed for smooth servo movement - with an 8 bit timer at least.
I must admit while I can, if I painfully slowly grind through other libraries, I get a bit cross-eyed reading code with bit manipulation and processor registers.
Title: Re: tiny85 self power-off
Post by: larryd on Aug 23, 2020, 03:38 am
Perfect application for the 'State Machine' and BWD Timers.

Read the examples, then start things out and we can help.