A less Cumbersome way of manipulating several LEDS?


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Virtual Ports

    Excellent Darrel - many thanks....does it add much in the way of delay? (ie if I was sequencing 8 leds fast would this start slowing stuff up)

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


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    how fast human eye is btw? vport is nowhere near to be that slow
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: Virtual Ports

    Quote Originally Posted by HankMcSpank View Post
    ....does it add much in the way of delay? (ie if I was sequencing 8 leds fast would this start slowing stuff up)
    VirtualPort will be faster than using lists of HIGH/LOW since it doesn't set the TRIS bits each and every time.
    That in itself may be a problem when running at 32Mhz and the old R-M-W issue may come into play.
    Let me know if it does and I'll change it to use the LAT registers on the 16F1's.

    In a similar vein, can I group just two specific leds together for ease of handling? (I always will want two specific LEDS to light/extinguish together - but want to treat them as one entity vs having to duplicate the commands to each port/pin per LED)
    The pin list macro can have multiple pins assigned to each bit.
    In this example both RC6 and RB3 would turn on and off according to bit0 of the value passed to WritePort.
    Code:
    MyPortPins  macro               ; these define which bits go with which pins
        Vpin   0, PORTC,6
        Vpin   0, PORTB,3
        Vpin   1, PORTB,6
        Vpin   2, PORTB,5
    DT

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Virtual Ports

    Hi Darrel,

    That's fantastic (ie two pins handled as one virtual pin...I'm figuring that the maximum number of Virtual Port bits is 8? if so, wouldn't you just know that I have 9 LEDs!)

    re VirtualPort and the TRISC settings ...hmm, maybe I can't use your funky routine after all - one thing I observed when using the HIGH/LOW command, was excessive audible clicking attributed to the port.pin switching state (I work with low level guitar signals, which often pass in close proximity to a PIC, guitar signals often get treated with enormous gain so I'm perhaps more aware/sensitive to such clicks than others!) The only way I was able to stop such clicking was to to use TRISC command instead of the high/low command, for example, this would result in clicking....

    TRISC.6 = 0
    HIGH PORTC.6

    whereas this doesn't...

    PortC.6 = 1
    TRISC.6 = 0

    ....whacky. (so to turn an LED on/off, I don't use high/low, but just set the pin as output or input)
    Last edited by HankMcSpank; - 1st September 2011 at 23:10.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    In a similar vein, can I group just two specific leds together for ease of handling? (I always will want two specific LEDS to light/extinguish together - but want to treat them as one entity vs having to duplicate the commands to each port/pin per LED)
    Why not wire them in "anti-parallel" then? One is on when pin is low, the other when pin is high and both are off when TRIS is 1.

    /Henrik.

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Quote Originally Posted by HenrikOlsson View Post
    Why not wire them in "anti-parallel" then? One is on when pin is low, the other when pin is high and both are off when TRIS is 1.

    /Henrik.
    Because I need them to light up together....if I'm reading your suggestion correctly, only one LED can be on at a time?

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Sorry, I misunderstood that. I thought you wanted one on when the other was off. I guess I kind of took that for granted because I can't really see the point in using more than one pin. Just wire the LEDs in parallel or, which is probably better, in series. Depends on the powersupply voltage and forward voltage drop of the particular LED.

    Are these some high power blue LEDs? High current and high Vf? Is that the reason you need one pin for each LED? Please tell me what I'm missing :-)

    /Henrik.

  8. #8
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: A less Cumbersome way of manipulating several LEDS?

    Quote Originally Posted by HenrikOlsson View Post
    Sorry, I misunderstood that. I thought you wanted one on when the other was off. I guess I kind of took that for granted because I can't really see the point in using more than one pin. Just wire the LEDs in parallel or, which is probably better, in series. Depends on the powersupply voltage and forward voltage drop of the particular LED.

    Are these some high power blue LEDs? High current and high Vf? Is that the reason you need one pin for each LED? Please tell me what I'm missing :-)

    /Henrik.
    Yes, I'm using high brightness blue leds (fwd voltage 3.2V, my PSU is 4V) in parallel drawing about 20mA, therefore two = 40ma...too much for one PIC pin...hence wanting to treat two pins as one virtual pin in code. But it's no big deal....thought I'd ask - and as ever there is something that exists that can be brought into play, except that I need to control the pin on/off via TRISC to avoid clicking so I can't personally use it.
    Last edited by HankMcSpank; - 2nd September 2011 at 10:17.

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