simple xmas light project not behaving....


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    look into Darrel Taylor's 3 channel software PWM code - it's interrupt based. I'm not sure if it's ready to run on a 18F4550. Your main loop would look something like this:

    FOR x = 0 to 255 STEP 5
    red = x 'REd fade on,
    PAUSE delay
    NEXT x

    FOR x = 0 to 255 STEP 5
    green = x 'green fade on,
    PAUSE delay
    NEXT x

    ect...

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    969


    Did you find this post helpful? Yes | No

    Default

    The code you showed has some problems for sure.

    The variables Duty and Scale are set to 1 at start. Then you do this
    Code:
    POWERUPRED:
    for Aloop = 1 to DUTY
    FOR Bloop = 1 to REDSCALE
    HIGH RED
    pause Aloop
    LOW RED
    pause (duty-Aloop)
    NEXT Bloop
    NEXT Aloop
    HIGH RED
    return
    Rewriting with your declared values it looks like this
    Code:
    POWERUPRED:
    for Aloop = 1 to 1
    FOR Bloop = 1 to 1
    HIGH RED
    pause Aloop
    LOW RED
    pause (1-Aloop)
    NEXT Bloop
    NEXT Aloop
    HIGH RED
    return
    Perhaps you see the problem now.

    Regards

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Jerson;
    Ok thats weird...
    The scale var is their if i want to slow down the change... so setting this to 1 is normal
    The duty var is actually set to 100 but for some reason it's shown as 1...
    Where did my zero's go?

    Max;
    I'm aware of DT's 3 channel PWM, however, the 18F4550 is only the development hardware i use for testing everything...
    I will be buying some lower grade pic's to do the job... i want approximately 5-10 of these running different patterns around the house both inside and out...
    Last edited by comwarrior; - 30th October 2010 at 00:21.

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