Witam
Mam problem z regulacją fazową, a mianowicie żarówka podłączona do układu wykonawczego od czasu do czasu rozbłyśnie maksymalnym światłem tak jakby triak na ułamek sekundy załączył się na max. wcześniej robiłem podobne układy ale na ATmega8 i było wszystko ok. ale teraz zastosowałem Attiny84 i dzieją się cuda ! układ elektrycznie jest dobrze skonstruowany mianowicie detekcja "0" przez transoptor CNY17 oraz sterowanie triaka przez MOC3021.Bardzo proszę o pomoc w temacie. Pozdrawiam
Mam problem z regulacją fazową, a mianowicie żarówka podłączona do układu wykonawczego od czasu do czasu rozbłyśnie maksymalnym światłem tak jakby triak na ułamek sekundy załączył się na max. wcześniej robiłem podobne układy ale na ATmega8 i było wszystko ok. ale teraz zastosowałem Attiny84 i dzieją się cuda ! układ elektrycznie jest dobrze skonstruowany mianowicie detekcja "0" przez transoptor CNY17 oraz sterowanie triaka przez MOC3021.Bardzo proszę o pomoc w temacie. Pozdrawiam
[/$regfile = "attiny84.dat" 'Typ procesora
$crystal = 8000000
Config Timer0 = Timer , Prescale = 256
On Timer0 Przerwanie0
Config Timer1 = Timer , Prescale = 64
On Timer1 Triakwl
Config Adc = Single , Prescaler = Auto , Reference = Avcc 'konfiguracja wewnętrznego przetwornika A/C
Config Int0 = Rising
On Int0 Przejscie
Enable Timer0
Enable Timer1
Enable Int0
Enable Interrupts
Config Pinb.2 = Input
Set Portb.2
'INIT0
Config Portb.0 = Input : Set Portb.0 : I_config Alias Pinb.0 ' Config Start
Config Portb.1 = Input : Set Portb.1 : I_start Alias Pinb.1 ' Start/Stop
Config Porta.6 = Output : Reset Porta.6 : Triac_1 Alias Porta.6 ' Triak
Config Porta.7 = Output : Reset Porta.7 : Pk_1 Alias Porta.7 ' Przekażnik
Config Porta.2 = Output : Set Porta.2 : Led_zasilanie Alias Porta.2 'Dioda Zasilanie
Config Porta.3 = Output : Set Porta.3 : Led_praca Alias Porta.3 'Dioda Praca
Config Porta.4 = Output : Set Porta.4 : Led_stop Alias Porta.4 'Dioda STOP
'****************************
'Zmienne
'****************************
Dim Dziel As Byte : Dim Dziel1 As Byte : Dim Dziel2 As Byte : Dim Dziel3 As Byte : Dim Dziel4 As Byte : Dim Dziel5 As Byte : Dim Dziel6 As Byte : Dim Dziel7 As Byte : Dim Dziel8 As Byte : Dim Dziel9 As Byte
Dim F4ms As Bit
Dim F100ms As Bit : Dim F200ms As Bit : Dim F300ms As Bit : Dim F400ms As Bit : Dim F500ms As Bit : Dim F600ms As Bit : Dim F700ms As Bit : Dim F800ms As Bit : Dim F900ms As Bit : Dim F1s As Bit
Dim Mig100 As Bit : Dim Mig200 As Bit : Dim Mig300 As Bit : Dim Mig400 As Bit : Dim Mig500 As Bit : Dim Mig600 As Bit : Dim Mig700 As Bit : Dim Mig800 As Bit : Dim Mig900 As Bit : Dim Mig1s As Bit
Dim Q As Word
Dim Poziom As Byte
Dim Lpac As Byte
Dim Lpac_1 As Byte
'****************************
'****************************
' Zmienne Potencjometru głównego
Dim Wart_ac As Word
Dim Wart_ac1 As Word 'wartosć wejściowa
Dim Wx As Word 'wartość wyjściowa
Dim F1 As Long : Dim F2 As Long : Dim F3 As Long : Dim F4 As Long : Dim F5 As Long
Dim C As Word
Const A = 0 'wart min input
Const B = 1023 'wart max input
'wart min out
Const D = 100 'wart max out
' Zmienne Potencjometra PCB
Dim Wart_ac2 As Word
Led_zasilanie = 0
Waitms 300
Led_praca = 0
Waitms 300
Led_stop = 0
Waitms 300
Led_zasilanie = 1
Waitms 300
Led_praca = 1
Waitms 300
Led_stop = 1
Waitms 100
Start Adc
Poziom = 0
Do
If F4ms = 1 Then
Gosub Regulacja
Gosub _ledy
Reset F4ms
End If
If F100ms = 1 Then
Toggle Mig100
Gosub Zalaczenie
Reset F100ms
End If
If F200ms = 1 Then
Toggle Mig200
Reset F200ms
End If
If F300ms = 1 Then
Toggle Mig300
Reset F300ms
End If
If F400ms = 1 Then
Toggle Mig400
Reset F400ms
End If
If F500ms = 1 Then
Toggle Mig500
Reset F500ms
End If
If F600ms = 1 Then
Toggle Mig600
Reset F600ms
End If
If F700ms = 1 Then
Toggle Mig700
Reset F700ms
End If
If F800ms = 1 Then
Toggle Mig800
Reset F800ms
End If
If F900ms = 1 Then
Toggle Mig900
Reset F900ms
End If
If F1s = 1 Then
Toggle Mig1s
Reset F1s
End If
Loop
End
'****************************
'Przerwanie timer0
'****************************
Przerwanie0:
Timer0 = 131
Set F4ms
Incr Dziel
If Dziel = 25 Then
Dziel = 0
Set F100ms
Incr Dziel1
Incr Dziel2
Incr Dziel3
Incr Dziel4
Incr Dziel5
Incr Dziel6
Incr Dziel7
Incr Dziel8
Incr Dziel9
End If
If Dziel1 = 2 Then
Dziel1 = 0
Set F200ms
End If
If Dziel2 = 3 Then
Dziel2 = 0
Set F300ms
End If
If Dziel3 = 4 Then
Dziel3 = 0
Set F400ms
End If
If Dziel4 = 5 Then
Dziel4 = 0
Set F500ms
End If
If Dziel5 = 6 Then
Dziel5 = 0
Set F600ms
End If
If Dziel6 = 7 Then
Dziel6 = 0
Set F700ms
End If
If Dziel7 = 8 Then
Dziel7 = 0
Set F800ms
End If
If Dziel8 = 9 Then
Dziel8 = 0
Set F900ms
End If
If Dziel9 = 10 Then
Dziel9 = 0
Set F1s
End If
Return
''''''''''''''''''''''''''''''
Regulacja:
Wart_ac1 = Getadc(1)
Wart_ac2 = Getadc(5)
If Wart_ac1 <> Wart_ac Then
Incr Lpac
Else
Lpac = 0
End If
If Lpac = 40 Then
Wart_ac = Wart_ac1
Lpac = 0
End If
' Skalowanie Potencjometra Głównego
C = 2
F1 = Wart_ac - A
F2 = D - C
F3 = B - A
F4 = F1 * F2
F5 = F4 / F3
Wx = F5 + C
Return
''''''''''''''''''''''''''''''''''''
Zalaczenie:
If I_start = 0 Then
Pk_1 = 1
End If
If I_start = 1 Then
Pk_1 = 0
End If
If Pk_1 = 1 Then Poziom = Wx
If Pk_1 = 0 Then Poziom = 0
Return
''''''''''''''''''''''''''''''''''''
_ledy:
Led_zasilanie = 0
If Pk_1 = 0 Then
Led_stop = Mig100
Else
Led_stop = 1
End If
If Pk_1 = 1 Then
If Poziom = 0 Then
Led_praca = 1
End If
If Poziom <= 10 Then
Led_praca = Mig1s
End If
If Poziom > 10 And Poziom <= 20 Then
Led_praca = Mig900
End If
If Poziom > 20 And Poziom <= 30 Then
Led_praca = Mig800
End If
If Poziom > 30 And Poziom <= 40 Then
Led_praca = Mig700
End If
If Poziom > 40 And Poziom <= 50 Then
Led_praca = Mig600
End If
If Poziom > 50 And Poziom <= 60 Then
Led_praca = Mig500
End If
If Poziom > 60 And Poziom <= 70 Then
Led_praca = Mig400
End If
If Poziom > 70 And Poziom <= 80 Then
Led_praca = Mig300
End If
If Poziom > 80 And Poziom <= 90 Then
Led_praca = Mig200
End If
If Poziom > 90 And Poziom <= 99 Then
Led_praca = Mig100
End If
If Poziom = 100 Then
Led_praca = 0
End If
Else
Led_praca = 1
End If
Return
Triakwl:
Triac_1 = 1
Stop Timer1
Return
Przejscie:
Set Portb.2
Triac_1 = 0
Q = Lookup(poziom , Tablica)
Load Timer1 , Q
Start Timer1
Return
Tablica:
Data 1230%
Data 1170% , 1137% , 1112% , 1090% , 1071% , 1054% , 1038% , 1023% , 1009% , 995%
Data 982% , 970% , 958% , 946% , 935% , 924% , 913% , 903% , 893% , 883%
Data 873% , 863% , 854% , 845% , 835% , 826% , 817% , 808% , 800% , 791%
Data 782% , 774% , 766% , 757% , 749% , 741% , 732% , 724% , 716% , 708%
Data 700% , 692% , 684% , 676% , 668% , 660% , 652% , 644% , 637% , 629%
Data 621% , 613% , 605% , 597% , 589% , 581% , 573% , 565% , 557% , 549%
Data 541% , 533% , 525% , 517% , 509% , 501% , 492% , 484% , 476% , 467%
Data 458% , 450% , 441% , 432% , 423% , 414% , 405% , 396% , 386% , 377%
Data 367% , 357% , 347% , 336% , 325% , 315% , 303% , 292% , 280% , 267%
Data 254% , 241% , 227% , 212% , 196% , 178% , 159% , 138% , 112% , 79%
Data 0%]