Port indexing & PWM for LED fade


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Port indexing & PWM for LED fade

    Looks good to me if the addressing works with PWM.
    What happens if you only try to PWM a single LED when you address it that way.. same thing?


    I've read about the trick to address pins, what if you knock them into a declared array first,
    and then aliased each one, I wonder what that would do.

    Code:
    pins[8] var byte
    portb.0 var pins[0]
    portb.1 var pins[1]
    portb.2 var pins[2]…
    
    
    Then cycle "pins" in the PWN command
    for selected = 0 to 7
    pins[selected] = value
    next selected
    Last edited by Art; - 1st December 2013 at 12:25.

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Port indexing & PWM for LED fade

    but my comment is, software PWM command (not HPWM) is a dead end.

    How about starting with a constant loop that counts from zero to something,
    or a hardware counter, then look at that counter each cycle of your program,
    and determining which LEDs to turn on or off based on their own preset on/off counters.

    Then you can vary the counters, and you're not limited to a single simultaneous PWM channel.

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Re: Port indexing & PWM for LED fade

    Art, Thanks for your reply. PWM with a single LED or port (LED1 var PortB.1) or single port (PortB.1) will work with PWM however I have been unable to get indexing to work with the PWM in any shape, form, or fashion. Some LED will light up but will not be the one you addressed. I think the problem must be within the PWM command structure. It will not recognize the indexing as a port location. I tried several versions of your suggestion of array declaration, no luck. I think indexing in some form should work but I have not figured it out yet. I have the routine working with Select Case approach but an indexing method would reduce the code considerably. Work continues…
    Last edited by MOUNTAIN747; - 1st December 2013 at 23:37. Reason: typo

Similar Threads

  1. Help with LED driver fade on/off
    By dfort in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th July 2009, 00:39
  2. PWM and fade effect
    By ruijc in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th July 2009, 10:58
  3. Port Indexing
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th September 2006, 12:33
  4. LED fade without PWM command
    By Nick in forum mel PIC BASIC
    Replies: 7
    Last Post: - 29th June 2005, 20:56
  5. Fade out an LED using PWM?
    By RossW in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 6th August 2004, 19:59

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