Problems with 12F675


Closed Thread
Results 1 to 40 of 67

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    OK, I see what you mean now.

    Try this ...
    Code:
    btn1:                   'actionare buton up
    
    if but1=1 and rel2=0  then
             high rel1
                                     
             pause 20
                              
             while but1=1 
             call check
             wend
             pause 20
                                           
             while but1 = 0 AND but2=0      
             call check
                      if rel1=0  then
                      GOTO Btn1PressDone
                      endif
             wend
             LOW rel1
    
             while but1=1 OR but2=1
             wend
             pause 20     
    
    endif
    Btn1PressDone:
    And yes, the check: routine seems to work "only after 5 times".
    DT

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    I am speechless...THANK YOU VERRY MUCH ! Works like a charm ! Great job, You are verry, verry good in this...
    Great forum, I am proud for visiting him. All the best for everyone, wherever you are !

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    I have tested this module on my car ; works verry fine, like I expect.Since this will be use on car, I think this is one good ideea to minimize the consumption.So I try to write something...Please take one advice...Thanks !
    Attached Files Attached Files

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I think it might be better to ...
    Code:
    main:
        rel1=0
        rel2=0
    @   sleep
        pause 100
    It looks like you have correctly set-up the pic to wake from sleep on PORT change (either switch).

    So then it wakes up ... drives the motor relays as necessary ... and only after the motor is finished, and no buttons are pressed, go back to sleep.

    The two NOP's are only required if it will be jumping to an Interrupt vector on wake up.
    Yours is just continuing where it left off.

    Hmmm, sounds like a powered antenna driver. ??
    <br>
    DT

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thanks for reply ! I KNOW that YOU are right. ...Now my car has "intelligent" windows !
    ...I think to 'implement' the detection of 'long press button/short press button', but after one short holidays...All the best !

  6. #6
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    I'm back ! ...with another challenge :
    - if press short but1 (or but2) the schematic works like before (ON/OFF rel, at every press of but1/but2 or overload detection) ;
    - but...if press long (over 1 sec) but1 (or but2) the relay must be ON as long as the but is press; once the but is release, the relay must go OFF.
    I try to implement some code from Melanie's advices (Thanks !) founded on this forum, but the result are not good...Relay don't go ON not at all ...
    I see this is the way witch work the electric windows on other cars ( with two different type of press: long & short) ; maybe, with - a lot of - help, I make my car (b.t.w. - Logan by Renault !) with really intelligent windows ! Thanks in advance for any advice !
    Attached Files Attached Files

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Challenge? ... What challenge?

    Started with a previous version ...
    Code:
    '****************************************************************
    '*  Name    : THE_BUTON_sleep.BAS                         *
    '****************************************************************
    @ DEVICE PIC12F675, intrc_osc_noclkout, wdt_OFF, pwrt_on, mclr_off, bod_off
    
    DEFINE OSC  4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    
    CMCON = 7
    OPTION_REG  = %10000110
    TRISIO  = %00011110
    ANSEL = %00011000
    ADCON0 = %10001101
    
    GIE var intcon.7 ' global interrupt enable 1=on ; 0=off
    gpie var intcon.3 'port change interrupt enable 1=0n ; 0=off
    gpif var intcon.0 'port change interrupt flag bit
    
    adval var Word
    vt var word
    u  var byte
    cnt var byte
    but1 var gpio.3
    but2 var gpio.2
    rel1  var gpio.5
    rel2  var gpio.0
    
    Timer1    VAR WORD EXT :@Timer1 = TMR1L
    TMR1ON    VAR T1CON.0
    TMR1IF    VAR PIR1.0
    T1Count   VAR BYTE
    LongPress VAR BIT
    T1CON = %00110100
    
    u=0
    cnt=0
    GIE=0
    GPIE=1
    IOC.2=1   ' int-on-change for GPIO.2 enabled
    IOC.3=1   ' int-on-change for GPIO.3 enabled
    
    but1=0
    but2=0
    rel1=0
    rel2=0
    
    main:
      rel1=0
      rel2=0
    @ sleep
      pause 100
      Timer1    = 3037
      T1Count   = 0
      LongPress = 0
      
      btn1:                   'actionare buton up
      
      if but1=1 and rel2=0  then
               high rel1
               TMR1ON = 1 
               pause 20
                                
               while but1=1
               call check
               wend
               IF LongPress THEN Stop_UP
               T1Count = 0        
               pause 20
                                             
               while but1 = 0 and but2 = 0
               call check
               if rel1=0 then
                  GOTO Btn1PressDone
               endif
               wend
        Stop_UP:
               LOW rel1
      
               while but1=1  OR but2 = 1
               wend
               pause 100
      endif
      GPIF=0  'Clear ort change interrupt flag
      
      Btn1PressDone:
      
      
      btn2:               ' actionare buton down
      if but2=1 and rel1=0  then
               high rel2 
               TMR1ON = 1 
               pause 20
                       
               while but2=1
               call check
               wend
               IF LongPress THEN Stop_Down        
               pause 20                          
              
               while but2 = 0  and but1 = 0
               call check
               if rel2 = 0 then
                 GOTO Btn2PressDone
               endif
               wend
        Stop_Down:
               low rel2  
      
               while but2=1 or but1=1
               wend
               pause 100
      endif
      GPIF=0  'Clear ort change interrupt flag
      Btn2PressDone:
       
    GOTO MAIN
    
    check:          ' verificare pentru supracurent
      adcin 3, adval
       vt=adval * 5000
       vt=div32 1023
      
      for cnt = 1 to 5
              if vt > 270 then      
                  u=u+1
                          if u > 5 then
      	                gpio.0=0
                          gpio.5=0
                          endif
                  pause 50
                  goto check            
              else
                  u=0
              endif
      next cnt
      
      IF TMR1IF then
          TMR1IF  = 0
          Timer1  = 3037
          T1Count = T1Count + 1
          if T1Count = 2 then 
            TMR1ON = 0
            T1Count = 0
            LongPress = 1
          endif
      ENDIF
    
    return
    
    
    end             ' of program
    I'll have to charge you for the next one though.
    <br>
    DT

Similar Threads

  1. 12F683 vs 12F675.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th July 2009, 05:58
  2. LANC code 12F675
    By MikeDD in forum General
    Replies: 4
    Last Post: - 9th May 2008, 06:44
  3. 12F675 cant serout to PC
    By ruijc in forum General
    Replies: 9
    Last Post: - 3rd December 2007, 01:11
  4. USART problems
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 6th March 2005, 22:45
  5. Serial LCD on 12F675
    By anj in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st April 2004, 00:11

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