16F628A - Stops if release power switch.


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Bruce, nice, thank you very much.
    Very nice.
    Just nice, from assembling without errors and warnings to the sequence and
    finally grouping the delays with " execute delay this number of times". Cool.
    Today i love electronics.

    I'll wait for some more answers to see if problem 1 will be completely solved, although grounding MCLR and that "sleep mode until /MCLR reset"..., almost solve the problem, looks very good ALREADY.

    Thanks again, Bruce.

  2. #2
    Join Date
    Feb 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Bruce, chaser2.asm makes the MCLR pin ssso sensible it turn the A0 led ON by just hovering the hand over the pic at about 15 cm... The circuit has transformed into a kind of "human bioelectric field detector" effective up to 15 cm
    This happened after i attached a wire to MCLR pin. The wire is now "in the air" and was intended to connect the pin to a PCB switch, but only by soldering it to MCLR pin it made everything uncontrolable...
    Before soldering the wire, the sequence was able to be started by only touching the MCRL pin with a metal, without even being conected to the GND.

    I only have here now some variable resistors 0-3K... you said something about a pull-up resistor, which i don't even imagine its shape... and function.
    Can you help ?
    This is the code chaser2;

    Code:
        LIST  p=16F628A         ;tell assembler what chip we are using
        include "P16F628A.inc"   ;include the defaults for the chip
        
        ;__config 0x3D18         ;config settings (osc. type etc.)
    
        ; similar to above with /MCLR enabled (for reset), XT osc (not internal). power-up timer on,
        ; and now you know at a glance what your config settings are.
    
        __CONFIG _CP_OFF & _BODEN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _LVP_OFF & _XT_OSC
    
        cblock 0x20  ;start of general purpose registers
          count1     ;used in delay routine
          counta     ;used in delay routine 
          countb     ;used in delay routine
          times      ;number of times to execute Delay loop
        endc
    
    LEDA0	    Equ  0     ;set constant LED = 0
    LEDPORTA0   Equ  PORTA ;set constant LEDPORT = 'PORTA'
    LEDA1	    Equ  1     ;set constant LED = 1
    LEDPORTA1   Equ  PORTA ;set constant LEDPORT = 'PORTA'
    LEDA2	    Equ  2     ;set constant LED = 2
    LEDPORTA2   Equ  PORTA ;set constant LEDP0RT = 'PORTA'
    LEDA3	    Equ  3     ;set constant LED = 3
    LEDPORTA3   Equ  PORTA ;set constant LEDPORT = 'PORTA'
    LEDA4	    Equ  4     ;set constant LED = 4
    LEDPORTA4   Equ  PORTA ;set constant LEDPORT = 'PORTA'
    
    ; NOTE: Removed below because RA5 = INPUT only on 16F628
    ; LEDA5	    Equ  5     ;set constant LED = 5 
    ; LEDPORTA5   Equ  PORTA ;set constant LEDPORT = 'PORTA'
    
    LEDB0	    Equ  0     ;set constant LED = 0
    LEDPORTB0   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB1	    Equ  1     ;set constant LED = 1
    LEDPORTB1   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB2	    Equ  2     ;set constant LED = 2
    LEDPORTB2   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB3	    Equ  3     ;set constant LED = 3
    LEDPORTB3   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB4	    Equ  4     ;set constant LED = 4
    LEDPORTB4   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB5	    Equ  5     ;set constant LED = 5
    LEDPORTB5   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB6	    Equ  6     ;set constant LED = 6
    LEDPORTB6   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDB7	    Equ  7     ;set constant LED = 7
    LEDPORTB7   Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDPORT     Equ  PORTB ;set constant LEDPORT = 'PORTB'
    LEDTRIS     Equ  TRISB ;set constant for TRIS register
    	
       org     0x0000   ;org 0 for the 16F628
    
       banksel PORTB    ;select bank 0
       movlw   0x07
       movwf   CMCON    ;turn comparators off (make it like a 16F84)
       clrf    PORTB    ;clear all port latches before setting TRIS regs
       clrf    PORTA
    
       banksel TRISA    ;select bank 1
       movlw   b'00100000'
       movwf   TRISA    ;set PortA outputs, RA5 = /MCLR input
       clrf    TRISB    ;set PortB all outputs
    
       banksel PORTB    ;select bank 0
    
    ;----------------------------------------------------------------------
    
    Loop
       BSF    LEDPORTA0, LEDA0  ; RA0 ON
       movlw  d'4'    ; execute delay this number of times
       movwf  times    
       call   Delay
    
       movlw  b'11111111'
       movwf  LEDPORT
       movlw  d'4'    ; execute delay this number of times
       movwf  times    
       call   Delay
    
       movlw  b'00000000'
       movwf  LEDPORT
       movlw  d'4'     
       movwf  times
       call   Delay
    
       movlw  b'11111111'
       movwf  LEDPORT
       movlw  d'4'
       movwf  times    
       call	  Delay
       
       movlw  b'00000000'
       movwf  LEDPORT
       movlw  d'4'
       movwf  times    
       call	  Delay
    
       movlw  b'11111111'
       movwf  LEDPORT
       movlw  d'4'
       movwf  times    
       call	  Delay
    
       movlw  b'00000000'
       movwf  LEDPORT
       movlw  d'4'
       movwf  times   
       call	  Delay
    
       movlw  b'11111111'
       movwf  LEDPORT
       movlw  d'4'
       movwf  times    
       call	  Delay
    
       movlw  b'00000000'
       movwf  LEDPORT
       movlw  d'4'
       movwf  times    
       call	  Delay
    
       movlw  b'00010000'
       movwf  LEDPORT
       movlw  d'1'
       movwf  times    
       call	  Delay
    
       movlw  b'00001000'
       movwf  LEDPORT	
       movlw  d'10'
       movwf  times   
       call	  Delay
    
       movlw  b'00010000'
       movwf  LEDPORT	
       movlw  d'1'
       movwf  times      
       call	  Delay
    
       movlw  b'00000000'
       movwf  LEDPORT	
       movlw  d'4'
       movwf  times       
       call   Delay	
       bcf    LEDPORTA0,LEDA0  ; RA0 off
       
       ; code above executes once, then PIC enters low-power sleep mode until /MCLR reset.
    
    SleepLoop 
       SLEEP            ; enter low power sleep
       GOTO   SleepLoop ; go back to sleep if it wakes up
    ;-------------------------------------------------------------------------------------
    
    Delay
       movlw   d'250'    ;delay 250 ms (4 MHz clock)
       movwf   count1
    
    d1
       movlw   0xC7
       movwf   counta
       movlw   0x01
       movwf   countb
    
    Delay_0
       decfsz  counta,f
       goto    $+2
       decfsz  countb,f
       goto    Delay_0
       decfsz  count1,f
       goto    d1
       decfsz  times    ; execute delay this number of times
       goto    Delay
    
       retlw   0x00
       
       end

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    A pull-up resistor is just a simple resistor connected between a pin (MCLR) and Vdd.
    http://www.seattlerobotics.org/encod...97/basics.html

    Everything bellow 22K would work. Usually 10K for me (in many case).
    Last edited by mister_e; - 10th February 2009 at 21:28.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Can't do it.

    It's totally uncontrollable, even with the pull-up resistor.
    Then, I don't want 2 switches, there is nobody there to reset the pin.
    The sequence must start and play with just a push&release, very short and then must standby and wait another push-start instead reseting.

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


    Did you find this post helpful? Yes | No

    Default

    Too bad,

    We had a working solution ... but with PBP.

    Really sorry not to be able to help you further.

    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
    Feb 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Ace

    Quote Originally Posted by Acetronics View Post
    Too bad,

    We had a working solution ... but with PBP.

    Really sorry not to be able to help you further.

    Alain
    Alain, omg. I went back to your post with the working solution and i finally understood what you said... That post was posted before Bruce gave me the codes #1&#2 and at that time i was unable to think clearly.
    Ace, thanks for coming back, this time i did it; a NC push button on Vdd powering the chip and that was it. omg it was easy.
    Merci, Alain, thanks for coming back, omg.

    Thanks everybody subject closed; this configuration is good for a half million applications, even for tech processes which are not so complex.

Similar Threads

  1. Switch mode power supply Pic Micro
    By iw2fvo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th July 2009, 13:11
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. Replies: 3
    Last Post: - 29th April 2009, 00:45
  4. 'Soft' On/Off Power Switch
    By Art in forum General
    Replies: 19
    Last Post: - 14th November 2008, 01:54
  5. Newbie - 16F628A and switch latching
    By malc-c in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 19th May 2006, 02:35

Members who have read this thread : 0

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