Guest User

Untitled

a guest
Jun 7th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '****************************************************************
  2. '*  Name    : UNTITLED.BAS                                      *
  3. '*  Author  : Alwin Winius                                      *
  4. '*  Notice  : Copyright (c)                                     *
  5. '*          : All Rights Reserved                               *
  6. '*  Date    : 8-11-2011                                         *
  7. '*  Version : 1.0                                               *
  8. '*  Notes   :                                                   *
  9. '*          :                                                   *
  10. '****************************************************************
  11. Device 16F690                ;We gebruiken een 16F690 type
  12. Config INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_ON, MCLRE_OFF, CP_OFF, CPD_OFF, BOR_OFF, IESO_OFF, FCMEN_OFF
  13.  
  14. All_Digital TRUE              ;Alle ingangen digitaal
  15.          ;76543210
  16. ADCON0 = %00000000
  17. ANSEL =  %00000000
  18. ANSELH = %00000000
  19. WPUA =   %00000000
  20. IOCA =   %00000000
  21.  
  22.         ;76543210
  23. TRISA = %00000111
  24. TRISB = %01010000
  25. TRISC = %00000111
  26.  
  27. Dim Status1 As Bit
  28. Dim Status2 As Bit
  29. Dim Status3 As Bit
  30. Dim Status4 As Bit
  31. Dim Status5 As Bit
  32. Dim Status6 As Bit
  33. Dim Status7 As Bit
  34. Dim Status8 As Bit
  35. Dim Status9 As Bit
  36. Dim Status10 As Bit
  37.  
  38. Dim Vertraging1 As Byte
  39. Vertraging1 = 50
  40.  
  41. Symbol Pallet_detectie1 = PORTA.0
  42. Symbol Pallet_rust1     = PORTA.1
  43. Symbol Pallet_vol1      = PORTA.2
  44. Symbol Inladen1         = PORTA.4
  45. Symbol Uitladen1        = PORTA.5
  46.  
  47. Symbol Pallet_detectie2 = PORTC.0
  48. Symbol Pallet_rust2     = PORTC.1
  49. Symbol Pallet_vol2      = PORTC.2
  50. Symbol Inladen2         = PORTC.4
  51. Symbol Uitladen2        = PORTC.5
  52.  
  53. Symbol Programswitch    = PORTB.6
  54.  
  55.  
  56.  
  57.  
  58. While 1 = 1
  59. ;/////////////////////////PROGRAM MAIN//////////////////////////////////////////
  60. Program_main:
  61.     If Programswitch = 1 Then                                         ;Als programmaswitch hoog is da programma laden uitvoeren. (pull up weerstand)
  62.         GoTo Program_laden
  63.     EndIf
  64.    
  65.     If Programswitch = 0 Then                                         ;Als programmaswitch laag is dan programma lossen uitvoeren. (gebruikerinput)
  66.         GoTo Program_lossen
  67.     EndIf
  68.  
  69. ;/////////////////////////PROGRAM LADEN BAND 1//////////////////////////////////
  70. Program_laden:
  71.  
  72.     Status1 = 0
  73.     Status2 = 0
  74.     Status3 = 0
  75.     Status4 = 0
  76.     Status5 = 0
  77.     Status6 = 0  
  78.  
  79. If Programswitch = 0 Then                                             ;Kijken of voorwaarde nog steeds actief is.
  80.     GoTo Program_main                                                 ;Indien voorwaarde veranderd is programma sluiten en terug naar programma lossen
  81. EndIf
  82.  
  83.   Repeat
  84.   If Pallet_detectie1 = 1 And Pallet_vol1 = 0 Then                    ;Inladen pallets starten
  85.     Low Inladen1
  86.     DelayMS Vertraging1
  87.     Status3 = 0  
  88.        
  89.   ElseIf Pallet_rust1 = 1 And Status1 = 0 Then                        ;stoppen pallets bij rust positie eerste pallet. (1 puls)
  90.     High Inladen1
  91.     DelayMS Vertraging1
  92.     Status1 = 1
  93.    
  94.   ElseIf Pallet_rust1 = 0 And Status1 = 1 And Status2 = 0 Then        ;puls 1 registreren.
  95.     Status2 = 1
  96.     DelayMS Vertraging1
  97.  
  98.   ElseIf Pallet_rust1 = 1 And Status2 = 1 Then                        ;puls 2 registreren.
  99.     Status2 = 0
  100.     Status3 = Status3 + 1
  101.     DelayMS Vertraging1
  102.  
  103.   ElseIf Status3 = 3 Then                                             ;stoppen pallets nadat 1 pallet reeds geladen is. (3 pulsen)
  104.     High Inladen1
  105.     Status3 = 0
  106.     DelayMS Vertraging1
  107.    
  108.   ElseIf Pallet_vol1 = 1 Then                                         ;stoppen lopende band bij band vol
  109.     High Inladen1
  110.     DelayMS Vertraging1
  111.   EndIf  
  112.  
  113.  
  114.  
  115. ;/////////////////////////PROGRAM LADEN BAND 1//////////////////////////////////  
  116.   If Pallet_detectie2 = 1 And Pallet_vol2 = 0 Then                  ;Inladen starten
  117.     Low Inladen2
  118.     DelayMS Vertraging1
  119.     Status6 = 0  
  120.        
  121.  
  122.   ElseIf Pallet_rust2 = 1 And Status4 = 0 Then                      ;stoppen pallets bij rust positie eerste lading. (1 puls)  
  123.     High Inladen2
  124.     DelayMS Vertraging1
  125.     Status4 = 1
  126.    
  127.   ElseIf Pallet_rust2 = 0 And Status4 = 1 And Status5 = 0 Then      ;puls 1 registrerem
  128.     Status2 = 1
  129.     DelayMS Vertraging1
  130.  
  131.   ElseIf Pallet_rust2 = 1 And Status5 = 1 Then                      ;Puls 2 registreren
  132.     Status5 = 0
  133.     Status6 = Status6 + 1
  134.     DelayMS Vertraging1
  135.  
  136.   ElseIf Status6 = 3 Then                                           ;stoppen pallets nadat 1 pallet reeds geladen is. (3 pulsen)
  137.     High Inladen2
  138.     Status6 = 0
  139.     DelayMS Vertraging1
  140.    
  141.   ElseIf Pallet_vol2 = 1 Then                                       ;stoppen lopende band bij band vol
  142.     High Inladen2
  143.     DelayMS Vertraging1
  144.   EndIf  
  145. Until Programswitch = 0                                             ;Programma uitvoeren tot programswitch is veranderd
  146.  
  147.  
  148. ;////////////////////////PROGRAM LOSSEN/////////////////////////////////////////
  149. Program_lossen:
  150.  
  151.     Status7 = 0
  152.     Status8 = 0
  153.     Status9 = 0
  154.     Status10 = 0
  155.  
  156. If PORTB.6 = 1 Then                                                 ;Kijken of voorwaarde nog steeds actief is.
  157.     GoTo Program_main                                               ;Indien voorwaarde veranderd is programma afsluiten en terug naar laden
  158. EndIf
  159.  
  160. Repeat
  161.  
  162. If Pallet_detectie1 = 0 And Status7 = 0 Then                        ;Pallets uitladen band starten.
  163.   Low Uitladen1
  164.   Status7 = 1
  165.   DelayMS Vertraging1
  166.  
  167. ElseIf Pallet_detectie1 = 1 And Status7 = 1 Then                    ;1ste puls registeren
  168.   Status7 = 0
  169.   Status8 = Status8 + 1
  170.   DelayMS Vertraging1
  171.  
  172. ElseIf Status8 = 2 Then                                             ;2de puls uitladen stoppen
  173.   High Uitladen1
  174.   DelayMS Vertraging1
  175.   Status8 = 0
  176.  
  177. EndIf
  178.  
  179. If Pallet_detectie2 = 0 And Status9 = 0 Then                        ;pallets uitladen, band starten.
  180.   Low Uitladen2
  181.   Status9 = 1
  182.   DelayMS Vertraging1
  183.  
  184. ElseIf Pallet_detectie2 = 1 And Status9 = 1 Then                    ;1ste puls registeren
  185.   Status9 = 0
  186.   Status10 = Status10 + 1
  187.   DelayMS Vertraging1
  188.  
  189. ElseIf Status10 = 2 Then                                            ;2de puls uitladen stoppen
  190.   High Uitladen2
  191.   DelayMS Vertraging1
  192.   Status10 = 0
  193.  
  194. EndIf
  195.  
  196. Until Programswitch = 1                                             ;Programma uitvoeren totdat programmaswitch veranderd.  
  197.  
  198. Wend                                                                ;Einde programma
  199.  
  200. End
Add Comment
Please, Sign In to add comment