Aquarium Lighting project - PWM - Need some assistance as I'm rusty !


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Aquarium Lighting project - PWM - Need some assistance as I'm rusty !

    I found DT's slow PWM (http://www.pbpgroup.com/modules/wfse...hp?articleid=6) maybe that would be the answer ??

  2. #2
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Aquarium Lighting project - PWM - Need some assistance as I'm rusty !

    OK I've re-written the code to use the multiple spwm routine produced by DT, but still can't get the delay working right.

    This is the routine that calculates the fade (or pause duration) for the dutycycle

    Code:
    Fade:
        Vb_1 = ((B_Day_On_H - B_Dawn_On_H)*60)       ' difference between day start and dawn start hour, converted to min
        Vb_2 = (B_Day_On_M - B_Dawn_On_M)            ' difference between day start and dawn start mins 
        Vb_5 = (Vb_1+Vb_2)*60                        ' Get total duration time in seconds
        Vb_6 = B_Max - B_Min                         ' Work out the 'distance' the lights go from min to max
        B_Fadein_Time = Vb_5 / Vb_6                  ' Get number of seconds between each PWM pulse
    Setting the dusk start time to 8:00 and the day on time to 8:05 I get the following results for the variables (B_Min = 0 and B_Max = 255) on the LCD

    Vb_5 = 600
    Vb_6 = 255
    B_Fadein_time = 2

    I then have the following statement which should increment the duty cycle until it reaches 255, with each cycle paused 2 seconds

    Code:
     case DAWN
    
        lcdout $FE,$94,"BLUE: DAWN "
        DutyCycle1 = DutyCycle1 +1
        pause B_Fadein_Time
        if DutyCycle1=B_Max then
        Blue_Day_Cycle = DAY
        endif
    However when run the duty cycle cycles from 0 to 255 so fast you can hardly notice it. Right, so the pause 2 statement is going to be too low, as pause 1000 equates to 1 second, so I multiplied the result by 1000 - the net result was too slow, it never reached 255 by the time the 5 minutes were up. Doing the maths I need to divide 600 seconds by 255 steps = 2.352941176470588. So I really need to convert this to a manageable number, say 2.353. ( B_Fadein_time is a word variable so should be able to store that result), and then convert this into seconds to use in the delay loop, but in a way that actually works !

    Assistance would be appeciated

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Aquarium Lighting project - PWM - Need some assistance as I'm rusty !

    Seems this place is not what it used to be... almost a 100 views and not one comment or suggestion.

  4. #4
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Aquarium Lighting project - PWM - Need some assistance as I'm rusty !

    This may be of little help but the upcoming FineLineIDE detected 3 unused labels:
    Ln 213 code_start:
    Ln 215 SetupPreset:
    Ln 463 MyTimer:

    Norm

  5. #5
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Aquarium Lighting project - PWM - Need some assistance as I'm rusty !

    Quote Originally Posted by Normnet View Post
    This may be of little help but the upcoming FineLineIDE detected 3 unused labels:
    Ln 213 code_start:
    Ln 215 SetupPreset:
    Ln 463 MyTimer:

    Norm
    Thanks for the comment, but as you say, not a lot of help. The first two simply are place makers... the latter is a routine that exists as a subroutine prior to the clock read routine and is referenced as part of the setup of the interrupts - I'll think I'll stick to Microcode Studio as my IDE ;-)

Similar Threads

  1. Weird PWM Behaviour on 16F1825
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th October 2012, 22:59
  2. More wood chuck lighting questions
    By AvionicsMaster1 in forum General
    Replies: 17
    Last Post: - 22nd January 2012, 05:45
  3. Triklits Microcontrolled Christmas Lighting
    By Homerclese in forum Off Topic
    Replies: 7
    Last Post: - 25th August 2008, 02:02
  4. DS1820 - Help I'm rusty !
    By malc-c in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 11th June 2008, 20:37
  5. Disco lighting controller - again
    By malc-c in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd January 2007, 00:25

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