Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

"sustain" the onbutton (increase press-time) (for on-button(sw-off))

Status
Not open for further replies.

xarvox

New Member
Hello everybody!

im about to build the power module for my bike computer, but im in dire need for some consultations.

First off;
i will be utilizing a auto-power-off function, as described on the link below.
https://homecircuits.eu/blog/arduino-low-voltage-disconnect-circuit/

The initial ON-duration (while button is pressed) is a concern for me, since im calculating that it might take several seconds to successfully boot the systems and initialize the keep-on pin needed to take over from the button press (to keep the above circuit active).
Im using a arduino as controller with i2c pin expanders (mcp23008) and my aim is to use one of the pins from one of the pin expanders to keep the circuit on.

Currently it takes about 2 seconds from when i connect power to when the led turns and stays on (blinks once at boot?), when connected to the pin extender.
..But i will be adding quite a lot more to the system, witch might (or might not) cause further delays at startup.

So im trying to figure out a way to "sustain" the button press, so a very short tactile button click will be read as looong-press for the hardware.
I dont want to be holding in the ON-button for several seconds to make sure i boot up the system..

There is of course ways to do this, my problem is that i havent even the slightest idea in what direction to look for the solution..
I was considering a capacitor at first, but that means it will only have a "shortclick"-time to charge and from what i understand, they charge/discharge about equally fast..?

This have lead me into thinking i will have to have a charged capacitor that i discharge when the button is pressed, but that kind of defies the idea of a self-disconnecting circuit, that will not draw any current while powered down.

So could anyone please throw in a bright idea?
 
Don't use an Arduino, use a bare processor - which will 'boot up' far faster than you can press the button and release it.

I've used auto-power off circuits for PIC's, and they work perfectly and instantly (I 'stole' the actual circuit from an AVR example).
 
Nigel, Well, thats one way to "avoid" the question, your solution probably works just as you described.
However, i believe that the initial question merits an answer, regardless of other workarounds.

I am grateful for your input, especially when you don´t agree with me, since that´s when i learn the most. :)

For me personally, its a question of finance versus time.
I have designed and ordered custom PCB´s for this project (will be posting more about it under the same tag) and even tho i had to ditch some of the component pcb´s due to negligence on the design-stage, i find it hard to motivate yet another PCB order.

The issues with the scrapped PCB´s are too numerous to mention but their functions will be replaced with soldered proto-boards.
The battery compartment (where the previously linked auto-off circuit resides) has about 45mm inner diameter(tube, L=35cm), so its a wee bit more spacy than 19.5mm (inner dia, handlebar, usable L=15cm).. :p

The reason behind not being "able" to go for a bare chip is that i dont think i´ll have the space for a (big enough) chip and its requred hardware inside my handlebar tube, while a arduino nano with the wires soldered directly to the board (no headers) will fit like a glove, with not a mm to spare. (18.9mm with electric tape) :)
This means that my circuit ends up in the middle of the tube, eliminating the possibility of the circuit shorting against the handlebar tube.

But please enlighten me, what is it about the "real" arduino that takes time compared to the "bare chip" at bootup?
I always figured that the arduino is just a "breakout board" for the ATMEGA processor onboard..
 
But please enlighten me, what is it about the "real" arduino that takes time compared to the "bare chip" at bootup?
I always figured that the arduino is just a "breakout board" for the ATMEGA processor onboard..

I can't say I've ever looked in to it, but any 'chip' that takes two seconds to start running wouldn't be a very good one.

I suspect that it's perhaps down to the bootloader (for programming the Arduino), perhaps that waits two seconds while it checks for incoming serial data to reprogram it? (that's one of the ways bootloaders work).

Edit:

I just posted this link in another thread, and realised it contains the auto-off circuit I used - which works perfectly.

One 'possibility' perhaps, increasing the size of C9 (left of page 7) might provide power long enough for the Arduino to start running your code.

https://www.mikrocontroller.net/attachment/164956/ttester_eng104k.pdf
 
Last edited:
Thanks Nigel, i´ll go read that doc right after i post this. :)

The delay i think is due to the i2c bus, everything needs to get powered up, then initialize comms and so on.
Im also using a library for the wire and MCP23008 pin extenders, witch might also need some wakeup-time..?

the serial response from my arduino (over usb) is under a second from when i press the reset-button, any time interval below a second is guestimations for me, but its closer to 1 than 0.

Just finished my initial mainproject post if youre interested. :)

Now; reading time! :)
 
How about a relay or logic gate which latches as soon as the button in pressed - which is subsequently disabled within the arduino code after 5 sec?
 
The delay i think is due to the i2c bus, everything needs to get powered up, then initialize comms and so on.
Im also using a library for the wire and MCP23008 pin extenders, witch might also need some wakeup-time..?

I'd be inclined to use a normal I/O for the power switching, and latch the power on BEFORE you do anything else.

Here's the first part of main() from one of my PIC examples, I simply set the clock speed, turn off the analogue inputs, set the direction of the I/O ports, and then set RB6 high, which is the pin for the latching power switch.

All the longer initialisation sections (which aren't very long anyway) are done after the power has been latched.

Code:
void main(void)                   // program entry
   {
    OSCCON = 0b01101000;                    //4MHz clock speed
   ANSELA=0;
   ANSELB=0;
   ADCON1 = 0x06;                                 // Analogue inputs off
   LCD_TRIS = 0b00000000;             // Lcd port as outputs
   TRISB = 0b10110111;                          // set RB3 and 6 as outputs for opto and ON/OFF  
   LATB = 0;                                             // all outputs LOW (all LED's off)
   RB6 = 1;                                                // latch ON/OFF switch ON
 
Well, i do it in a similar fasion as the coded example, but i first init the mcp(mcp.begin(9600), then set the on-pin to high(mcp.digitalWrite(onPin, HIGH), however i do this before the main loop, at void setup(). (unfamiliar with the flavor in the code example)

The reason behind these pin extenders is the distance between everything, and the number of cables it would require had i not used the i2c bus.

I cannot run the cables 100% internally, it´ll have to go externally on some stretches.
So i really dont want to add any cables to the existing idea of a single 4-lead cable.

FlatfootSkier, you are welcome to elaborate, im a electronics newbie.. :)
But yes, a latching feature would be possible, i also have I/O-pins to spare (to reset the latch).
I´ll have a websearch, it´ll probably give some insights. :)

Thank you folks for the input so far! :)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top