Soldering station


Closed Thread
Results 1 to 38 of 38

Hybrid View

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

    Default Soldering station

    Using Pensol SL10, one cheap 12F675 and N3310 display, I made for myself this soldering station. Works fine, the mos-fet remains cool, but... I wonder if my code it's the better way to drive the mos-fet and keep most accurate temperature of iron ("pwm mosfet, 255, 300").
    Any advice it's wellcome ! Thanks in advance !
    Code:
    '===============================================================================
    '*                   Statie digitala de lipit, cu display de NOKIA 3310        *
    '*                 Digital solering station with N3310 display            *    
    '*                           by Dan Niculescu, june 2011                        *
    '===============================================================================
    
    @ 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
                i               var  byte
                 
                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
    
        Low D_C                                  'Command/Data
    
               pause 500                 
               LcdReg  =  %00100001         'LCD Extended Commands.
               call    PrintCtrlLcd
               LcdReg  =  $FF               '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
    call Borderline
    pause 50
     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  
    
    GotoXY:                
    LcdReg = %01000000 | Posy : call    PrintCtrlLcd    'Y
    LcdReg = %10000000 | Posx : call    PrintCtrlLcd    'X
    
    '===============================================================================
    memo:
    
    if mode = 1 then
     gosub poz
     char = 17
     call    PrintChar
     calibra = 4800
    endif
    
    if mode = 2 then  
     gosub poz
     char = 15
     call    PrintChar
     calibra = vt
    endif
    
    if mode = 3 then 
     gosub poz
     char = 18
     call printchar
     calibra = 10
    endif
    
    if mode > 3 then 
      mode = 0
     gosub poz
     char = 16
     call printchar
    endif
    
    return
    '===============================================================================
    check:
    if mode >= 1 then
        if w1 < (calibra-2) then  pwm mosfet, 255, 300       
        else
        low mosfet
    endif
    return
    '===============================================================================
    Poz:
                    LcdReg  =  %10000000 + 67        ' cursor  X
                    call    PrintCtrlLcd
                    LcdReg  =  %01000011             ' cursor  Y
                    call    PrintCtrlLcd
    return
    '===============================================================================               
    BorderLine:                          
    '=================================== RAW UP
          LcdReg  =  %10000000            ' cursor  X  
          call    PrintCtrlLcd
          LcdReg  =  %01000000            ' cursor  Y
          call    PrintCtrlLcd
          for y = 0 to 83                   
          LOokup y, [$FF,$01,$01,$01,$01,_
                     $01,$01,$01,$01,$01,$01,$01,$01,$01,$FD,$FD,$FD,$85,$85,$FD,$FD,$79,_        'D
                     $01,$01,$FD,$FD,$FD,$01,$01,$79,$FD,$FD,$85,$A5,$ED,$ED,$69,$01,$01,_        'IG
                     $FD,$FD,$FD,$01,$05,$05,$05,$FD,$FD,$FD,$05,$05,$05,$01,_                    'IT
                     $F9,$FD,$FD,$25,$25,$FD,$FD,$F9,$01,$01,$FD,$FD,$FD,$81,$81,$81,$81,_        'AL
                     $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$FF] ,LcdReg       
          call    PrintDataLcd
          next y
    '===================================  RAW 1 to 4                               
    for i= 1 to 4
    posx=0
    posy=i
    gosub GotoXY
                   lcdReg= $FF
                   call    PrintDataLcd
    next i
    
    for i = 1 to 4
    posx=83
    posy=i
    gosub GotoXY
                   lcdReg= $FF
                   call    PrintDataLcd
    next i   
    '===================================  RAW DOWN              
          LcdReg  =  %10000000           
          call    PrintCtrlLcd
          LcdReg  =  %01000101            
          call    PrintCtrlLcd
          for y = 0 to 83                   
          LOokup y, [$FF,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,_             
                   $80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,_          
                   $80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,_          
                   $80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,_          
                   $80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,$80,_          
                   $80,$80,$80,$80,$80,$80,$80,$80,$FF] ,LcdReg
          call    PrintDataLcd
          next y 
    Return
    
    '===============================================================================
    
    End             'of program
    Attached Images Attached Images      

  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

    Hi Fratello,
    You REALLY like those Nokia graphic LCD . . .
    I think they're pretty cool too, Now as for USEFUL comments . . . According to the engineer from France who writes the Dark Side column in Circuit Cellar, . . Robert La Coste ? his suggestion is to use a PID loop to give you some Hysteresis to your temperature to prevent overshoot and undershoot of tip temp. Search the forum there is a pretty good one or more in circulation.
    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 for advice !
    I found this : incPID_mc.pbp Author : Henrik Olsson. GREAT WORK !
    Unfortunately the code don't fit in my small 12F675 ; it's a solution to upgrade to a bigger PIC (18F2550 ?) but... for my small device it's another way ?!
    ...and yes, I like this display : it's verry cheap (about 1 euro) and easy to use. One 2x16 LCD display it's 6 euro and don't look so nice .

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    I can assume you're almost at the limits of the code space with your current code. The best option, I reckon, to get reasonably good control with your existing setup would be to try PI control. As it is, you are using the PWM function. Just compute the proportional output to get a smoother control.
    Modify your check routine so that the PWM function outputs 255 when far lower than the setpoint, 0 when at it. Now, to compensate the offset of the temperature, you add the integral correction over time. This can be achieved quite easily with integer math alone.

    A typical P controller pseudo code
    Band con 10 ' this decides the band around SetPoint in which you want proportional control

    if Temp < SetPoint-Band then
    PWMout = 255 ' full heat
    else
    if Temp > Setpoint+Band then
    PWMout = 0 ' full off
    else
    ' within band, do Proportional heating
    Error = SetPoint+Band-Temp ' you want to get the bigger numbers for temp < sv
    PWMout = (Error*255)/(2*Band) ' get an output from 255 to 0 over the band from SV-Band to SV+Band, 50% at SV
    endif
    endif

    Adding integral is relatively easy too. You just need a variable to adjust the error over time. Or use a button to snapshot the error and add it as an offset.

    IntErr var byte

    IntErr = IntErr+(Error/IntTime) ' integrate the error over time

    PWMout = PWMout + IntErr
    if PWMout > 255 then PWMout = 255 ' limit to usable PWM range

    PWM Mosfet, PWMout, 300 ' transfer to the mosfet

    Just some ideas.

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Thank You so much ! I try and I post the results.

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    I cannot run my simulation ( AMD Athlon64 X2 DualCore 4200+, 2 GB RAM ?!) ...
    It's this code OK ? Thanks !
    Code:
    hyst            CON  2
    check:
    if mode >= 1 then
        if w1 < calibra-hyst     then pwm mosfet, 255, 300
        if w1 > calibra+hyst     then low mosfet
        if w1 = calibra+hyst-w1 then pwm mosfet,(w1*255)/(2*hyst), 300
    endif
    return

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