Jak zmienić kod do obsługi 4 przekaźników.

Pytania, kody i porady dotyczące nie tylko Bascom.
Grzegorz2
Posty: 7
Rejestracja: 27 maja 2020, 22:01

Jak zmienić kod do obsługi 4 przekaźników.

Post autor: Grzegorz2 » 28 maja 2020, 6:50

Witam dopiero zaczynam przygodę z Bascom i mam problem chciałbym dodać do tego kodu obsługę ustawiania czasu czy jest możliwość dodania, czy pisać od nowa. Nowy program.
  1. $regfile = "m16adef.dat"                                    ' specify the used micro                             ' generated. Take care that the chip supports all fuse bytes.
  2. $crystal = 8000000
  3. $baud = 19200
  4.                                              ' used crystal frequency                  ' generated. Take care that the chip supports all fuse bytes.
  5.  
  6. Config Lcd = 16 * 2
  7. Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
  8. Config Pind.0 = Input
  9. Config Pinc.2 = Output
  10. Config Pinc.3 = Output
  11. Config Pinc.4 = Output
  12. Config Pinc.5 = Output
  13.  
  14.  
  15. Startknop Alias Pind.0
  16. Relais1 Alias Portc.2
  17. Relais2 Alias Portc.3
  18. Relais3 Alias Portc.4
  19. Relais4 Alias Portc.5
  20.  
  21.  
  22. Dim Compoort As String * 3
  23. Dim Klaar As Byte
  24. Dim Minute As Byte
  25. Dim Second As Byte
  26. Dim Vanity_once As Bit
  27. Dim Klepnummer As Byte
  28. Dim Multiplier As Byte
  29.  
  30. Declare Sub Rainmaker(byval Klepnummer As Byte , Byval Minute As Byte)
  31. Declare Sub Wacht_seconde
  32. Declare Sub Start_sequence
  33. Declare Sub Serial_input
  34. Declare Sub Reset_relays
  35. Declare Sub Set_zero
  36.  
  37. Hier:
  38. Vanity_once = 1
  39.     Klaar = 1
  40.    Do
  41.         If Vanity_once = 1 Then
  42.             Cls
  43.             Locate 1 , 1 : Lcd "COS TAM"                    'Tell the amased spectators what you do
  44.             Locate 2 , 3 : Lcd "COS TAM"
  45.         End If
  46.         Vanity_once = 0
  47.         If Startknop = 0 Then Start_sequence
  48.         Serial_input
  49.     Loop
  50.  
  51. Sub Serial_input
  52.     Compoort = Inkey()
  53.  
  54.         Select Case Compoort
  55.             Case "1"
  56.                     Set_zero
  57.                     Reset_relays
  58.                     Rainmaker 1 , 20
  59.             Case "2"
  60.                     Set_zero
  61.                     Reset_relays
  62.                     Rainmaker 2 , 20
  63.             Case "3"
  64.                     Set_zero
  65.                     Reset_relays
  66.                     Rainmaker 3 , 20
  67.             Case "4"
  68.                     Set_zero
  69.                     Reset_relays
  70.                     Rainmaker 4 , 20
  71.             Case "5"
  72.                     Start_sequence
  73.             Case "6"
  74.                     Goto Gestopt
  75.         End Select
  76.  
  77. End Sub
  78.  
  79.  
  80. Sub Start_sequence
  81.     Rainmaker 1 , 1                                         'open valve 1 for 20 minutes
  82.     Rainmaker 2 , 1                                         'open valve 2  ...
  83.     Rainmaker 3 , 1                                         'and so on
  84.     Rainmaker 4 , 1
  85. End Sub
  86.  
  87. Sub Rainmaker(byval Klepnummer As Byte , Byval Minute As Byte)
  88.     Compoort = ""
  89.     Second = 1
  90.     Cls
  91.     If Klepnummer < 1 Or Klepnummer > 5 Then Goto Gestopt
  92.     If Klepnummer = 1 Then Set Relais1
  93.     If Klepnummer = 2 Then Set Relais2
  94.     If Klepnummer = 3 Then Set Relais3
  95.     If Klepnummer = 4 Then Set Relais4
  96.  
  97.     Do
  98.         Second = Second - 1
  99.         If Second < 0 Then Goto Gestopt
  100.             Locate 1 , 1 : Lcd "Zawor"
  101.             Locate 1 , 6 : Lcd Klepnummer
  102.             Locate 1 , 8 : Lcd "otwarty"
  103.             Locate 2 , 1 : Lcd "Nadal"
  104.         If Minute > 9 Then Locate 2 , 5 : Lcd Minute
  105.         If Minute < 10 Then
  106.             Locate 2 , 4 : Lcd " "
  107.             Locate 2 , 5 : Lcd "0"
  108.             Locate 2 , 6 : Lcd Minute
  109.         End If
  110.         Locate 2 , 7 : Lcd ":"
  111.         If Second > 9 Then Locate 2 , 8 : Lcd Second
  112.         If Second < 10 Then
  113.             Locate 2 , 8 : Lcd "0"
  114.             Locate 2 , 9 : Lcd Second
  115.         End If
  116.         Locate 2 , 11 : Lcd "Min."
  117.         Klaar = Second + Minute
  118.  
  119.         If Second = 0 Then Minute = Minute - 1
  120.         If Second = 0 Then Second = 60
  121.  
  122.         Multiplier = 100
  123.         Do
  124.             Decr Multiplier
  125.             Waitus 9550                                     '100 x 10000us = 1 second   <-- this number makes 1 sec
  126.         Loop Until Multiplier = 0
  127.         Serial_input
  128.         If Startknop = 0 Then Goto Gestopt                  'stop op nogmaals startknop drukken
  129.     Loop Until Klaar = 0
  130.         Reset_relays
  131.         Vanity_once = 1
  132. End Sub
  133.  
  134. Gestopt:
  135.     Cls
  136.     Set_zero
  137.     Reset_relays
  138.     Locate 1 , 5 : Lcd "STOP!"
  139.     Wait 3
  140.  
  141. Goto Hier
  142.  
  143. Sub Reset_relays
  144.     Reset Relais1
  145.     Reset Relais2
  146.     Reset Relais3
  147.     Reset Relais4
  148. End Sub
  149.  
  150. Sub Set_zero
  151.     Compoort = "0"
  152.     Klepnummer = 0
  153.     Second = 0
  154.     Minute = 0
  155.     Klaar = 0
  156. End Sub
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: niveasoft » 28 maja 2020, 7:03

To chyba nieskomplikowane. Widać że to program do jakiegoś zraszacza z czterema wyjściami sterowany poprzez SerialPort i ma jeden przycisk Start.
Można włączyć każde z wyjść na stałą wartość czasu 20min lub przyciskiem wszystkie na raz na 1min.

Teraz pytanie czy chcesz czasem sterować przyciskami czy poprzez SerialPort? Przyciski pewnie musiałbyś dodać,ale to pewnie nie problem.
Dodaj dwa przyciski i jedną zmienną. Klikając góra dół zmniejszysz ją lub zwiekszysz a potem odpalajac zdalnie wyjście zamiast sztywno ustawionych 20min przekazujesz wartość zmiennej i program gotowy.
Na koniec można dodać obsługę poprzez SerialPort. Program, na razie, wykorzystuje z klawiatury komputera cyfry od 1 do 6. Możesz dopisać kod że jak otrzyma np, 7 to zmniejsza tę zmienną czasową i nawet zwraca potwierdzenie "Ok now time period is "; Zmienna. Tak samo gdy otrzyma 8 to zwiekszy i potwierdzi.

Wszystko wydaje sie bardzo proste ;)
Grzegorz2
Posty: 7
Rejestracja: 27 maja 2020, 22:01

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: Grzegorz2 » 28 maja 2020, 7:38

Chciałbym sterować przyciskami.
Dopisanie przycisków to nie problem, zwiększanie czasu może być co minute.
Tylko jak się zabrać za te zmienne i dalej.
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: niveasoft » 28 maja 2020, 7:56

Łap na zachętę, ale następnym razem tak łatwo nie będzie. Widziałem Cię chyba na Elektrodzie. Musisz trochę poczytać. Na przykład Helpa. Jest też po polsku ale trochę stary. Na Twoim poziomie wystarczy.

W programie dodałem dwa przyciski na PD1 i PD2. Zmieniają domyślny czas 20min na 10min - 30min. Dodatkowo czas jest wyświetlany na LCD.
Zmieniają zmienną Minuty i potem ta zmienna jest przekazywana jako czas do kolejnego Sub zamiast oryginalnych 20min.
Dodałem tez dyrektywę $projecttime która mierzy czas spędzony nad kodem. Jak widać zmiany zajęły mi 10minut :D
  1.     $regfile = "m16adef.dat"                                    ' specify the used micro                             ' generated. Take care that the chip supports all fuse bytes.
  2.     $crystal = 8000000
  3.     $baud = 19200
  4.  
  5. $projecttime = 10
  6.  
  7.     Config Lcd = 16x2
  8.     Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
  9.     Config Pind.0 = Input
  10.     Config Pinc.2 = Output
  11.     Config Pinc.3 = Output
  12.     Config Pinc.4 = Output
  13.     Config Pinc.5 = Output
  14.  
  15.  
  16.     Startknop Alias Pind.0
  17.     Relais1 Alias Portc.2
  18.     Relais2 Alias Portc.3
  19.     Relais3 Alias Portc.4
  20.     Relais4 Alias Portc.5
  21.  
  22.     Sw_plus Alias Pind.1 : Set Portd.1
  23.     Sw_minus Alias Pind.2 : Set Portd.2
  24.  
  25.  
  26.  
  27.     Dim Compoort As String * 3
  28.     Dim Klaar As Byte
  29.     Dim Minute As Byte
  30.     Dim Second As Byte
  31.     Dim Vanity_once As Bit
  32.     Dim Klepnummer As Byte
  33.     Dim Multiplier As Byte
  34.  
  35.     Dim Minuty As Byte , Timestr As String * 2
  36.  
  37.  
  38.     Declare Sub Rainmaker(byval Klepnummer As Byte , Byval Minute As Byte)
  39.     Declare Sub Wacht_seconde
  40.     Declare Sub Start_sequence
  41.     Declare Sub Serial_input
  42.     Declare Sub Reset_relays
  43.     Declare Sub Set_zero
  44.     Declare Sub Format_time
  45.  
  46.     Hier:
  47.     Vanity_once = 1
  48.         Klaar = 1
  49.  
  50.     Minuty = 20
  51.     Call Format_time()
  52.  
  53.        Do
  54.             If Vanity_once = 1 Then
  55.                 Cls
  56.                 Locate 1 , 1 : Lcd "COS TAM"                    'Tell the amased spectators what you do
  57.                 Locate 2 , 3 : Lcd "COS TAM"
  58.                 Locate 1 , 14 : Lcd Timestr
  59.             End If
  60.             Vanity_once = 0
  61.             If Startknop = 0 Then Start_sequence
  62.             Serial_input
  63.          Debounce Sw_plus , 0 , Plus_sub , Sub
  64.          Debounce Sw_minus , 0 , Minus_sub , Sub
  65.         Loop
  66.  
  67.     Sub Serial_input
  68.         Compoort = Inkey()
  69.  
  70.             Select Case Compoort
  71.                 Case "1"
  72.                         Set_zero
  73.                         Reset_relays
  74.                         Rainmaker 1 , Minuty
  75.                 Case "2"
  76.                         Set_zero
  77.                         Reset_relays
  78.                         Rainmaker 2 , Minuty
  79.                 Case "3"
  80.                         Set_zero
  81.                         Reset_relays
  82.                         Rainmaker 3 , Minuty
  83.                 Case "4"
  84.                         Set_zero
  85.                         Reset_relays
  86.                         Rainmaker 4 , Minuty
  87.                 Case "5"
  88.                         Start_sequence
  89.                 Case "6"
  90.                         Goto Gestopt
  91.             End Select
  92.  
  93.     End Sub
  94.  
  95.  
  96.     Sub Start_sequence
  97.         Rainmaker 1 , 1                                         'open valve 1 for 20 minutes
  98.         Rainmaker 2 , 1                                         'open valve 2  ...
  99.         Rainmaker 3 , 1                                         'and so on
  100.         Rainmaker 4 , 1
  101.     End Sub
  102.  
  103.     Sub Rainmaker(byval Klepnummer As Byte , Byval Minute As Byte)
  104.         Compoort = ""
  105.         Second = 1
  106.         Cls
  107.         If Klepnummer < 1 Or Klepnummer > 5 Then Goto Gestopt
  108.         If Klepnummer = 1 Then Set Relais1
  109.         If Klepnummer = 2 Then Set Relais2
  110.         If Klepnummer = 3 Then Set Relais3
  111.         If Klepnummer = 4 Then Set Relais4
  112.  
  113.         Do
  114.             Second = Second - 1
  115.             If Second < 0 Then Goto Gestopt
  116.                 Locate 1 , 1 : Lcd "Zawor"
  117.                 Locate 1 , 6 : Lcd Klepnummer
  118.                 Locate 1 , 8 : Lcd "otwarty"
  119.                 Locate 2 , 1 : Lcd "Nadal"
  120.             If Minute > 9 Then Locate 2 , 5 : Lcd Minute
  121.             If Minute < 10 Then
  122.                 Locate 2 , 4 : Lcd " "
  123.                 Locate 2 , 5 : Lcd "0"
  124.                 Locate 2 , 6 : Lcd Minute
  125.             End If
  126.             Locate 2 , 7 : Lcd ":"
  127.             If Second > 9 Then Locate 2 , 8 : Lcd Second
  128.             If Second < 10 Then
  129.                 Locate 2 , 8 : Lcd "0"
  130.                 Locate 2 , 9 : Lcd Second
  131.             End If
  132.             Locate 2 , 11 : Lcd "Min."
  133.             Klaar = Second + Minute
  134.  
  135.             If Second = 0 Then Minute = Minute - 1
  136.             If Second = 0 Then Second = 60
  137.  
  138.             Multiplier = 100
  139.             Do
  140.                 Decr Multiplier
  141.                 Waitus 9550                                     '100 x 10000us = 1 second   <-- this number makes 1 sec
  142.             Loop Until Multiplier = 0
  143.             Serial_input
  144.             If Startknop = 0 Then Goto Gestopt                  'stop op nogmaals startknop drukken
  145.         Loop Until Klaar = 0
  146.             Reset_relays
  147.             Vanity_once = 1
  148.     End Sub
  149.  
  150.     Gestopt:
  151.         Cls
  152.         Set_zero
  153.         Reset_relays
  154.         Locate 1 , 5 : Lcd "STOP!"
  155.         Wait 3
  156.  
  157.     Goto Hier
  158.  
  159.     Sub Reset_relays
  160.         Reset Relais1
  161.         Reset Relais2
  162.         Reset Relais3
  163.         Reset Relais4
  164.     End Sub
  165.  
  166.     Sub Set_zero
  167.         Compoort = "0"
  168.         Klepnummer = 0
  169.         Second = 0
  170.         Minute = 0
  171.         Klaar = 0
  172.     End Sub
  173.  
  174.     Plus_sub:
  175.      If Minuty < 30 Then Incr Minuty
  176.      Call Format_time()
  177.     Return
  178.  
  179.     Minus_sub:
  180.      If Minuty > 10 Then Decr Minuty
  181.      Call Format_time
  182.     Return
  183.  
  184.     Sub Format_time
  185.      Timestr = Str(minuty)
  186.      Timestr = Format(timestr , "00")
  187.     End Sub
Grzegorz2
Posty: 7
Rejestracja: 27 maja 2020, 22:01

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: Grzegorz2 » 28 maja 2020, 8:14

Ok.
Po pracy będę testował.
I porównywał stary do nowego.
Jak się umie pisać w Bascom to zajmuje to chwilkę ale dla zielonego to miesiąc.
Grzegorz2
Posty: 7
Rejestracja: 27 maja 2020, 22:01

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: Grzegorz2 » 29 maja 2020, 21:35

Witam jestem po próbach ale ustawianie przyciskami nie dzała.
  1. $regfile = "m16adef.dat"              ' specify the used micro                             ' generated. Take care that the chip supports all fuse bytes.
  2.     $crystal = 8000000
  3.     $baud = 19200
  4.  
  5. $projecttime = 33
  6.  
  7.     Config Lcd = 16 * 2
  8.     Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
  9.     Config Pind.0 = Input
  10.     Config Pina.2 = Input
  11.     Config Pina.3 = Input
  12.     Config Pinc.2 = Output
  13.     Config Pinc.3 = Output
  14.     Config Pinc.4 = Output
  15.     Config Pinc.5 = Output
  16.     '$sim
  17.  
  18.     Startknop Alias Pind.0
  19.     Relais1 Alias Portc.2
  20.     Relais2 Alias Portc.3
  21.     Relais3 Alias Portc.4
  22.     Relais4 Alias Portc.5
  23.  
  24.     Sw_plus Alias Pina.2 : Set Porta.2                      
  25.     Sw_minus Alias Pina.3 : Set Porta.3                    
  26.  
  27.  
  28.  
  29.     Dim Compoort As String * 3
  30.     Dim Klaar As Byte
  31.     Dim Minute As Byte
  32.     Dim Second As Byte
  33.     Dim Vanity_once As Bit
  34.     Dim Klepnummer As Byte
  35.     Dim Multiplier As Byte
  36.  
  37.     Dim Minuty As Byte , Timestr As String * 2
  38.  
  39.  
  40.     Declare Sub Rainmaker(byval Klepnummer As Byte , Byval Minute As Byte)
  41.     Declare Sub Wacht_seconde
  42.     Declare Sub Start_sequence
  43.     Declare Sub Serial_input
  44.     Declare Sub Reset_relays
  45.     Declare Sub Set_zero
  46.     Declare Sub Format_time
  47.  
  48.     Hier:
  49.     Vanity_once = 1
  50.         Klaar = 1
  51.  
  52.     Minuty = 20
  53.     Call Format_time()
  54.  
  55.  
  56.        Do
  57.             If Vanity_once = 1 Then
  58.                 Cls
  59.                 Locate 1 , 1 : Lcd "COS TAM"                'Tell the amased spectators what you do
  60.                 Locate 2 , 3 : Lcd "COS TAM"
  61.                 Locate 1 , 14 : Lcd Timestr
  62.  
  63.             End If
  64.             Vanity_once = 0
  65.  
  66.  
  67.             If Startknop = 0 Then Start_sequence
  68.             Serial_input
  69.          Debounce Sw_plus , 0 , Plus_sub , Sub
  70.          Debounce Sw_minus , 0 , Minus_sub , Sub
  71.         Loop
  72.  
  73.  
  74.     Sub Serial_input
  75.         Compoort = Inkey()
  76.  
  77.             Select Case Compoort
  78.                 Case "1"
  79.                         Set_zero
  80.                         Reset_relays
  81.                         Rainmaker 1 , Minuty
  82.                 Case "2"
  83.                         Set_zero
  84.                         Reset_relays
  85.                         Rainmaker 2 , Minuty
  86.                 Case "3"
  87.                         Set_zero
  88.                         Reset_relays
  89.                         Rainmaker 3 , Minuty
  90.                 Case "4"
  91.                         Set_zero
  92.                         Reset_relays
  93.                         Rainmaker 4 , Minuty
  94.                 Case "5"
  95.                         Start_sequence
  96.                 Case "6"
  97.                         Goto Gestopt
  98.             End Select
  99.  
  100.     End Sub
  101.  
  102.  
  103.     Sub Start_sequence
  104.         Rainmaker 1 , 1                                     'open valve 1 for 20 minutes
  105.         Rainmaker 2 , 1                                     'open valve 2  ...
  106.         Rainmaker 3 , 1                                     'and so on
  107.         Rainmaker 4 , 1
  108.     End Sub
  109.  
  110.     Sub Rainmaker(byval Klepnummer As Byte , Byval Minute As Byte)
  111.         Compoort = ""
  112.         Second = 1
  113.         Cls
  114.         If Klepnummer < 1 Or Klepnummer > 5 Then Goto Gestopt
  115.         If Klepnummer = 1 Then Set Relais1
  116.         If Klepnummer = 2 Then Set Relais2
  117.         If Klepnummer = 3 Then Set Relais3
  118.         If Klepnummer = 4 Then Set Relais4
  119.  
  120.         Do
  121.             Second = Second - 1
  122.             If Second < 0 Then Goto Gestopt
  123.                 Locate 1 , 1 : Lcd "Zawor"
  124.                 Locate 1 , 6 : Lcd Klepnummer
  125.                 Locate 1 , 8 : Lcd "otwarty"
  126.                 Locate 2 , 1 : Lcd "Nadal"
  127.             If Minute > 9 Then Locate 2 , 5 : Lcd Minute
  128.             If Minute < 10 Then
  129.                 Locate 2 , 4 : Lcd " "
  130.                 Locate 2 , 5 : Lcd "0"
  131.                 Locate 2 , 6 : Lcd Minute
  132.             End If
  133.             Locate 2 , 7 : Lcd ":"
  134.             If Second > 9 Then Locate 2 , 8 : Lcd Second
  135.             If Second < 10 Then
  136.                 Locate 2 , 8 : Lcd "0"
  137.                 Locate 2 , 9 : Lcd Second
  138.             End If
  139.             Locate 2 , 11 : Lcd "Min."
  140.             Klaar = Second + Minute
  141.  
  142.             If Second = 0 Then Minute = Minute - 1
  143.             If Second = 0 Then Second = 60
  144.  
  145.             Multiplier = 100
  146.             Do
  147.                 Decr Multiplier
  148.                 Waitus 9550                                 '100 x 10000us = 1 second   <-- this number makes 1 sec
  149.             Loop Until Multiplier = 0
  150.             Serial_input
  151.             If Startknop = 0 Then Goto Gestopt              'stop op nogmaals startknop drukken
  152.         Loop Until Klaar = 0
  153.             Reset_relays
  154.             Vanity_once = 1
  155.     End Sub
  156.  
  157.  
  158.  
  159.     Gestopt:
  160.         Cls
  161.         Set_zero
  162.         Reset_relays
  163.         Locate 1 , 5 : Lcd "STOP!"
  164.         Wait 3
  165.  
  166.     Goto Hier
  167.  
  168.     Sub Reset_relays
  169.         Reset Relais1
  170.         Reset Relais2
  171.         Reset Relais3
  172.         Reset Relais4
  173.     End Sub
  174.  
  175.     Sub Set_zero
  176.         Compoort = "0"
  177.         Klepnummer = 0
  178.         Second = 0
  179.         Minute = 0
  180.         Klaar = 0
  181.     End Sub
  182.  
  183.    Plus_sub:
  184.      If Minuty < 30 Then Incr Minuty
  185.      Call Format_time()
  186.     Return
  187.  
  188.     Minus_sub:
  189.      If Minuty > 10 Then Decr Minuty
  190.      Call Format_time
  191.     Return
  192.  
  193.     Sub Format_time
  194.      Timestr = Str(minuty)
  195.      Timestr = Format(timestr , "00")
  196.      Return
  197.  
  198.  
  199.     End Sub
Grzegorz2
Posty: 7
Rejestracja: 27 maja 2020, 22:01

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: Grzegorz2 » 30 maja 2020, 17:32

Witam sam program do ustawiania czasu przyciskami działa ale coś jest nie tak bo z resztom programu już nie działa.
  1.  $crystal = 8000000
  2.     $baud = 19200
  3.     Config Lcd = 16 * 2
  4.     Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7 , E = Portb.3 , Rs = Portb.2
  5.     Config Pind.0 = Input
  6.     Config Pind.1 = Input
  7.     Config Pind.2 = Input
  8.  
  9.     Sw_plus Alias Pind.1 : Set Portd.1
  10.     Sw_minus Alias Pind.2 : Set Portd.2
  11.  
  12.       Dim Minuty As Byte , Timestr As String * 2
  13.       Declare Sub Format_time
  14.  
  15.  
  16.       Minuty = 20
  17.     Call Format_time()
  18.     Do
  19.  
  20.       Locate 1 , 14 : Lcd Timestr
  21.  
  22.        Debounce Sw_plus , 0 , Plus_sub , Sub
  23.          Debounce Sw_minus , 0 , Minus_sub , Sub
  24.  
  25.       Loop
  26.  
  27.              Plus_sub:
  28.      If Minuty < 40 Then Incr Minuty
  29.      Call Format_time()
  30.     Return
  31.  
  32.     Minus_sub:
  33.      If Minuty > 10 Then Decr Minuty
  34.      Call Format_time
  35.     Return
  36.  
  37.     Sub Format_time
  38.      Timestr = Str(minuty)
  39.      Timestr = Format(timestr , "00")
  40.     End Sub
Awatar użytkownika
niveasoft
Posty: 1216
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: niveasoft » 01 cze 2020, 8:06

W tych subach Plus i Minus dopisz "Vanity_once = 1" żeby odświeżyło wyświetlacz. W moich programach ta zmienna nazywa się "Refresh".
Grzegorz2
Posty: 7
Rejestracja: 27 maja 2020, 22:01

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: Grzegorz2 » 04 cze 2020, 20:00

Problem rozwiązany ale mam następny bo gdy dodam CLS to mam przygaszony wyswietlacz a gdy nie mam CLS to mieszają sie dwa napisy z tym końcowym.
  1.  Cursor Off
  2.  
  3.  
  4.        Do
  5.            If Vanity_once = 1 Then
  6.                 Cls
  7.                 Locate 1 , 1
  8.                 Lcd "STEROWNIK"
  9.                 Locate 2 , 3
  10.                 Lcd "13 sekcji"
  11.                 Locate 1 , 14
  12.                 Lcd Timestr
  13.                 End If
marekszy
Posty: 99
Rejestracja: 20 lis 2016, 20:21

Re: Jak zmienić kod do obsługi 4 przekaźników.

Post autor: marekszy » 04 cze 2020, 20:06

Dołóż kilka spacji do napisu i wyczyści resztę wyswietlacza
ODPOWIEDZ