Hi all,
I am new to this, however have managed to make some inroads into my project.
What I am attempting to do is to have a servo motor power on, complete a couple of swipes, and then shut down for a period of minutes before looping. I have been borrowing heavily from:
http://www.cunningturtle.com/attiny4585-servo-library/and
http://www.insidegadgets.com/2011/02/05/reduce-attiny-power-consumption-by-sleeping-with-the-watchdog-timer/The tricky part is that I want this system running for a period of months off a 4600mAh LifePO4 pack. As the servo continues to draw power as it waits for a pulse, I have added an N-MOSFET:
http://www.freetronics.com/products/n-mosfet-driver-output-moduleparts schematic:
http://cdn.shopify.com/s/files/1/0045/8932/files/NDRIVE_NDriveModule.pdf?100736and have wired it into the system assuming that the servo is operating as a motor like this:
http://www.electronics-tutorials.ws/transistor/tran_7.htmlWhether or not the circuit is 100% correct remains to be seen, however my issue is this...
If I load the attiny85 with the watchdog timer example given, It flashes correctly and measures in the uA range when sleeping as it should.
I am using the led in this as the gate signal for the MOSFET controller.
When I start adding the servo commands, in particular it seems to be the myServo.attach(1...) command, it starts reading around 2.5mA.
I've tried myServo.detach(), however this doesn't seem to solve the issue, which is not helped by the fact that every time i connect the ammeter in this state, the circuit becomes unstable/stops working. I also can't figure out how to make the servo reattach after detached for the next loop. When I remove it and reconnect the power as normal, it is relatively stable.
I feel bad asking for help, but this has had me stumped all week, trying with NPN transistors and all sorts to figure out what's going on.
Is there anything obvious in my code? The issue is in it somewhere, I just don't know Arduino well enough to see where, as you'll no doubt notice in the attached file.
Many thanks in advance for any assistance - I hope it proves useful to someone else once the bugs are worked out.
Mark.