Soldering station


Closed Thread
Results 1 to 38 of 38
  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    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
    579


    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
    947


    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
    579


    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
    579


    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

  7. #7
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Looks good to me except I would make the first line this
    if w1 < calibra-hyst then high mosfet

  8. #8
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Because of "structure" of my code (see memo subroutine) , this procedure don't work ... I don't have anymore acces to "memory"... I must try a different way, but I have such little space.

  9. #9
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    A new, working fine too, version...
    Code:
    if buton = 0 then 
    mode = mode + 1
    gosub memo
    endif
    
    
    gosub check
    Pause 100                
    Goto Main
    and
    Code:
    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      
                 else
            low mosfet 
        endif
    CASE 3
    LOW MOSFET
    END SELECT
    Still have BIG thermal inertia of iron soldering (about 7-8 degree)...

  10. #10
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    where do you buy Nokia 3310 LCD displays?Can you put a link to the store?Thanks
    Do you use Solomon SL-10 soldering iron?

  11. #11
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Yes, I use Pensol SL10. The display it's from " people sell everything don't need anymore " ... about 1 euro.

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    FTR, Nokia 3310 or 5110 are basically the same. they use PCD8544 controller. Seems there's no longer a load of 1-2$ deal 'round here... probably because they are so popular
    Steve

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

  13. #13
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Quote Originally Posted by fratello View Post
    Yes, I use Pensol SL10. The display it's from " people sell everything don't need anymore " ... about 1 euro.
    Which program you use to make the "DIGITAL" text?Can you make a tutorial or something like that so I can learn something.
    I buy 3 Nokia 3310 mobile phones for 2euros.And now I have 8 of those in my lab

  14. #14
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    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.

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    probably http://en.radzio.dxp.pl/bitmap_converter/

    You draw you screen at the right size (84x48 pixels) in Photoshop, MsPaint (whatever floats your boat), save it as monochrome BMP, then import it in the software, generate the table, then import it in your code.

    EDIT: also check this out
    http://www.picbasic.co.uk/forum/cont...Nokia-3310-LCD
    Last edited by mister_e; - 12th July 2011 at 18:56.
    Steve

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

  16. #16
    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.

  17. #17
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    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".

  18. #18
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    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

  19. #19
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    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

  20. #20
    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.

  21. #21
    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.

  22. #22
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    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.

  23. #23
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    I'm sure there is something I am missing here but,
    Still have BIG thermal inertia of iron soldering (about 7-8 degree)...
    Do you think you can do better then this? Or need to? Now if its an excersize in learning and just the fun of doing it, well thats a great reason. But I would think the tip temp will cool that much if you just blow on the tip. but to raise it will take full power for a few seconds to get it back, then it will overshoot. Just my HO.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  24. #24
    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 cncmachineguy View Post
    I'm sure there is something I am missing here but,


    Do you think you can do better then this? Or need to? Now if its an exercise in learning and just the fun of doing it, well that's a great reason. But I would think the tip temp will cool that much if you just blow on the tip. but to raise it will take full power for a few seconds to get it back, then it will overshoot. Just my HO.
    Just so we are all playing on the same field . . . are we talking degrees C or degrees F ? I am guessing Centigrade so that's more like 13 or 14 Fahrenheit.
    Check out Robert's article:
    http://itech.fgcu.edu/faculty/zalews...PIDcontrol.pdf
    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.

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


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Sure enough, it's not Kelvin... just sayin
    Steve

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

  26. #26
    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 mister_e View Post
    Sure enough, it's not Kelvin... just sayin
    Hey! He (Kelvin) used to work for me . . .
    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.

  27. #27
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    I can hazard a guess that changing this section of code
    Code:
         vt=adval * 500      
                vt=div32 1023 
                grup=vt+grup  
                PAUSE 10
    to this
    vt=adval >> 1
    grup=vt+grup
    PAUSE 10
    might save you a bit of code & ram space. But, I've not checked this, so, you'll beware. Again, if you notice,
    I've used an approximation of divide by 2(500/1000) for 500/1023 instead of 1/2.046 I do not think it will matter much if you calibrate
    the readings.

  28. #28
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Wow ! Great support here ! Thanks to all !!!
    In first post You can see : the temperature it's in Celsius degrees. The PID control it's a verry good ideea; sure I will use in future projects !
    But...I try to do like Mr. Ioannis :
    Code:
    if w1 < (calibra - 5) then pwm mosfet 255, 300
    if w1 < (calibra - 3) then pwm mosfet 155, 250
    if w1 < (calibra - 1) then pwm mosfet 100, 200
    endif
    endif
    endif
    I think to reduce the "power" of heating by adjusting the pwm factors... It's OK ?!
    Last edited by fratello; - 14th July 2011 at 06:26.

  29. #29
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    1. On the above code you do not need the 3 endif.

    2. The credit is not for me. Maybe Jerson's?

    Ioannis

  30. #30
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station


  31. #31
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Oh, I see. OK, but take into account what I noted on the post.

    It is slow and may oscillate. I am sure it will. Also depending on the resolution, the dead band may be large. Of course the larger it is the less it will oscillate.

    Ioannis

  32. #32
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    I wrote this :
    Code:
    if w1 < (calibra - 3) then pwm mosfet 155, 250 
    if w1 < (calibra - 1) then pwm mosfet 100, 200
    but the heating start ONLY when w1 < (calibra - 3) !
    Why don't start when w1 < (calibra - 1) ?!?

  33. #33
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    And what is the value of w1 then?

    Ioannis

  34. #34
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Example : if calibra (value for memory, set by user) is 140, the heating start at 137.
    I wrote the routine for display those two values : w1 (current temperature) and calibra. The led blink ( PWM out) only when w1 < ( (calibra-3) !
    Code:
    if mode = 2 then
     call poz
     char = 16
     call    PrintChar  
     calibra = vt
                    LcdReg  =  %10000000 + 25        ' cursor  X
                    call    PrintCtrlLcd
                    LcdReg  =  %01000011 + 1         ' cursor  Y
                    call    PrintCtrlLcd
    '~~~~~~~~~~~~~~~~~ now display results 
     if (vt dig 2) <1 then
                    char = 16  
                    call Printchar
                    else         
                    Char = (vt dig 2)            
                    call    PrintChar 
     endif      
    
    
                    Char = (vt dig 1)           
                    call    PrintChar                     
     
                    Char = (vt dig 0)           
                    call    PrintChar
    
                    Char = 16                 
                    call    PrintChar
                
                    Char = 13
                    call  PrintChar
                   
                    Char = 14
                    call  PrintChar
    
                    Char = 16                 
                    call    PrintChar
    
                    Char = 15                 
                    call    PrintChar
    endif

  35. #35
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Fratello,can you make a code with MAX6675 thermocouple cold junction sensor?I have one,so I want to use it.

  36. #36
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    Hi! Why don't You write your own code ?!

  37. #37
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Post Re: Soldering station

    Quote Originally Posted by SKOLS1 View Post
    Fratello,can you make a code with MAX6675 thermocouple cold junction sensor?I have one,so I want to use it.

    Here, I'm familiar with the MAX6675 so I'll give you a start...

    This should read the MAX6675 and display degrees C & degrees F on a LCD display.
    (Pin aliases for LCD not shown, only for the MAX6675)

    Code:
    'Alias pins - MAX6675 temp sensor
    MXSCLK      var     PORTD.0   'MAX6675 Clock
    MXCS        var     PORTD.2   'MAX6675 Chip Select
    MXSO        Var     PORTD.3   'MAX6675 Serial Data
    
    '--Variables-----------------------
    kTemp       var     word    'raw data from MAX6675
    tempC       var     word    'temperature in degrees C
    tempF       var     word    'temp C converted to degrees F
    
    
    '-----------Read and display temperature from MAX6675-----------
    main:
        LOW MXCS                            'chip select low
        shiftin MXSO, MXSCLK, 0, [kTemp\16] 'shift in the data
        HIGH MXCS                           'chip select high
        tempC = kTemp >> 5                  'side shift to ditch the stuff to the right of the decimal point and just show whole degrees)  
        tempF = ((tempC * 18)/10) + 32      'convert C to F
            
       lcdout $fe,1,dec tempC," degrees C  ",$fe,$c0,dec tempF," degrees F  "   'display the data on LCD
    
       pause 500
       goto main
      
    end

  38. #38
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: Soldering station

    So it's possible to write code for 16F628A (16F648A), for example...since 12F675 don't have enough ports. And working with large fonts (if using Nokia LCD disply) , memory, pre-setting, etc...

Members who have read this thread : 1

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