Soldering station


Closed Thread
Results 1 to 38 of 38

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Hi,
    A fullblown PID is probably overkill but, for the record, incPID_mc is the multichannel version of the PID-filter. It works fine with a single channel but it takes a lot more codespace than the original incPID routine.

    You can find v1.5 of the single channel version in this post. And with THAT said it still won't fit the 12F675 due to the limited amount of RAM available in that device.

    What I'd do is probably something in the line of what Jerson showed but I'd also add a bias or feedforward based on the setpoint (not the error). If you know that in order to maintain a temperature of say 250°C you need a dutycycle of 40% then, once you're within the window of the regulator you enable the P(I) regulator and add the bias/feedforward to the output.

    You'll need to work out a suitable bias/feedforward "gain" since it's not going to be perfectly linear. Since the system (probably) heats up faster than it cools down and you can't have "negative drive" you should err on the low side for the bias/feedforward so that IT alone can never drive the temp OVER the setpoint. If it does the regulator can't bring it down since it can never go "below" 0% PWM.

    /Henrik.

    EDIT: The original version of incPID, which can be found i post 1 in the thread above, compiles to 314 words on the 12F675 and uses 29 bytes of RAM. Depending on how many bytes of RAM your application uses it MIGHT fit but again, it's probably not worth it.
    Last edited by HenrikOlsson; - 12th July 2011 at 18:57.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Quote Originally Posted by HenrikOlsson View Post
    Depending on how many bytes of RAM your application uses it MIGHT fit but again, it's probably not worth it.
    Hello Henrik,
    Probably not in Sweden or the USA, but in Romania, it might be very well worth it. Import tax is high there, wages not so much . . . Thanks for helping him.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Thanks to all for support !!! Glad to see people helping others...
    I will take attention to inc_PID, but ... now my code is 1002 words . The best (so far) solution it's to "upgrade" the PIC (maybe 18F...) but, for moment, I will try to keep this "low-cost variant".

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Try to compact your code. Maybe repeated code can be a subroutine etc.

    Also if you use flags, then declare them as BIT and not as BYTE or even worse as WORD.

    If you need a BYTE variable, do not declare as WORD.

    Ioannis

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Whitout "graphics elements" the code it's 659 words. Maybe it's a good start for use PID ?! (+314 words)
    Code:
    ' version 2
    @ DEVICE PIC12F675, intrc_osc_noclkout, wdt_off, mclr_off
    DEFINE OSC  4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    
    CMCON    = 7
    TRISIO   = %001001
    INTCON   = 0 
    GPIO     = 0
    
    ANSEL    = %00010001
    ADCON0   = %10000001
    wpu      = %00000010
     
                D_C      var     GPIO.2       
                SDIN     var     GPIO.4
                SCK      var     GPIO.5
                MOSFET   var     GPIO.1
              buton    var     GPIO.3
    
                LcdReg          var  byte        
                x               var  byte
                y               var  byte
                z               var  byte
                a               var  byte
                PosX            var  byte
                PosY            var  byte
                Chr             var  byte
                LcdData         var  byte
                Offset          var  byte
                Char            var  byte
                adval           var  word
                w1              var  word
              vt              var  word
              cnt             var  byte
                grup            var  word
                mode               var  byte
              calibra         var  word
              
                 
                DATA @0,$3E,$51,$49,$45,$3E,_       ';// 0                   
                        $00,$42,$7F,$40,$00,_       ';// 1
                        $42,$61,$51,$49,$46,_       ';// 2
                        $21,$41,$45,$4B,$31,_       ';// 3
                        $18,$14,$12,$7F,$10,_       ';// 4
                        $27,$45,$45,$45,$39,_       ';// 5
                        $3C,$4A,$49,$49,$30,_       ';// 6
                        $01,$71,$09,$05,$03,_       ';// 7
                        $36,$49,$49,$49,$36,_       ';// 8
                        $06,$49,$49,$29,$1E,_       ';// 9
                        $08,$08,$3E,$08,$08,_       ';// +
                        $08,$08,$08,$08,$08,_       ';// -
                        $00,$60,$60,$00,$00,_       ';// .
                        $00,$02,$05,$02,$00,_       ' grad
                        $3E,$41,$41,$41,$22,_       ' C
                        $7F,$02,$0C,$02,$7F,_       ' M     
                        $00,$00,$00,$00,$00,_       ' space
                     $08,$04,$7F,$04,$08,_       ' arrow up
                        $20,$40,$7F,$40,$20         ' arrow down
            
                              
               pause 500                 
               LcdReg  =  %00100001         'LCD Extended Commands.
               call    PrintCtrlLcd
               LcdReg  =  $E6               'Set LCD Vop (Contrast).Initial $C5
               call    PrintCtrlLcd
               LcdReg  =  %00000110         'Set Temp coefficent.
               call    PrintCtrlLcd
               LcdReg  =  %00010011         'LCD bias mode 1:48.
               call    PrintCtrlLcd
               LcdReg  =  %00100000         'LCD Standard Commands
               call    PrintCtrlLcd
               LcdReg  =  $0C               'LCD in normal mode.  $0D inverse
               call    PrintCtrlLcd                 
    Pause 100
    Call CursorHome
    Pause 100               
    Gosub LCD_Clear
    mode = 0
    Pause 500                ' time to give-up :) 
    '===================== READING VOLTAGE ==============================
    Main:
    low mosfet
     vt=0
     grup=0
         for cnt = 1 to 20
     ADCON0.1 = 1
     WHILE ADCON0.1 = 1 : WEND
     Pause 10
     adval.HighByte = ADRESH
     adval.LowByte = ADRESL
     PAUSE 10
         vt=adval * 500
         vt=div32 1023
         grup=vt+grup
     PAUSE 10
         next cnt
     w1=grup / 20
    
    '~~~~~~~~~~~~~~~~~ setting cursor for display the voltage
                    LcdReg  =  %10000000 + 25        ' cursor  X
                    call    PrintCtrlLcd
                    LcdReg  =  %01000011             ' cursor  Y
                    call    PrintCtrlLcd
    '~~~~~~~~~~~~~~~~~ now display results 
     if (w1 dig 2) <1 then
                    char = 16  
                    call Printchar
                    else         
                    Char = (w1 dig 2)            
                    call    PrintChar 
     endif      
    
    
                    Char = (w1 dig 1)           
                    call    PrintChar
    
     if (w1 dig 0) < 5 then            
                    Char = 0          
                    call    PrintChar  
            else
                    char = 5
                    call PrintChar
     endif                         
                    Char = 16                 
                    call    PrintChar
                
                    Char = 13
                    call  PrintChar
                   
                    Char = 14
                    call  PrintChar
    
                    
    if buton = 0 then 
    mode = mode + 1
    gosub memo
    endif
    
    
    gosub check
    Pause 100                
    Goto Main
    
    '================== L C D ===========================================                
    
    CursorHome:     LcdReg  =  %10000000            ' cursor Home
                    call    PrintCtrlLcd
                    LcdReg  =  %01000000            ' cursor Home
                    call    PrintCtrlLcd
                    return
    
    PrintChar:      offset = Char * 5          
                
                    for a = 1 to 5                
                        read offset, LcdReg
                        call  PrintDataLcd
                        offset = offset + 1
                    next a
                    LcdReg = 0
                    call    PrintDataLcd
                    return
                                        
    PrintCtrlLcd:   D_C = 0                             
    
    PrintDataLcd:   for x = 1 to 8                
                        SDIN = LcdReg.7              
                        SCK = 1
                        LcdReg = LcdReg << 1
                        SCK = 0
                    next x               
                    D_C = 1
                    return               
                    
    LCD_Clear:
                    PosX=0:PosY=0:Gosub LCD_GotoXY
                    D_C = 1
                    FOR Chr=1 TO 252
                        LcdData=0:Gosub LCD_ByteOut
                        LcdData=0:Gosub LCD_ByteOut
                    next Chr
                    return
    
    LCD_GotoXY:
                    D_C = 0
                    LcdData=%01000000 | PosY :Gosub LCD_ByteOut
                    LcdData=%10000000 | PosX :Gosub LCD_ByteOut
                    return
    
    LCD_ByteOut:
                    SHIFTOUT SDIN,SCK,1,[LcdData]
                    return  
    
    '===============================================================================
    memo:
    
    if mode = 1 then
     gosub poz
     char = 17
     call    PrintChar
    endif
    
    if mode = 2 then  
     gosub poz
     char = 15
     call    PrintChar
     calibra = vt
    endif
    
    if mode = 3 then 
     gosub poz
     char = 18
     call printchar
    endif
    
    if mode > 3 then 
      mode = 0
     gosub poz
     char = 16
     call printchar
    endif
    
    return
    '===============================================================================
    check:
    SELECT CASE  MODE
    CASE 1
    PWM MOSFET, 255, 300
    CASE 2
        if w1 < (calibra-1) then 
        pwm mosfet, 155, 200       'era 500
        else
        low mosfet 
        endif
    CASE 3
    LOW MOSFET
    END SELECT    
    return
    '===============================================================================
    Poz:
                    LcdReg  =  %10000000 + 67        ' cursor  X
                    call    PrintCtrlLcd
                    LcdReg  =  %01000011             ' cursor  Y
                    call    PrintCtrlLcd
    return
    '===============================================================================               
    
    End             'of program

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    You can still shave some bytes...

    - you don't need 2 spi routines LCD_ByteOut & PrintDataLcd,
    - replace the For-To-Next loop with Repeat-Until ones,
    - if at all possible, try to skip the div32.
    - use internal timer for delays (not sure it will that much though
    - pwm with a high/low loop maybe?
    - select case for a couple a if-then

    couples of ideas like that. sounds like a nice challenge
    Last edited by mister_e; - 13th July 2011 at 17:37.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Another thing about the graphic part, I've messed with it a lot recently and I saved a load of code space by skipping the whole SELCT-CASE + Lookup thing by using something like
    Code:
    SearchChar:
            read (index), char
            if char == TheCharYoureLookingFor then
                Gosub PrintIt
                index=endtable
                endif
            index=index+6
            if (index)<endtable then SearchChar
    But you need to modify a little bit the way your DATA lines are done.
    Code:
                DATA @0,"0",$3E,$51,$49,$45,$3E,_       ';// 0                   
                        "1",$00,$42,$7F,$40,$00,_       ';// 1
                        "2",$42,$61,$51,$49,$46,_       ';// 2
                        "3",$21,$41,$45,$4B,$31,_       ';// 3
                        "4",$18,$14,$12,$7F,$10,_       ';// 4
                        "5",$27,$45,$45,$45,$39,_       ';// 5
                        "6",$3C,$4A,$49,$49,$30,_       ';// 6
                        "7",$01,$71,$09,$05,$03,_       ';// 7
                        "8",$36,$49,$49,$49,$36,_       ';// 8
                        "9",$06,$49,$49,$29,$1E,_       ';// 9
                        "+",$08,$08,$3E,$08,$08,_       ';// +
                        "-",$08,$08,$08,$08,$08,_       ';// -
                        ".",$00,$60,$60,$00,$00,_       ';// .
                        "G",$00,$02,$05,$02,$00,_       ' grad
                        "C",$3E,$41,$41,$41,$22,_       ' C
                        "M",$7F,$02,$0C,$02,$7F,_       ' M     
                        " ",$00,$00,$00,$00,$00,_       ' space
                        "^",$08,$04,$7F,$04,$08,_       ' arrow up
                        "_",$20,$40,$7F,$40,$20         ' arrow down
    so when you want to display your grad character, just need to send G to that routine above. Simple... if it fits the EEPROM ...
    Steve

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

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Hi,
    314 words is the size when compiled by itself. Depending on what functions your code uses it might already have one or more of the PBP library routines included meaning the total size will be less than whatever + 314 words.

    But like I said, the problem in this case is likely the amount of available RAM. If my count is correct your code uses 23 bytes and the original incPID uses 29 bytes, then, if I'm not mistaken, PBP adds ~24 bytes for its internal use (might change depending on what library routines are used, I don't know for sure). All in all this adds up to more than the 64 bytes of RAM available on the 12F675.

    What I meant with not being worth it wasn't that you should throw a "bigger" PIC at the issue. I meant that I don't think the effort of implementing incPID is worth it considering the performance gain you might get compared to the aproaches already discussed. Sure, it it fits it's wort a try, if it doesn't fit I'd try to make do with what's available.

    Finally incPID was written in order to be versatile and easy to use. It's probably possible to reduce the size and amount of RAM needed further if adapting it to a specific application - but that's up to anyone using it to do.

    /Henrik.

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