Witam, naskrobałem kawałek programu obsługującego sterownik - monitor transformatora wysokiego napięcia. Jest to popularny pastuch ogrodzeń pastwiskowych. Otóż wszystko działa jak należy poza jedynym faktem że nie potrafię wplątać do tego programu trzech klawiszy za pomocą których mógłbym zmieniać na starcie parametry. Oto co chciałbym wprowadzić w ten poniższy program. Rem Cyfrowy sterownik elektryzatora Rem projekt wykonał Karol F. 2015/05/14 Rem Procesor ATMEGA8 '$sim $regfile = "m8def.dat" $crystal = 16000000 ' Taktowanie zegara 8MHz rc wewnętrzny ' $baud = 9600 $hwstack = 32 $swstack = 16 $framesize = 16 'Config Com1 = Dummy , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 Rem Konfig. ADC Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0 Config Lcd = 16x2 'configure lcd screen Cls Cursor Off Lcd " Pastuch ver.2" Lowerline Lcd " High Voltage !" Waitms 2000 Cls Config Adc = Single , Prescaler = Auto , Reference = Avcc Rem Konfiguracja portów In - Out Config Portb.0 = Output ' Wolne takt pastucha 350V Config Portb.1 = Output ' Średni takt pastucha 300V Config Portb.2 = Output ' Szybki takt pastucha 250V Reset Portb.0 Reset Portb.1 Reset Portb.2 Config Portd.3 = Output Config Portd.4 = Output Config Portd.5 = Output Config Portd.6 = Output Config Portd.7 = Output Reset Portd.3 Reset Portd.4 Reset Portd.6 Reset Portd.5 Reset Portd.7 Rem Inicjacja przetwornika ADC 10bit 'Enable Adc Const Div = 5 / 1023 Rem stałe zmienne Dim Vref As Word Dim Vin As Single Dim Vbat As Single Dim Va As Single Dim Vb As Single Rem Obsługa klawiszy sterujących Lcd "Ustaw Parametry" Start Adc Rem ================ Warunki początkowe Va = 29 ' napięcie z dzielnika 400V (29 odpowiada 290V) Vb = 30 Do ' Gosub Bat_high Gosub Automat Gosub Bat_alarm Loop ' End Automat: Vref = Getadc(0) Vin = Vref * Div Vin = Vin * 10 If Vin <= Va Then ' Load DC 250-300V 'Set Portb.0 Set Portd.7 'Dioda LED LOAD Reset Portd.30 ' tranzystor sterujący trafo End If If Vin >= Vb Then Reset Portd.7 ' Dioda Led LOAD ' SET TRAFO HV 300V impuls sterujący Set Portd.6 ' tranzystor sterujący trafo Waitms 10 Reset Portd.6 End If Print "ADC0 = " ; Vin ; " value " ; Vref Return Rem Pomiar Napięcia Akumulatora 12V - przy 10V załącz Alarm! Bat_alarm: Vref = Getadc(1) Vbat = Vref * Div Vbat = Vbat * 10 If Vbat =< 10.00 Then ' Alarm Battery < 10V buzzer Reset Portd.4 Reset Portd.5 Set Portd.5 Waitms 50 Reset Portd.5 Waitms 50 Set Portd.5 Reset Portd.5 Waitms 50 Set Portd.5 Waitms 50 Reset Portd.5 Waitms 50 End If If Vbat => 10.00 Then Set Portd.4 End If Return End Bardzo bym prosił o pomoc tej poprawki.
|
|||
Odp. Elektryzator
Proszę. Pozmieniałbym dużo więcej w tym programie, ale nie mam dziś więcej czasu. To co chciałeś powinno działać.
BARTek
Moja strona
Elektryzator sterowany atmegą8
Bartek jesteś wielki, dzięki za pomoc, ale jak byś był w stanie coś tam poprawić to poczekam...
Elektryzator sterowany atmegą8
Karlos123 pokażesz schemat elektryzatora