High End Pre with PIC 16F876A


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    13

    Default High End Pre with PIC 16F876A

    Hi Guys:
    I am quite new to PIC Programming and I thought it would be an excellent place to learn about it at this forum.
    I have been working on this idea of developing a high end pre around PIC 16F876A, though as far as I could go the porject works fine as long as I use up, down and mute buttons.
    But I cannot figure out a way how to configure that input selection stage so that one button changes the input (a total of four inputs) and when it reaches input 4, any new press on button input shifts the input to "input 1". I use ULN2803 for driving relays.
    Appreciate if guys here could help me out.
    Abidr
    Attached Files Attached Files
    Last edited by abidr; - 28th April 2008 at 07:18.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Not sure what you are after
    so that one button changes the input
    but this may give you an idea. http://www.picbasic.co.uk/forum/showthread.php?t=8602

    Or maybe use "count" routine. every time the button is pressed the counter increases. If the count VAR is 1 do something. If count VAR is 2 do something else. If count VAR > 4 then count VAR = 0.
    Is that what you need?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Apr 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    thanks "mackrackit"
    link is not helpful.
    Other part is that is VAR=0 then input is "IPOD" if input =2 etc.
    My issue is how to define variable "an exmaple will be of great help" and how to shift the command to ULN2803 again an example will help.
    Attached is picture of populated PCB of the project
    abidr
    Attached Images Attached Images  
    Last edited by abidr; - 28th April 2008 at 07:55.

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The count code would be something like this
    Code:
    Bcnt VAR BYTE ' variable for counting
    Button VAR PORT?.? 'PIN FOR BUTTON
    
    MAIN:
    IF Button = 1 then Bcnt = Bcnt + 1
    IF Bcnt > 4 then Bcnt =0
    IF Bcnt = 1 then GOSUB someplace1 ' after done at the gosub "return"
    IF Bcnt = 2 then GOSUB someplace2
    so on and so on
    That is the basics, you may need a debounce routine and pauses. Maybe some endifs and elses too.

    The sub routines would have something like
    HIGH PORT?.?
    This pin will be connected to the pin on the 2803 that you want to trigger.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Apr 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Thanks dave heres is the code:
    ACTIVATE_RELAY:

    LOW MUTE ' Activate MUTE

    select case RELAY

    case 1 : PORTD = %10000000
    PAUSE 500
    case 2 : PORTD = %01000000
    PAUSE 500
    case 3 : PORTD = %00100000
    PAUSE 500
    case 4 : PORTD = %00010000
    PAUSE 500
    end select

    GOSUB SHOW_INPUT
    HIGH MUTE
    IF RELAY_FLAG = 0 THEN GOTO MAIN

    RETURN

    SHOW_INPUT:

    select case RELAY

    case 1 : LCDOUT $FE, $C0,"DVD 5.1 "
    case 2 : LCDOUT $FE, $C0,"USB DAC1"
    case 3 : LCDOUT $FE, $C0,"USB DAC2"
    case 4 : LCDOUT $FE, $C0,"CD "
    end select
    RETURN
    Let me give it a try I guess it should work now.

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


    Did you find this post helpful? Yes | No

    Default

    If you need to count how many time a button have been pressed, you may use RA4/T0CKI. really easy to setup and work really fine. The only thing you need to read/reset is TMR0 register.
    Steve

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

Similar Threads

  1. 16F883 and Problems with HIGH statement
    By aaanekre in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th October 2009, 01:09
  2. PIC keeps resetting when executing subroutine
    By jbirnsch in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 27th August 2009, 07:03
  3. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 04:05
  4. need help simulating PS/2 mouse
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th December 2007, 21:49
  5. Pic suggestion for high precision voltage measure
    By d1camero in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th April 2004, 06:22

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