A new challenge (I'm in trouble again)


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2009
    Posts
    21

    Default A new challenge (I'm in trouble again)

    My recent successes with my Christmas star have got me a request from a neighbour for lighthouse flashing circuit for his model lighthouse. No problem with flashing routines,\however the requirement is to have automatic shutdown (battery saving). To achieve this with a 16f628a I have fed the pic via a pnp switching transistor (2n3906) base is pulled up with 4.7k
    and connected to porta.1 via 22k. To start up a pushbutton is also connected to the 22k which pulls the base to 0 and switches on the transistor. This works OK ---HOWEVER I wish to use the same pushbutton to change the flashing routine therefore I have to free up the pushbutton and make porta.1 an input. In order to do this I have connected an identical \transistor switch to portb.0 to hold the supply on whilst using porta.1 as an input. This does not work and I can't for the life of me figure out why. The effect that this produces is that the "power" on led in the circuit lights (at very slightly less than full brightness) then when I press the button (i.e. switch on the transistor which is driven from Porta.1) the flashing routine commences but only continues whilst I hold the button down and then after 12 flashes freezes with the flashing led on ! What the devil is going on ? The code I have written is as follows . Hope I have made this clear without attaching the circuit (haven't figured out how to do that yet... will have another look tomorrow. Cheers

    [@ DEVICE pic16f628a,intrc_osc_noclkout,mclr_on

    x var word
    output portb.0
    output portb.3
    output porta.1
    output porta.0
    porta.1 = 0
    portb.0 = 0

    input porta.1

    for x = 1 to 12

    high portb.3
    pause 200
    low portb.3
    pause 200
    next x
    end
    ]

  2. #2
    Join Date
    Oct 2005
    Location
    Pinckney, Michigan
    Posts
    91


    Did you find this post helpful? Yes | No

    Default Re: A new challenge (I'm in trouble again)

    I didn't fully evaluate how your'e doing it, but it sounds suspiciously similar to a circuit I designed several years back, and has worked well ever since.

    It should do what you need.

    The "gist" of the way it works is the very first button push will switch power on. The PIC must quickly set the "Master_On" signal to keep power on. Subsequent button presses will simultaneously try to power the system up again, but since it is "already" powered up, it will simply toggle the "BTN1" signal.

    The PIC must clear the "Master_ON" signal to turn power off.

    None of the circuits are critical so feel free to make substitutions, but be sure to use two diodes.


    Name:  PB_Startup_Mode_Change_Circuit.jpg
Views: 362
Size:  237.0 KB

  3. #3
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default Re: A new challenge (I'm in trouble again)

    Here's a very simple way to do this; http://www.best-microcontroller-proj...n-Circuit.html

    I havent tried this myself yet, though.

    Regards,

    Anand Dhuru

  4. #4
    Join Date
    Dec 2009
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: A new challenge (I'm in trouble again)

    Thanks for the help folks. I'm afaid Marks that your circuit uses devices not readily available to me and is alittle more complex than I wanted - many thanks for your trouble however. Ardhuru -- looked at the site you suggested but can't relate it to my problem ... thanks anyway. I have tried to approach the problem another way i.e. to use the sleep command to minimise power consumtion. Im still having problemas however (brain ain't what it used to be) hence a new post related to interrrupts which I am about to submit.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: A new challenge (I'm in trouble again)

    Hi,

    Thinking to it twice ...

    some times ago a friend of us from Argentina, called "PEU" asked for help for a hand light device and some kind of automated start/stop sequence like you look for ... was aboard a 12F683.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: A new challenge (I'm in trouble again)

    Was about end 2007 to 2008 ...

    not sure it has been lost ...

    Wow !!! got it in my archives ( 04/2008 )

    Code:
    '@ device pic12f675,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off, bod_on
    @    __config _INTRC_OSC_NOCLKOUT & _PWRTE_ON & _WDT_OFF &_BODEN_ON & _MCLRE_OFF & _CP_OFF
     
    '*****************************************************************************
    'Config
    '*****************************************************************************
     
    'OSCCON  = %01100110
    CMCON  = %00000111     ' Disable comparator
    VRCON   = %00000000     ' disable
    ADCON0  = %11100000
    ANSEL   = %10000000
    '*****************************************************************************
    '       I/Os
    '*****************************************************************************
    GPIO    = %00000000   ' All outputs low
    TRISIO  = %00000000      ' no inputs 
    '*****************************************************************************
    'Aliases
    '*****************************************************************************
    BODbit   var GPIO.0
    PORbit   var GPIO.1
    BOD   var GPIO.2
    LED   var GPIO.4
    '*****************************************************************************
    ' Init vars
    '*****************************************************************************
    Selection var Byte
    Ton   var Word
    Toff  var Word
    '*****************************************************************************
    Coldstart:
    '*****************************************************************************
       
    IF PCON.1 = 0 and PCON.0 = 0 THEN BODbit = 1 'BROWN OUT RESET BIT
    IF PCON.1 = 0      THEN
      PORbit = 1         'POWER ON RESET BIT
                 ' For debugging purpose only !!!
                 
      Selection = 1        'Lights LED @ 25%
    ENDIF
    PAUSE 1000
    GPIO = 0
    IF PCON.1 = 1 AND PCON.0 = 0 THEN    'PCON.0 = BOD ;PCON.1 = POR
              
        BOD  = 1              'GPIO.1 red led PIN6 shows a BOD state
        PAUSE 1000        ' For debugging purpose only !!!
        GPIO  = 0
        
        Selection =  ( Selection + 1 )// 5
        
        
    ENDIF
    PCON.1 = 1
    PCON.0 = 1
    '*****************************************************************************
    'Program choice
    '*****************************************************************************
    SELECT CASE Selection
     CASE 0
       Ton = 0   ' Stop
     
     CASE 1 
      Ton = 500  ' 25%
     
     CASE 2 
      Ton = 700  ' 50%
     
     CASE 3 
      Ton = 870  ' 75%
     
     CASE 4 
      Ton = 1000  '100%
     
    END SELECT
    
     
    '*****************************************************************************
    'Power Drive
    '*****************************************************************************
    Toff  = 2000 - Ton
    IF Ton = 0  THEN       ' LED OFF
     LED = 0
     @ SLEEP       ' IF Power = 0 then snore !!!
     @ NOP        ' and wait for a Power off ...
             ' That ALSO saves the batt ...
    ENDIF
          
    'NOTE : WAKE UP is achieved by Powering OFF the device ... not the classical way !
    '  !!! WDT MUST be OFF !!!
             
    IF Ton = 1000  THEN      ' LED @ 100%
     LED = 1 
      
     WHILE 1       ' Endless loop until power Off !!!     
        WEND
        
    ENDIF
    WHILE 1        ' Soft PWM @ 500Hz until power OFF
     LED  = 1
     PAUSEUS Ton
     LED  = 0
     PAUSEUS Toff
     
    WEND
    END
    have fun ...

    Alain
    Last edited by Acetronics2; - 19th February 2012 at 14:18.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts