MikroBasic to PBP Pro: Boost mode SMPS


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: MikroBasic to PBP Pro: Boost mode SMPS

    I'd be willing to learn about PID's. It's something I wanted to do anyway. Have you worked with them Ioannis?

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: MikroBasic to PBP Pro: Boost mode SMPS

    For something similar to what you try, but not succesfully. It just oscilated and could not fix it.

    I will try again, but am busy right now.

    Ioannis

  3. #3
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: MikroBasic to PBP Pro: Boost mode SMPS

    After some tweaking I have this pretty much working now. I can get it to ramp up slowly to full brightness, maintain a set level, be adjusted up and down, have the new value write to EEPROM and next time it is powered up it will ramp up to the last saved level. All I want to add now is ramp down at power off. Not a problem.

    I'd like to reduce code size though. I have a lot of IF THEN's and a lot of FOR NEXT's. They are used to increment and decrement a byte value based on which level output is set.

    Code:
     rampup:l = 0
    for l = 0 to led
    if L = 0 then 
    fb = 0
    CCP1CON = 0
    ramp = 0
    portc.2 = 0
    endif
    
    
    IF L = 1 then
    fb = 10
    endif
    
    
    if L = 2 then
    fb = 45
    endif
    
    
    if L = 3 then
    pause 25
    fb = 90
    endif
    
    
    if L = 4 then
    pause 40
    fb = 130
    endif
    
    
    IF L = 5 then
    pause 50
    fb = 170
    endif
    
    
    if L = 6 then
    pause 75
    fb = 280
    endif
    
    
    if L = 7 then
    pause 100
    fb = 450
    endif
    
    
    adcin 1, temp
    If temp > fb and L > 0 then
    ramp = ramp - 1
    IF ramp <= 0 then
    CCP1CON = 0
    ramp = 0
    portc.2 = 0
    endif
    endif
    If temp < fb Then
    ramp = ramp + 1
    If ramp >= 40 then 
    ramp = 40
    endif
    endif
    If ramp > 41 then
    ramp = 0
    endif
    
    
    CCP1CON = 111100
    PR2 = 44
    high_duty=(ramp>>2)        'high 6 bits in CCPR1L
          low_duty=(ramp<<6)         'low two bits for CCP1CON
          low_duty=(low_duty>>2)           'shift back to CCP1CON<5:4>
          low_duty.3=1                     'PWM configuration bit
          low_duty.2=1                     'PWM configuration bit
    CCPR1L=high_duty
    CCP1CON = $0C
    T2CON = 4
    
    
    pause 100
    next l
    goto main
    This is the ramp up routine that seems to work well. The ramp down is similar. Any way to reduce this block of code in size?

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