<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=12&amp;t=11742&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2015-05-21T23:19:52+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=12&amp;t=11742&amp;mode</id>
<entry>
<author><name><![CDATA[Jacek]]></name></author>
<updated>2015-05-21T23:19:52+01:00</updated>
<published>2015-05-21T23:19:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129822#p129822</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129822#p129822"/>
<title type="html"><![CDATA[Re: enkoder  i 3 x led]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129822#p129822"><![CDATA[
Witam - mam pytanie czy taki program do komunikacji będzie działał - jest to część programu z EP 9/2004 dotyczącego obsługi RS485 - terminal wysyła znaki - ale atmega nie odpowiada:<br /><br />[syntax=basic4gl]Temp = Enkoder_odczyt<br /><br />Zn = Inkey()<br />     If Zn = Chr(8) Then<br />     Adr_s = &quot;&quot;<br />     Il_zn = 0                                              '<br />     Do<br />       Zn = Inkey()<br />       If Zn &gt;= &quot;0&quot; And Zn &lt;= &quot;9&quot; Then<br />          Incr Il_zn<br />          Adr_s = Adr_s + Zn<br />       Else<br />           If Zn &gt; Chr(0) Then<br />              Exit Do<br />           End If<br />       End If<br />     Loop<br />     If Zn = &quot;r&quot; Then<br />        If Il_zn &gt; 0 And Il_zn &lt; 3 Then<br />          Adres = Val(adr_s)<br /><br />          If Adres = Adrr Then<br />             Do<br />              Zn = Inkey()<br />              Loop Until Zn = Chr(13)<br />              Set Re_de<br />             Waitus 200<br />              Print Temp<br />              Waitms 1<br />              Reset Re_de<br />            End If<br />            End If<br />           End If<br />          End If[/syntax]<br /><br />cały program:<br /><br />[syntax=basic4gl]'Konfiguracja<br />'****************************<br />'$sim<br />$regfile = &quot;m32def.dat&quot;<br />$crystal = 16000000<br />$hwstack = 40<br />$swstack = 16<br />$framesize = 32<br />$baud = 9600<br /><br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />                     'porty<br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />Config Porta = Output<br />Config Portc.7 = Output<br />Config Portc.6 = Output<br />Config Portc.5 = Output<br />Config Portd.2 = Input<br />Config Portd.3 = Input<br />Config Portd.4 = Output<br />Config Portd.6 = Output<br />Config Portd.7 = Output<br />Config Print0 = Portb.2 , Mode = Set<br />Config Portb.2 = Output<br /><br /><br />Porta = 255<br />Portc.7 = 0<br />Portc.6 = 0<br />Portc.5 = 0<br />Portd.2 = 1<br />Portd.3 = 1<br />Portd.4 = 1<br />Portd.6 = 1<br />Portd.7 = 1<br /><br />Config Serialin = Buffered , Size = 15<br />'Config Serialout = Buffered , Size = 15<br />Echo Off<br />Const Adrr = 5<br /><br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />                      'aliasy<br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br /><br />W1 Alias Portc.7<br />W2 Alias Portc.6<br />W3 Alias Portc.5<br />Segmenty Alias Porta<br />Re_de Alias Portb.2<br /><br /><br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />                  'zmienne<br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br /><br /><br /><br />Dim I As Byte , Wyswietlacz As Byte , Tablica(3) As Byte<br />Dim E As Integer , F As Integer , Enkoder_odczyt As Integer<br />Dim Zadana As Integer , A As Integer , Temp As Integer<br />Dim C3 As Byte , C4 As Byte , C5 As Byte , Pwm_ As Byte<br />Dim Zn As String * 1 , Adr_s As String * 5 , Adres As Byte<br />Dim Il_zn As Byte , Test As Word<br />Dim Master_rx As Integer , Master_tx As Integer<br /><br /><br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />                    'timery<br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br /><br />Config Timer1 = Pwm , Pwm = 8 , Prescale = 256 , Compare B Pwm = Clear Down<br />Enable Timer1<br />Start Timer1<br />Config Timer0 = Timer , Prescale = 64<br />On Ovf0 Przerwanie<br />Load Timer0 , 1388<br /><br />Enable Ovf0<br />Enable Interrupts<br /><br /><br />Enable Timer0<br />Load Timer0 = 250<br />'Enable Timer1<br />'Load Timer1 = 125<br />'-------------------------------<br />Config Int0 = Falling<br />   On Int0 Enkoder<br />Enable Interrupts<br />   Enable Int0<br /><br /><br />Tablica(1) = 0<br />Tablica(2) = 0<br />Tablica(3) = 0<br /><br />Zadana = 180<br />Pwm_ = 200<br />Reset Re_de<br /><br /><br /><br />Wait 1<br /><br />Do<br /><br />  Enkoder_odczyt = E / 2<br />If Enkoder_odczyt =&gt; 360 Then<br />   Enkoder_odczyt = 360<br />End If<br /><br />If Enkoder_odczyt &lt;= 0 Then<br />   Enkoder_odczyt = 0<br />End If<br /><br /><br />A = Enkoder_odczyt<br /><br />Temp = A \ 100<br />C3 = Temp<br />Temp = A Mod 100<br />Temp = Temp \ 10<br />C4 = Temp<br />Temp = A Mod 10<br />C5 = Temp<br /><br />Tablica(1) = C3<br />Tablica(2) = C4<br />Tablica(3) = C5<br /><br /> If Enkoder_odczyt &lt; Zadana Then<br />   Gosub Cw<br />End If<br /><br />If Enkoder_odczyt &gt; Zadana Then<br />   Gosub Ccw<br />End If<br /><br />If Enkoder_odczyt = Zadana Then<br />   Gosub Brake<br />End If<br /><br /><br />'Zn = Inkey()<br />'If Zn = Chr(114) Then<br />'   Waitus 200<br />'   Set Re_de<br />'   Print Enkoder_odczyt<br />'   Waitms 1<br />'   Reset Re_de<br />'  End If<br /><br /><br /><br />'Print Enkoder_odczyt<br />'Set Re_de<br />'Waitus 50<br /><br />Temp = Enkoder_odczyt<br /><br />Zn = Inkey()<br />     If Zn = Chr(8) Then<br />     Adr_s = &quot;&quot;<br />     Il_zn = 0                                              '<br />     Do<br />       Zn = Inkey()<br />       If Zn &gt;= &quot;0&quot; And Zn &lt;= &quot;9&quot; Then<br />          Incr Il_zn<br />          Adr_s = Adr_s + Zn<br />       Else<br />           If Zn &gt; Chr(0) Then<br />              Exit Do<br />           End If<br />       End If<br />     Loop<br />     If Zn = &quot;r&quot; Then<br />        If Il_zn &gt; 0 And Il_zn &lt; 3 Then<br />          Adres = Val(adr_s)<br /><br />          If Adres = Adrr Then<br />             Do<br />              Zn = Inkey()<br />              Loop Until Zn = Chr(13)<br />              Set Re_de<br />             Waitus 200<br />              Print Temp<br />              Waitms 1<br />              Reset Re_de<br />            End If<br />            End If<br />           End If<br />          End If<br /><br /><br /><br />Loop<br /><br />End<br /><br /><br />Przerwanie:<br /><br /><br />Load Timer0 , 1388<br />     Incr Wyswietlacz<br /><br />     If Wyswietlacz = 4 Then<br />        Wyswietlacz = 1<br />     End If<br /><br />     Select Case Wyswietlacz<br /><br />            Case 1:<br />                 W3 = 1<br />                 Segmenty = Lookup(tablica(1) , Kody7seg)<br />                 W1 = 0<br />            Case 2:<br />                 W1 = 1<br />                 Segmenty = Lookup(tablica(2) , Kody7seg)<br />                 W2 = 0<br />            Case 3:<br />                 W2 = 1<br />                 Segmenty = Lookup(tablica(3) , Kody7seg)<br />                 W3 = 0<br /><br />     End Select<br /><br /><br /><br />Return<br /><br /><br />Cw:<br /><br />Start Timer1<br />Pwm1b = Pwm_<br />Portd.6 = 0<br />Portd.7 = 1<br /><br />Return<br /><br />Ccw:<br /><br />Start Timer1<br />Pwm1b = Pwm_<br />Portd.6 = 1<br />Portd.7 = 0<br /><br />Return<br /><br />Brake:<br /><br />Stop Timer1<br />Pwm1b = 0<br />Portd.6 = 1<br />Portd.7 = 1<br /><br />Return<br /><br />Enkoder:<br />Disable Int0<br />'Waitms 1<br />If Pind.2 = 0 Then<br />   If Pind.3 = 0 Then<br />   Decr E                                                   'Incr E<br />   Incr F                                                   'Decr F<br />   Else<br />   Incr E                                                   'Decr E<br />   Decr F                                                   'Incr F<br />   End If<br />End If<br />Enable Int0<br />Return<br /><br /><br /><br />Kody7seg:<br />Data &amp;B00000011                                             '0<br />Data &amp;B10011111                                             '1<br />Data &amp;B00100101                                             '2<br />Data &amp;B00001101                                             '3<br />Data &amp;B10011001                                             '4<br />Data &amp;B01001001                                             '5<br />Data &amp;B01000001                                             '6<br />Data &amp;B00011111                                             '7<br />Data &amp;B00000001                                             '8<br />Data &amp;B00001001                                             '9<br />Data &amp;B11111110                                             'dp<br />Data &amp;B11100101                                             'c<br />Data &amp;B11000101                                             'o<br />Data &amp;B11010101                                             'n<br />Data &amp;B00110001                                             'P[/syntax]<br /><br />pozdrawiam Jacek.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=193">Jacek</a> — 21 maja 2015, o 23:19</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jacek]]></name></author>
<updated>2015-05-19T19:48:27+01:00</updated>
<published>2015-05-19T19:48:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129633#p129633</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129633#p129633"/>
<title type="html"><![CDATA[Re: enkoder  i 3 x led]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129633#p129633"><![CDATA[
<img src="https://forum.atnel.pl/images/smilies/icon_redface.gif" alt=":oops:" title="Zawstydzony" />  <img src="https://forum.atnel.pl/images/smilies/icon_redface.gif" alt=":oops:" title="Zawstydzony" />  Bartek - kurczaczki  <img src="https://forum.atnel.pl/images/smilies/icon_redface.gif" alt=":oops:" title="Zawstydzony" /> jesteś wielki - a ja jestem ślepy - dzięki za podpowiedź.<br />pozdrawiam Jacek<br />P.s. już się &quot;kręcą&quot; cyferki na wyświetlaczach.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=193">Jacek</a> — 19 maja 2015, o 19:48</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jacek]]></name></author>
<updated>2015-05-18T23:14:13+01:00</updated>
<published>2015-05-18T23:14:13+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129542#p129542</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129542#p129542"/>
<title type="html"><![CDATA[enkoder  i 3 x led]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=11742&amp;p=129542#p129542"><![CDATA[
witam - chciałbym na 3 wyświetlaczach siedmiosegmentowych led wyświetlić stopnie z enkodera. Odczyt z enkodera ma być na przerwaniach jak i obsługa wyświetlaczy skleciłem tako oto kod  <img src="https://forum.atnel.pl/images/smilies/icon_redface.gif" alt=":oops:" title="Zawstydzony" /> ale coś nie chce mi działać na wyświetlaczach są liczby początkowe &quot;000&quot; kod:<br /><br />[syntax=basic4gl]'****************************<br />           'Konfiguracja<br />'****************************<br />'$sim<br />$regfile = &quot;m32def.dat&quot;<br />$crystal = 16000000<br /><br /><br />$hwstack = 40<br />$swstack = 16<br />$framesize = 32<br /><br />Config Porta = Output<br />Config Portc.7 = Output<br />Config Portc.6 = Output<br />Config Portc.5 = Output<br /><br />Porta = 255<br />Portc.7 = 0<br />Portc.6 = 0<br />Portc.5 = 0<br /><br />'Config Porta = &amp;B11111111 : Porta = &amp;B11111111<br />'Config Portc = &amp;B11111011 : Portc = &amp;B11111111<br /><br /><br />W1 Alias Portc.7<br />W2 Alias Portc.6<br />W3 Alias Portc.5<br />Segmenty Alias Porta<br /><br /><br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />                  'zmienne<br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br /><br /><br /><br />Dim I As Byte , Wyswietlacz As Byte , Tablica(3) As Byte<br />Dim E As Integer , F As Integer , Enkoder_odczyt As Integer<br />Dim Zadana As Integer , A As Integer , Temp As Integer<br />Dim C1 As Byte , C2 As Byte , C3 As Byte , C4 As Byte , C5 As Byte<br /><br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br />                    'timery<br />'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br /><br /><br />Config Timer0 = Timer , Prescale = 64<br />On Ovf0 Przerwanie<br />Load Timer0 , 1388<br /><br />Enable Ovf0<br />Enable Interrupts<br /><br /><br />Enable Timer0<br />Load Timer0 = 250<br />'Enable Timer1<br />'Load Timer1 = 125<br />'-------------------------------<br />Config Int0 = Falling<br />   On Int0 Enkoder<br />Enable Interrupts<br />   Enable Int0<br /><br /><br />Tablica(1) = 0<br />Tablica(2) = 0<br />Tablica(3) = 0<br /><br /><br /><br />Wait 1<br /><br />Do<br /><br />  Enkoder_odczyt = E / 2<br />If Enkoder_odczyt =&gt; 360 Then<br />   Enkoder_odczyt = 360<br />End If<br /><br />If Enkoder_odczyt &lt;= 0 Then<br />   Enkoder_odczyt = 0<br />End If<br /><br /><br /><br />If Enkoder_odczyt &lt; Zadana Then<br />   Gosub Cw<br />End If<br /><br />If Enkoder_odczyt &gt; Zadana Then<br />   Gosub Ccw<br />End If<br /><br />If Enkoder_odczyt = Zadana Then<br />   Gosub Brake<br />End If<br /><br /><br /><br />A = Enkoder_odczyt<br /><br />'Temp = A \ 10000<br />'C1 = Temp<br />'Temp = A Mod 10000<br />'Temp = Temp \ 1000<br />'C2 = Temp<br />'Temp = A Mod 1000<br />'Temp = Enkoder_odczyt \ 100<br />'C3 = Temp<br />'Temp = Enkoder_odczyt Mod 100<br />'Temp = Temp \ 10<br />'C4 = Temp<br />'Temp = Enkoder_odczyt Mod 10<br />'C5 = Temp<br /><br />Temp = A \ 100<br />C3 = Temp<br />Temp = A Mod 100<br />Temp = Temp \ 10<br />C4 = Temp<br />Temp = A Mod 10<br />C5 = Temp<br /><br />Tablica(1) = C3<br />Tablica(2) = C4<br />Tablica(3) = C5<br /><br /><br />Loop<br /><br />End<br /><br /><br />Przerwanie:<br /><br /><br />Load Timer0 , 1388<br />     Incr Wyswietlacz<br /><br />     If Wyswietlacz = 4 Then<br />        Wyswietlacz = 1<br />     End If<br /><br />     Select Case Wyswietlacz<br /><br />            Case 1:<br />                 W3 = 1<br />                 Segmenty = Lookup(tablica(1) , Kody7seg)<br />                 W1 = 0<br />            Case 2:<br />                 W1 = 1<br />                 Segmenty = Lookup(tablica(2) , Kody7seg)<br />                 W2 = 0<br />            Case 3:<br />                 W2 = 1<br />                 Segmenty = Lookup(tablica(3) , Kody7seg)<br />                 W3 = 0<br /><br />     End Select<br /><br /><br /><br />Return<br /><br /><br />Cw:<br /><br />Start Timer1<br />Pwm1b = A<br />Portd.6 = 0<br />Portd.7 = 1<br /><br />Return<br /><br />Ccw:<br /><br />Start Timer1<br />Pwm1b = A<br />Portd.6 = 1<br />Portd.7 = 0<br /><br />Return<br /><br />Brake:<br /><br />Stop Timer1<br />Pwm1b = 0<br />Portd.6 = 1<br />Portd.7 = 1<br /><br />Return<br /><br />Enkoder:<br />Disable Int0<br />'Waitms 1<br />If Pind.2 = 0 Then<br />   If Pind.3 = 0 Then<br />   Incr E<br />   Decr F<br />   Else<br />   Decr E<br />   Incr F<br />   End If<br />End If<br />Enable Int0<br />Return<br />'Kody7seg:<br />'Data 3,                                                     ' 0<br />'Data 159,                                                   ' 1<br />'Data 37,                                                    ' 2<br />'Data 13,                                                    ' 3<br />'Data 153,                                                   ' 4<br />'Data 73,                                                    ' 5<br />'Data 65,                                                    ' 6<br />'Data 31,                                                    ' 7<br />'Data 1,                                                     ' 8<br />'Data 9,                                                     ' 9<br />'Data 17,                                                    ' A<br />'Data 193,                                                   ' b<br />'Data 99,                                                    ' C<br />'Data 133,                                                   ' d<br />'Data 97,                                                    ' E<br />'Data 113                                                    ' F<br /><br /><br />Kody7seg:<br />Data &amp;B00000011                                             '0<br />Data &amp;B10011111                                             '1<br />Data &amp;B10100101                                             '2<br />Data &amp;B00001101                                             '3<br />Data &amp;B10011001                                             '4<br />Data &amp;B01001001                                             '5<br />Data &amp;B01000001                                             '6<br />Data &amp;B00011111                                             '7<br />Data &amp;B00000001                                             '8<br />Data &amp;B00001001                                             '9<br />Data &amp;B11111110                                             'dp<br />Data &amp;B11100101                                             'c<br />Data &amp;B11000101                                             'o<br />Data &amp;B11010101                                             'n<br />Data &amp;B00110001                                             'P[/syntax]<br /><br />czy mogę prosić o pomoc - co robię źle.<br />pozdrawiam Jacek.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=193">Jacek</a> — 18 maja 2015, o 23:14</p><hr />
]]></content>
</entry>
</feed>