Buttons are driving me nuts


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Posts
    14

    Default Buttons are driving me nuts

    Don't you hate when you got the complicated thing to work, but the simple things just seem beyond you?

    I'm building a IR Camera trigger using a PIC 16F648A, and I spent all last night getting the 38.5Khz modulated carrier to work perfectly. I was testing it on a timer, so that every 5 seconds, it would send the pulse out. I now want to try triggering it from a button press, but I don't seem to be having ANY luck getting the PIC to see the press.

    Code is as follows:
    Code:
    @ device pic16F648A, wdt_off, intrc_osc_noclkout, mclr_off, protect_off
    DEFINE OSC 4
    CMCON = 7 ' Turn all comparators to fully digital (needed??)
    TRISB.3 = 0 ' IR Output Pin
    TRISB.4 = 1 ' Shutter Input Pin
    HPWM 1,127,38500 ' Configure HPWM for 50% duty cycle PWM signal at 38.5kHz
    CCP1CON = 0         'PWM OFF
    
    start:
    while TRISB.4 = 1 : WEND
    gosub shutter
    pause 250 
    goto start
    I've tried using "While TRISB.4 = 0 : WEND", and that (if memory serves) just fires the subroutine constantly (which makes sense).

    I've attached the "schematic" for how the button is attached, just in case I've mangled that somehow. The button is a normally open momentary contact. I've checked with a logic probe that B4 on the PIC sits low normally, and goes high with the button press.

    Sadly enough, I'm pretty sure this is going to be one of those simple "you missed..." answers.

    Thanks in advance!
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    TRISB configure i/o as input or output while PORTB is the place to read/write from/to.

    try...
    Code:
    <font color="#000000">        @ device pic16F648A, wdt_off, intrc_osc_noclkout, mclr_off, protect_off
            <font color="#000080">DEFINE </font>OSC 4
            CMCON = 7 <font color="#008000">' Turn all comparators to fully digital (needed??)
            </font>TRISB.3 = 0 <font color="#008000">' IR Output Pin
            </font>TRISB.4 = 1 <font color="#008000">' Shutter Input Pin
    
    </font>start:
            <font color="#000080">WHILE </font>PORTB.4 = 0 : <font color="#000080">WEND
            GOSUB </font>Shutter
            <font color="#000080">PAUSE </font>250 
            <font color="#000080">GOTO </font>start
            
    Shutter:
            <font color="#000080">HPWM </font>1,127,38500 <font color="#008000">' Configure HPWM for 50% duty cycle PWM signal at 38.5kHz
            </font><font color="#000080">PAUSE </font>500
            CCP1CON = 0      <font color="#008000">' PWM OFF
            </font><font color="#000080">RETURN
    </font>
    Steve

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

  3. #3
    Join Date
    Aug 2006
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Thank you SO much!

    I feel like an utter idiot for making that mistake.

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


    Did you find this post helpful? Yes | No

    Default

    I guess you will never do it again

    Don't worry about that, take your time, understand what you do, and enjoy the result.

    We are here to help anyway.
    Steve

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

Similar Threads

  1. In Circut Debug (ICD) buttons palet is disable for 18F2620
    By muskut in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th June 2010, 05:21
  2. destroying my last pic? driving a miniature motor
    By Michael Wakileh in forum Schematics
    Replies: 20
    Last Post: - 28th August 2007, 09:38
  3. Replies: 3
    Last Post: - 17th April 2007, 14:45
  4. Driving me NUTS!
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th October 2005, 15:06
  5. Driving a logic-level HEXFET
    By thelightbrain in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th November 2004, 23:34

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