output port issues driving LEDs


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2006
    Posts
    7

    Default output port issues driving LEDs

    With a 16F690 and PBP, I’m having a problem driving simultaneous port outputs which are connected to LEDs via individual 2k Ohm resistors to ground.
    With this first bit of code, I can illuminate one or two LEDs as one would expect.

    Trisc = %00000000

    Portc = %00000001 ‘ lights the first LED
    Pause 1000
    Portc = %00000011 ‘ lights both LEDs

    Now, the below code SHOULD do the same thing as the above code which is
    light the first LED then light the second LED while not turning off the first LED.
    Nope, the first LED gets extinguished.

    Trisc = %00000000

    Portc.0 = 1 ‘ lights the first LED
    Pause 1000
    Portc.1 = 1 ‘ the first LED goes dark and the second LED lights!!!!


    I have found some other older posts that talk of this same issue but they were running several LEDs with one dropping resistor which turned out to be their problem.
    I have a separate resistor for each LED.

    HELP!

    Bob

  2. #2


    Did you find this post helpful? Yes | No

    Default

    May I suggest that 2K ohms is way to high a value? Use something more like 300 ohms.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by p15218 View Post
    Portc.0 = 1 ‘ lights the first LED
    Pause 1000
    Portc.1 = 1 ‘ the first LED goes dark and the second LED lights!!!!
    It's the never ending problem.

    OK well, it will end for you when you add this to your program ...
    Code:
    ANSEL = 0
    But for us, it will never end. The word will never get out. "Turn off the Analog ports".

    Microchip is a cruel vicious company bent on driving us crazy by ENABLING analog functions by defualt.<hr>

    Sorry, I was watching the political convention on Tivo and felt like being over-dramatic for no reason at all.
    DT

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Microchip is a cruel vicious company bent on driving us crazy by ENABLING analog functions by defualt.
    Yes, but has anyone noticed that they're not even sensibly enabled 'by default'? Posted by videophone onto a big screen from the back of a dodgy hotelroom in Kansas).

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    FYI: The reason this happens;
    Code:
    Portc.0 = 1 ‘ lights the first LED
    Pause 1000
    Portc.1 = 1 ‘ the first LED goes dark and the second LED lights!!!!
    is because you're using a read-modify-write type command with Portc.0=1
    so when the PortC is read on the 2nd Portc.1=1, Portc.0 is read again, and
    it's read as zero, since A/D is enabled, so it goes low on the next port bit
    change.

    Melanie: What the heck are you doing in Kansas...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    It's the never ending problem.

    But for us, it will never end. The word will never get out. "Turn off the Analog ports".

    Microchip is a cruel vicious company bent on driving us crazy by ENABLING analog functions by defualt.<hr>

    Sorry, I was watching the political convention on Tivo and felt like being over-dramatic for no reason at all.
    What I don't understand is: Why do so many people miss this? Thinking back to my PIC infancy, it is this very thing which I can recall learning. The first step in any program. Setting up the ports to work they way I want. Analog, Digital, Input, Output, Pull-up, CCP, .... Whatever. It's plastered everywhere! I could hardly read a post, manual, datasheet, PIC book, etc. without seeing this problem and the solution.



    .....



    I'm done. Stepping down. Deep breath.

    SteveB
    Last edited by SteveB; - 28th August 2008 at 03:26. Reason: punctuation!

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    No, not in Kansas... I was just making fun of the convention following Darrels comment... though I was in Southern California for a short while a month back... baby-sitting of all things - Don't ask!!!

Similar Threads

  1. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  2. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  3. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 23:19
  4. Port A Issues
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st June 2005, 22:07
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 6th May 2005, 00:29

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