1. 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.
    Dismiss Notice

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

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by xarvox, Aug 31, 2017.

  1. xarvox

    xarvox New Member

    Joined:
    Aug 31, 2017
    Messages:
    10
    Likes:
    0
    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.
    http://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?
     
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,203
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    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).
     
  3. xarvox

    xarvox New Member

    Joined:
    Aug 31, 2017
    Messages:
    10
    Likes:
    0
    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..
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,203
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE

    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: Aug 31, 2017
  6. xarvox

    xarvox New Member

    Joined:
    Aug 31, 2017
    Messages:
    10
    Likes:
    0
    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! :)
     
  7. flatfootskier

    flatfootskier Member

    Joined:
    Jan 11, 2007
    Messages:
    128
    Likes:
    5
    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?
     
  8. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,203
    Likes:
    640
    Location:
    Derbyshire, UK
    ONLINE
    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 (text):

    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

     
     
  9. xarvox

    xarvox New Member

    Joined:
    Aug 31, 2017
    Messages:
    10
    Likes:
    0
    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! :)
     

Share This Page