Desoldeer Station Firmware

Download

'****************************************************************
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : Stijn Coenen (Elektronicastynus.be)               *
'*  Notice  : Copyright (c) 2013 Stijn Coenen                   *
'*          : All Rights Reserved                               *
'*  Date    : 17/12/2013                                        *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
Device = 16F1847

Config1 FOSC_INTOSC, WDTE_ON, PWRTE_ON, MCLRE_OFF, CP_ON, CPD_ON, BOREN_OFF, CLKOUTEN_OFF, IESO_ON, FCMEN_ON
Config2 WRT_OFF, PLLEN_OFF, STVREN_ON, BORV_HI, LVP_OFF

Xtal                  = 32       
All_Digital           = true   

OSCCON                = %11110000
WDTCON                = %00010111

'LEDs
    Symbol    LED_Rood    = LATA.2   
    Symbol    LED_Groen   = LATA.4
    Symbol    LED_Blauw   = LATA.3
    Dim       RoodFreq    As Byte
    Dim       RoodTeller  As Byte
    Dim       GroenFreq   As Byte   
    Dim       GroenTeller As Byte
    Dim       KnipVertr   As Byte
    
'Knoppen     
    Symbol    Btn_Up      = PORTA.6 
    Symbol    Btn_Down    = PORTA.7 
    Symbol    Btn_Enter   = PORTA.5  'PORTB.1 '   

'Triac's    
    Symbol    NetSens     = LATB.0 
    Symbol    Verwarming  = LATB.3
    Symbol    Solenoid    = LATB.6

'LCD     
    Symbol    PIN_SCE     = LATA.1 
    Symbol    PIN_RESET   = LATB.7
    Symbol    PIN_DC      = LATB.5
    Symbol    PIN_SDIN    = LATB.4
    Symbol    PIN_SCLK    = LATB.2
    
    Symbol    LCD_COMMAND = 0 
    Symbol    LCD_DATA    = 1
    Symbol    LCD_X       = 84
    Symbol    LCD_Y       = 48
    
    Dim       Data_or_Command As Bit
    Dim       LCD_Send_Data   As Byte
    Dim       LCD_Index       As Word  
    Dim       LCD_IndexX      As Byte  
    Dim       LCD_IndexY      As Byte
    Dim       Pos_X           As Byte
    Dim       Pos_Y           As Byte
    Dim       img_nr          As Byte
    Dim       Karakter        As Byte
    Dim       Tekst[30]       As Byte
    Dim       tekst_Lengte    As Byte
    Dim       Regel           As Byte  
    Dim       Positie         As Byte
    Dim       CharIndex       As Byte
    Dim       CharTemp        As Byte
    
'Faseaansnijding
    Dim       PWMWaarde       As Byte 
    Dim       PWMTeller       As Byte
    Dim       SinusHelft      As Byte  

'Temp regeling     
    Dim       SetPoint        As Word
    Dim       TempNow         As Word
   
    Dim       Error_now       As SWord          'Huidige fout
    Dim       Error_last      As SWord          'Fout laatste cyclus
    Dim       P               As SWord         'P    waarde
    Dim       I               As SWord         'I    waarde
    Dim       D               As SWord         'D    waarde        
    Dim       PID             As SWord         'PID  waarde
    Symbol    Kp              = 2    '15         'Proportionele actie
    Symbol    Ki              = 0'              'Integratietijd
    Symbol    Kd              = 1'5              'Differentiatietijd    
    
    Dim       StandbyTimer    As Dword
    Dim       StbBit          As Bit
    Dim       StandbyOn       As Bit
    Dim       DebounsSTB      As Byte
    Dim       StbTijd         As Byte
                                        
    Dim       AnaloogWord     As Word
    Dim       AnaloogFloat    As Float
    Dim       GemTeller       As Byte
    
    Declare Adin_Res      =  10     ' 10-bit result required  
    Declare Adin_Tad      =  FRC    ' RC OSC chosen  
    Declare Adin_Stime    =  50   ' Allow 50us sample time   
    
    FVRCON                = %11000001  '1.024V ref spanning

    ADCON1                = %10000011
    ANSELA                = %00000001
    ANSELB                = %00000000
                      

'Desoldeertimer                      
    Symbol    Btn_Bout        = PORTB.1
    Dim       MinTijd         As Byte
    Dim       MinTijdAct      As Bit 
    Dim       MinTmr1         As Byte 
    Dim       MinTmr2         As Byte
    Dim       DeSol           As Bit
    Dim       StijgBit        As Bit 
    
'Diverse        
    Dim       DelayIndex      As Byte  
    Dim       DelayIndex2     As Byte   
    Dim       DelayIndex3     As Byte
    Dim       MenuItem        As Byte
    Dim       TempVar         As Word

    EData     370, 5, 150, 0, 15
    '0 1 - 370    = insteltemp
    '2   - 5      = 5 sec min suction
    '3 4 - 0, 150 = standby temp (2 waardes voor woord)
    '5   - 15     = 15 min voordat standby ingaat
    
'Tris        76543210
    TRISA = %11100001
    LATA  = 0        
    TRISB = %00000011
    LATB  = 0   
    
    ADCON1.7 = 1
    
'Interrupt
    Symbol  INTF    = INTCON.1        'External Interrupt Flag 
    Symbol  T0IF    = INTCON.2        'TMR0 Overflow Interrupt Flag     
    Symbol  IOCIF   = INTCON.0
    Symbol  IOCBF1  = IOCBF.1
    Symbol  IOCIE   = INTCON.3
    On_Hardware_Interrupt GoTo IrInterrupt  
    
GoTo Init     
'****************************************************************
IrInterrupt:
    Context Save
    
       If INTF = 1 Then   
           INTF = 0                   
           Verwarming = 0
           PWMTeller  = 0 
           SinusHelft = 0    

           'Knipperleds
           Inc KnipVertr
           If KnipVertr = 10 Then 
              KnipVertr = 0
              
              Inc RoodTeller
              If RoodTeller > 4 Then RoodTeller = 0 
              
              If RoodFreq > RoodTeller Then 
                  LED_Rood = 1   
              Else
                  LED_Rood = 0  
              EndIf     
              
              Inc GroenTeller
              If GroenTeller > 4 Then GroenTeller = 0 
              
              If GroenFreq > GroenTeller Then 
                  LED_Groen = 1   
              Else
                  LED_Groen = 0  
              EndIf  
           EndIf 
           
           If DeSol = 1 Then
              If StandbyOn = 1 Then     
                  If Btn_Bout = 0 Then
                     DeSol = 0
                     StandbyOn = 0  
                     StandbyTimer = 0  
                     'Interrupt terug aan 
                     IOCIE = 0 
                     IOCBP = 2
                  EndIf                 
              Else
                  Solenoid = 1
                  LED_Blauw = 1
                  If StijgBit = 0 Then
                     MinTmr1 = MinTijd 
                     StijgBit = 1
                  EndIf    
                  Inc MinTmr2
                  If MinTmr2 = 50 Then
                      'Elke sec 
                      MinTmr2 = 0
                      If MinTmr1 > 0 Then
                         Dec MinTmr1   
                      EndIf              
                  EndIf
                  
                  'Uitschakelen?
                  If MinTmr1 = 0 And Btn_Bout = 0 Then
                     DeSol = 0   
                     Solenoid = 0  
                     LED_Blauw = 0
                     'Interrupt terug aan 
                     IOCIE = 0 
                     IOCBP = 2        
                     StijgBit = 0
                  EndIf          
              EndIf
           EndIf
                                       
       EndIf    
        
       If T0IF = 1 Then     
          T0IF = 0    'Timer overflow flag weer resetten
          TMR0 = 244
          Inc PWMTeller
          If PWMTeller = 101 Then
             PWMTeller = 0
             Inc SinusHelft
             Verwarming = 0  
          EndIf
          If SinusHelft < 3 Then
             If PWMTeller > (100 - PWMWaarde) Then
                Verwarming = 1
             EndIf
          EndIf       
       EndIf
       
       If IOCIF = 1 Then
          'Flaggen resetten
          IOCIF = 0
          IOCBF1 = 0  
          'Deze interrupt uit 
          IOCIE = 0 
          IOCBP = 0
          'Modus actief      
          DeSol = 1
       EndIf 
    Context Restore         
'****************************************************************
Init:
    Clear
    
    'LCD
    GoSub LCD_Init
    DelayMS 10    
    GoSub LCD_Clear    
   
    'Interrupt
                      '76543210
    INTCON          = %10111000
    PIE1            = %00000000
    PIE2            = %00000000
    OPTION_REG      = %00000101  
    IOCBP           = %00000010  
    IOCBN           = %00000000    
     
    'LCD opstartscherm
    img_nr = 0   
    GoSub LCD_Bitmap     
    
    'Temp regeling
    SetPoint = ERead 0
    MinTijd  = ERead 2
     
    DelayMS 500   
    Clrwdt            
    DelayMS 500   
    Clrwdt    
    
'SetPoint = 200
'****************************************************************
Main:    
    GoSub LCD_Clear
    
           'LED_Groen = ~ Btn_Down  
        'LED_Rood  = ~ Btn_Up
        'LED_Blauw = ~ Btn_Enter
        'LED_Blauw = ~LED_Blauw
         
          TempNow = 320
             
    While 1 = 1    
    
          GoSub ReadTemp
          GoSub Bereken_PID
         
          GoSub PrintTempBout
          GoSub PrintSettings  
          
          GoSub Standby 
    
          For DelayIndex = 0 To 4   
              If Btn_Up = 0 Then
                 Inc SetPoint    
                 GoSub PrintSettings 
                 'Nieuwe waarde in eeprom opslaan
                 EWrite 0, [SetPoint] 
                 StandbyTimer = 0
              EndIf
              If Btn_Down = 0 Then
                 Dec SetPoint  
                 GoSub PrintSettings  
                 'Nieuwe waarde in eeprom opslaan
                 EWrite 0, [SetPoint]  
                 StandbyTimer = 0
              EndIf     
              If Btn_Enter = 0 Then
                 GoSub Instellingen 
              EndIf        
              DelayMS 100          
          Next
    Wend
'****************************************************************
Standby:
    Inc StandbyTimer
    StbTijd = ERead 5
    If StandbyTimer = 60 * 2 * StbTijd Then  
       'Standby
       SetPoint = ERead 3
       StandbyOn = 1
       While StandbyOn = 1     
          GoSub ReadTemp
          GoSub Bereken_PID
          GoSub LCD_Clear
          If StbBit = 0 Then
             StbBit = 1   
             GoSub PrintTempBout
          Else
              StbBit = 0
          EndIf
          GoSub PrintSettings  
          For DelayIndex = 0 To 4   
              If Btn_Up = 0 Then
                 StandbyOn = 0
              EndIf
              If Btn_Down = 0 Then 
                 StandbyOn = 0
              EndIf    
              If Btn_Enter = 0 Then 
                 StandbyOn = 0
              EndIf          
              DelayMS 100          
          Next
       Wend
       SetPoint = ERead 0
       StandbyTimer = 0
    EndIf
Return  
'****************************************************************
Instellingen:          
    DelayMS 250   

    GoSub LCD_Clear  
    
    MenuItem = 0
    
    While 1 = 1     
      
        Regel = 1
        Positie = 1   
        StrN Tekst = "  Settings  "   
        GoSub LCD_PrintTekst  
        
        Regel = 3
        Positie = 2   
        StrN Tekst = "Stanby Time"   
        GoSub LCD_PrintTekst  
        
        Regel = 4
        Positie = 2  
        StrN Tekst = "Stanby temp"   
        GoSub LCD_PrintTekst  
        
        Regel = 5
        Positie = 2   
        StrN Tekst = "Min su time"   
        GoSub LCD_PrintTekst     
        
        Regel = 6
        Positie = 2   
        StrN Tekst = "Back"   
        GoSub LCD_PrintTekst  
    
    
        GoSub ReadTemp
        GoSub Bereken_PID
           
        For DelayIndex2 = 0 To 4   
              If Btn_Up = 0 Then
                 If MenuItem > 0 Then 
                    Dec MenuItem  
                 EndIf
              EndIf
              If Btn_Down = 0 Then
                 If MenuItem < 3 Then
                    Inc MenuItem
                 EndIf  
              EndIf     
              If Btn_Enter = 0 Then
                 Select MenuItem 
                     Case 0   
                          GoSub InstStandbyTime
                     Case 1    
                          GoSub InstStandbyTemp        
                     Case 2    
                          GoSub InstSucTime        
                     Case 3 
                          GoSub LCD_Clear    
                          Return
                 EndSelect  
                 While Btn_Enter = 0 
                       GoSub ReadTemp
                       GoSub Bereken_PID  
                       DelayMS 500  
                 Wend
              EndIf  
                   
              Select MenuItem
                  Case 0        
                     Regel = 3 : Positie = 1 : StrN Tekst = ">" : GoSub LCD_PrintTekst     
                     Regel = 4 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 5 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 6 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst 
                  Case 1        
                     Regel = 3 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 4 : Positie = 1 : StrN Tekst = ">" : GoSub LCD_PrintTekst     
                     Regel = 5 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst    
                     Regel = 6 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst    
                  Case 2        
                     Regel = 3 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 4 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 5 : Positie = 1 : StrN Tekst = ">" : GoSub LCD_PrintTekst     
                     Regel = 6 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst   
                  Case 3        
                     Regel = 3 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 4 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst     
                     Regel = 5 : Positie = 1 : StrN Tekst = "-" : GoSub LCD_PrintTekst    
                     Regel = 6 : Positie = 1 : StrN Tekst = ">" : GoSub LCD_PrintTekst 
                  Case Else
                     MenuItem = 0
              EndSelect   
                  
              DelayMS 100                   
                    
        Next
    Wend   
Return
'****************************************************************
InstStandbyTime:       
    GoSub LCD_Clear 
    Regel = 1 : Positie = 1 : StrN Tekst = "Standby Time" : GoSub LCD_PrintTekst 
    
    TempVar = ERead 5
    TempVar.HighByte = 0
    DelayMS 100
    While Btn_Enter = 0 : Wend
    
    While 1 = 1     
 
        GoSub ReadTemp
        GoSub Bereken_PID
           
        For DelayIndex3 = 0 To 4   
              Regel = 3 : Positie = 2 : StrN Tekst = Str$(Dec3 TempVar) : GoSub LCD_PrintTekst   
              Regel = 3 : Positie = 5 : StrN Tekst = " min" : GoSub LCD_PrintTekst 
              
              If Btn_Up = 0 Then 
                 If TempVar < 120 Then
                    Inc TempVar
                 EndIf     
              EndIf
              If Btn_Down = 0 Then    
                 If TempVar > 0 Then 
                    Dec TempVar  
                 EndIf
              EndIf     
              If Btn_Enter = 0 Then   
                 EWrite 5, [TempVar.LowByte]
                 GoSub LCD_Clear 
                 Return
              EndIf  
  
              DelayMS 100 

        Next
    Wend  
Return
'**************************************************************** 
InstStandbyTemp:      
    GoSub LCD_Clear 
    Regel = 1 : Positie = 1 : StrN Tekst = "Standby temp" : GoSub LCD_PrintTekst 
    
    TempVar = ERead 3 
    DelayMS 100
    While Btn_Enter = 0 : Wend
    
    While 1 = 1     
 
        GoSub ReadTemp
        GoSub Bereken_PID
           
        For DelayIndex3 = 0 To 4   
              Regel = 3 : Positie = 2 : StrN Tekst = Str$(Dec3 TempVar) : GoSub LCD_PrintTekst   
              Regel = 3 : Positie = 5 : StrN Tekst = "|C" : GoSub LCD_PrintTekst 
              
              If Btn_Up = 0 Then 
                 If TempVar < 450 Then
                    Inc TempVar
                 EndIf     
              EndIf
              If Btn_Down = 0 Then    
                 If TempVar > 90 Then 
                    Dec TempVar  
                 EndIf
              EndIf     
              If Btn_Enter = 0 Then   
                 EWrite 3, [TempVar]
                 GoSub LCD_Clear 
                 Return
              EndIf  
  
              DelayMS 100 

        Next
    Wend       
     
Return
'**************************************************************** 
InstSucTime:         
    GoSub LCD_Clear                           
    Regel = 1 : Positie = 1 : StrN Tekst = "Minimum" : GoSub LCD_PrintTekst                       
    Regel = 2 : Positie = 1 : StrN Tekst = "Suction Time" : GoSub LCD_PrintTekst  
    
    TempVar = ERead 2
    TempVar.HighByte = 0
    DelayMS 100
    While Btn_Enter = 0 : Wend
    
    While 1 = 1     
 
        GoSub ReadTemp
        GoSub Bereken_PID
           
        For DelayIndex3 = 0 To 4   
              Regel = 4 : Positie = 2 : StrN Tekst = Str$(Dec3 TempVar) : GoSub LCD_PrintTekst   
              Regel = 4 : Positie = 5 : StrN Tekst = " sec" : GoSub LCD_PrintTekst 
              
              If Btn_Up = 0 Then 
                 If TempVar < 60 Then
                    Inc TempVar
                 EndIf     
              EndIf
              If Btn_Down = 0 Then    
                 If TempVar > 0 Then 
                    Dec TempVar  
                 EndIf
              EndIf     
              If Btn_Enter = 0 Then   
                 EWrite 2, [TempVar.LowByte]
                 MinTijd = TempVar.LowByte 
                 GoSub LCD_Clear 
                 Return
              EndIf  
  
              DelayMS 100 

        Next
    Wend       
     
Return
'****************************************************************
ReadTemp:
    TempNow = 0
    For GemTeller   = 0 To 4
        AnaloogWord = ADIn 0
     '   Analoogfloat = AnaloogWord * (1.024/1024)
     '   AnaloogFloat = AnaloogFloat / 0.0095
     '   AnaloogFloat = (AnaloogFloat - 19.96) /0.113
        
     '   Gemiddelde = Gemiddelde * 3
    '    Gemiddelde = Gemiddelde - 223 + 50
    
        AnaloogFloat = AnaloogWord / 9.3 '9.5
        AnaloogFloat = (AnaloogFloat - 19.96) * 10  
        AnaloogFloat = AnaloogFloat / 0.85 '0.113

        TempNow    = TempNow + AnaloogFloat 'fround(AnaloogFloat)
    Next    
    TempNow = TempNow / 5    
'    TempNow = TempNow + 1           
'    If TempNow = 420 Then
'       TempNow = 300
'    EndIf 
Return                         
'****************************************************************
PrintSettings:
    'Insteltemp weergeven
    Regel = 5
    Positie = 1   
    StrN Tekst = "Setp :    |C"   
    Tekst[10] = "z" + 2
    GoSub LCD_PrintTekst         
    Regel = 5
    Positie = 8
    StrN Tekst = Str$(Dec3 SetPoint) 
    GoSub LCD_PrintTekst   
    
    'Outputpower weergeven          
    Regel = 6
    Positie = 1   
    StrN Tekst = "Power:    %"   
    GoSub LCD_PrintTekst               
    Regel = 6
    Positie = 8
    StrN Tekst = Str$(Dec3 PWMWaarde) 
    GoSub LCD_PrintTekst  
Return                 
'****************************************************************
PrintTempBout:   
    Regel = 0
    Positie = 18 + (16 * 0)
    Karakter = Dig TempNow, 2
    GoSub LCD_Arial_Cijfer 
    Positie = 18 + (16 * 1) + 1
    Karakter = Dig TempNow, 1
    GoSub LCD_Arial_Cijfer  
    Positie = 18 + (16 * 2) + 2
    Karakter = Dig TempNow, 0
    GoSub LCD_Arial_Cijfer
Return 
'****************************************************************
Bereken_PID:
    Error_now = SetPoint - TempNow      'De huidige fout berekeken

    If Error_now < 0 Then               'Als de fout kleiner is dan 0 (overshoot)
        P = 0                           'dan de P waarde 0 maken anders de P
    Else                                'waarde berekenen
        P = Kp * Error_now  
    EndIf
    I = I + (Ki * Error_now)            'I waarde berekenen
    D = Kd * (Error_now - Error_last)   'D waarde berekenen        
    Error_last = Error_now              'fout van nu in error_last zetten voor de 
                                        'volgende keer de D waarde te berekenen
    PID = P + I + D                     'P, I en D actie optellen             
    If PID > 100 Then 
       PWMWaarde = 100   'Als PID groter is dan 100 > 100 maken
    Else
        If PID < 0 Then 
            PWMWaarde = 0     'Als PID kleiner is dan 0 > 0 maken
        Else 
            PWMWaarde = PID
        EndIf
    EndIf     
    
    If Error_now > 15 Then
       RoodFreq = PWMWaarde / 25 + 1
       GroenFreq = 0
    Else
       If PWMWaarde > 0 Then
          GroenFreq = PWMWaarde / 25 + 1
       Else 
          GroenFreq = 0
       EndIf
       RoodFreq = 0
    EndIf 
    
    Clrwdt    
Return                             
'****************************************************************
LCD_gotoXY:  
    Data_or_Command = 0    
    Pos_X.7 = 1
    LCD_Send_Data = Pos_X  
    GoSub LCD_Write    
    Pos_Y.6 = 1   
    LCD_Send_Data = Pos_Y
    GoSub LCD_Write
Return  
'****************************************************************
LCD_Bitmap:            
    Data_or_Command = LCD_DATA
    For LCD_Index = 0 To ((LCD_X * (LCD_Y / 8)) -1) 
     LCD_Send_Data = LRead Afbeeldingen + (img_nr * (LCD_X * (LCD_Y / 8))) + LCD_Index
     GoSub LCD_Write   
    Next
Return        
'****************************************************************
LCD_Arial_Cijfer: 

  LCD_Index = 0
  
  For LCD_IndexX = 0 To 15' step - 1
  
      Pos_X = LCD_IndexX + Positie
      
      For LCD_IndexY = 0 To 2' step -1
      
          Pos_Y = LCD_IndexY + Regel 
          GoSub LCD_gotoXY                    
           
          LCD_Send_Data = LRead Cijfers + LCD_Index + (Karakter * 48)

          Inc LCD_Index 
                           
          Data_or_Command = LCD_DATA
          GoSub LCD_Write 
            
      Next             
  Next
Return 
'****************************************************************
LCD_Character:     
  Data_or_Command = LCD_DATA 
  LCD_Send_Data = $00 'Blank vertical line padding
  GoSub LCD_Write 
  
  For LCD_Index = 0 To 4   
      LCD_Send_Data = LRead ((Karakter - " ")*5) + Font_Table + LCD_Index      
      GoSub LCD_Write 
  Next   
                    
  LCD_Send_Data = $00    
  GoSub LCD_Write 
Return    
'****************************************************************
LCD_Clear:
  For LCD_Index = 0 To ((LCD_X * (LCD_Y / 8)) )     
     Data_or_Command = LCD_DATA
     LCD_Send_Data = $00
     GoSub LCD_Write
  Next   
     
  'After we Clear the display, Return To the home position
  Pos_X = 0
  Pos_Y = 0
  GoSub LCD_gotoXY
  
Return
'****************************************************************
LCD_Init:
     PIN_RESET = 0
     DelayMS 1
     PIN_RESET = 1
     
     
     Data_or_Command = LCD_COMMAND
     LCD_Send_Data = $21 'Tell LCD that extended commands follow
     GoSub LCD_Write
     LCD_Send_Data =  180 '170 '$A9'$B0 'Set LCD Vop (Contrast): Try 0xB1(good @ 3.3V) or 0xBF if your display is too dark    
     GoSub LCD_Write
     LCD_Send_Data = $02 'Set Temp coefficent            
     GoSub LCD_Write
     LCD_Send_Data = $14 'LCD bias mode 1:48: Try 0x13 or 0x14   
     GoSub LCD_Write

     LCD_Send_Data = $20 'We must send 0x20 before modifying the display control mode   
     GoSub LCD_Write
     LCD_Send_Data = $0C 'Set display control, normal mode. 0x0D for inverse    
     GoSub LCD_Write
     
Return
'****************************************************************
LCD_Write:
  PIN_DC = Data_or_Command
 
  PIN_SCE = 0
  SHOut PIN_SDIN, PIN_SCLK, MsbFirst, [LCD_Send_Data \ 8]  
  PIN_SCE = 1   
Return   
'****************************************************************
LCD_TekstPlaats:
  Pos_Y = (Regel - 1 ) * 9   
  Pos_X = (Positie - 1)  * 7
  GoSub LCD_gotoXY
Return
'****************************************************************
LCD_PrintTekst:
  GoSub LCD_TekstPlaats
  For CharIndex = 0 To 30  
      CharTemp = Tekst[CharIndex]
      Tekst[CharIndex] = 0
      If CharTemp > 31 And CharTemp < 127  Then   
         Karakter = CharTemp
         GoSub LCD_Character        
      Else
          Break
      EndIf
  Next    
Return
'****************************************************************
Include "5110_Font.inc"            
Include "5110_Images.inc"          
Include "5110_Arial_cijfers.inc"    
'****************************************************************  
End

Download