<?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=9566&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-12-14T23:57:26+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=12&amp;t=9566&amp;mode</id>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T23:57:26+01:00</updated>
<published>2014-12-14T23:57:26+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108759#p108759</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108759#p108759"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108759#p108759"><![CDATA[
Te układy równiez nie działaja tak jak powiny <br />Układ tak narawde ma pracowac jako zadajnik MPG wiec potrzebuje wystawic sygnał cw do obsługi sterownika silnika krokowoego na atmega162 cały układ działa doskolane inne programy maja problem z cw poniewarz potrafia wystawic sygnał a nie przezucic z ccw na cw <br />a przy okazji wykozystuje z zadajnika odczyt na lcd wiec chciałbym tylko uruchomic ten program na atmega 32u4<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 23:57</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T23:21:17+01:00</updated>
<published>2014-12-14T23:21:17+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108751#p108751</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108751#p108751"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108751#p108751"><![CDATA[
na atmega 162 terz chodzi na 16MHz enkodera uzywam inkrementalnego 500 impulsów  push pull<br />i działa swietnie, nawet przy dużych predkościach nie gubi się ale ma tylko 3 przerwania a potrzebuje zrobic odczyt z dwuch enkoderów  na jednym wyswietlaczu, dlatego zakupiłem arduino leonardo ze wzgledu na atmega32u4 bo caly moduł kosztuje tyle co sam procesor <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br />Testowałem naprawde wiele róznych programów do obsługi enkoderów i wszystkie sie gubiły przy wiekszych predkosciach<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 23:21</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T22:57:39+01:00</updated>
<published>2014-12-14T22:57:39+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108741#p108741</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108741#p108741"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108741#p108741"><![CDATA[
pinb jest podciagniety opornikiem wiec nie wymaga podcigania <br />po zmianie <br />Config Int0 = Rising<br />Config Int1 = Falling<br />jest lepiej ale nadal   skacze wynik jak mu sie chce ale w miejszym stopniu<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 22:57</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T22:24:46+01:00</updated>
<published>2014-12-14T22:24:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108725#p108725</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108725#p108725"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108725#p108725"><![CDATA[
jakaś podpowiedz jak je ustawić ?<br />Mcucr = &amp;B00001011<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 22:24</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[kicajek]]></name></author>
<updated>2014-12-14T22:20:50+01:00</updated>
<published>2014-12-14T22:20:50+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108724#p108724</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108724#p108724"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108724#p108724"><![CDATA[
Nie wiem czy to ważne, ale rejestry MCUCR znacznie różnią się w tych dwóch ATmegach.<br />Porównaj sobie noty katalogowe.<br /><br />Pozdr.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=826">kicajek</a> — 14 gru 2014, o 22:20</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T21:25:46+01:00</updated>
<published>2014-12-14T21:25:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108709#p108709</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108709#p108709"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108709#p108709"><![CDATA[
przerabiałem z atmega162 na 32u4  a to tylko opis nie istotny,  w kodzie zrudłowym jest PD0 i PD1<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 21:25</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[matrix]]></name></author>
<updated>2014-12-14T21:23:59+01:00</updated>
<published>2014-12-14T21:23:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108706#p108706</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108706#p108706"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108706#p108706"><![CDATA[
Może <a href="http://mirley.firlej.org/enkoder_obrotowy"  class="postlink"><span style="color: #0000FF">-&gt; TO &lt;-</span></a> pomoże.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=689">matrix</a> — 14 gru 2014, o 21:23</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[kicajek]]></name></author>
<updated>2014-12-14T21:19:34+01:00</updated>
<published>2014-12-14T21:19:34+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108705#p108705</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108705#p108705"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108705#p108705"><![CDATA[
Witam<br />Zaznaczam że Bascom'a nie znam nic ale zauważyłem w Twoim opisie:<br />[syntax=basic4gl]' Encoder phase A to INT0 and INT1  (PD2 and PD3)[/syntax]<br />a w Atm32 INT0 i INT1 jest pod PD0 i PD1; no chyba, że w kodzie podawane jest już odpowiednio.<br /><br />Pozdr.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=826">kicajek</a> — 14 gru 2014, o 21:19</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T20:33:02+01:00</updated>
<published>2014-12-14T20:33:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108693#p108693</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108693#p108693"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108693#p108693"><![CDATA[
tak zaglądałem do PDF-a Portu F używam do obsługi wyświetlacza który w pełni działa JTAG wyłączony<br /><br />Na atmega162 po przekręceniu enkoderem licznik zmiana się co +0.01 - 0.01  zaś na atmega32u4 skacze jak chce +153.03 + 5.01 -534.52 nie ma płynności przeskoku<br /><br />opis pinów <br /><a href="http://forum.atnel.pl/_obrazki/o/6955/ee86be513918a0dccec8433d3339cc50.png"  class="postlink"><img src="http://forum.atnel.pl/_obrazki/o/thumb/6955/ee86be513918a0dccec8433d3339cc50.png" alt="Obrazek" /></a><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 20:33</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-14T19:10:47+01:00</updated>
<published>2014-12-14T19:10:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108678#p108678</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108678#p108678"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=108678#p108678"><![CDATA[
Witam.<br />Ciągnąc dalej temat mam następujący problem otóż cały program działa pod atmega162 lecz jeśli zmienię pod atmege32u4 nie działają przerwania tzn wyświetla głupoty.<br />Gdzie błąd  ?<br />[syntax=basic4gl]-------------------------------------------------------------------------------<br />' Filename : QuadrDec_1.0.bas<br />' Purpose  : Quadrature Decoder/Counter and Display<br />' Author   : Ger langezaal<br />' Date     : 5 April 2002<br />' Compiler : BASCOM-AVR   Rev. 1.11.6.5<br />'<br />'-------------------------------------------------------------------------------<br />'<br />' Algorithm:<br />' Interrupt on both edges of phase A<br />' Test phase B in ISR<br />' When phase B &lt;&gt; phase A then decrement counter<br />' When phase B = phase A then increment counter<br />' Convert counter value to displacment units<br />' Format value in string and display<br />'<br />'-------------------------------------------------------------------------------<br />'<br />' Setup for AT90S2313-10<br />'<br />' INT0 edge is set to rising edge<br />' INT1 edge is set to falling edge<br />' Encoder phase A to INT0 and INT1  (PD2 and PD3)<br />' Encoder phase B to PD4<br />' Pushbutton between Portd.5 and GND  (display zero)<br />' LCD at PortB<br />'<br />' Example for PROXXON KT150 XY table:<br />' Displacement/rev = 2 mm<br />' Encoder resolution = 20 pulses/rev<br />' Interrupt on both pulse edges = 40 interrupts/rev<br />' Dial resolution: 2 mm / 40 = 0.05 mm<br />' The optical encoder came from a used mouse (two available)<br />'<br />'-------------------------------------------------------------------------------<br />'<br />' Options/Compiler/Chip:<br />' HW Stack   48<br />' Soft Stack  8<br />' Framesize  16<br />'<br />'-------------------------------------------------------------------------------<br />'<br />$regfile = &quot;m32u4def.dat&quot;<br />$crystal = 16000000                                       '16 MHz<br /> <br />Dim X_axis As String * 8                                    'LCD format string<br />Dim Axis_raw As Integer                                     'optical pulse counter<br />Dim Axis_mm As Integer                                      'counter value converted to mm<br />'                                       'range: -327.65 to +327.65 mm<br /> <br />Const Enc_res = 20 * 2                                      'encoder resolution * 2<br />Const Conv_mm = 200 / Enc_res                               'dial resolution = 0.05 mm<br /> <br />Config Portb = Output<br />Config Portd = Input<br />Portd = 255                                                 'enable Portd pullup's<br /> <br />Config Lcdbus = 4<br />Config Lcd = 20 * 4<br />Config Lcdpin = Pin , Db4 = Portf.5 , Db5 = Portf.4 , Db6 = Portf.1 , Db7 = Portf.0<br />Config Lcdpin = Pin , E = Portf.6 , Rs = Portf.7<br />Cls<br />Cursor Off<br /> <br />Phase_a Alias Pind.0                                        'INT0 also connected to Pind.0 = INT1<br />Phase_b Alias Pind.1<br />Axis_rst Alias Pinb.4                                       'reset counter if low<br /> <br />'---&#91; Set Interrupt logic &#93;-----------------------------------------------------<br /> <br />Mcucr = &amp;B00001011                                          'set interrupt edges<br />On Int0 Phase_a_edge                                        'ISR on rising edge<br />On Int1 Phase_a_edge                                        'ISR on falling edge<br />Enable Int0<br />Enable Int1<br />Enable Interrupts<br /> <br />'---&#91; Initialization &#93;----------------------------------------------------------<br /> <br />Lcd &quot;X-Axis   Rev.1.0&quot;<br />Waitms 1000<br />Cls<br />Axis_raw = 0<br /> <br />'---&#91; Main program loop &#93;-------------------------------------------------------<br /> <br />Do<br />  If Axis_rst = 0 Then Axis_raw = 0                         'reset counter if low<br /> <br />  Axis_mm = Axis_raw * Conv_mm                              'convert to mm<br />  X_axis = Str(axis_mm)                                     '<br />  X_axis = Format(x_axis , &quot; +0.00&quot;)                        'format without leading zero's<br />'  X_axis = Format(x_axis , &quot;+000.00&quot;)   'format with leading zero's<br /> <br />  Locate 1 , 1<br />  Lcd &quot;X &quot; ; X_axis ; &quot; mm&quot;                                 'display<br />  Waitms 200<br />Loop<br /> <br />'-------------------------------------------------------------------------------<br />End<br /> <br />'---&#91; Interrupt Service Routine &#93;-----------------------------------------------<br /> <br />Phase_a_edge:                                               'Interrupt on rising and falling edge<br />  If Phase_b &lt;&gt; Phase_a Then                                'test phase B<br />    Decr Axis_raw                                           'CCW<br />  Else<br />    Incr Axis_raw                                           'CW<br />  End If<br />Return<br /> <br />'-------------------------------------------------------------------------------[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 14 gru 2014, o 19:10</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-08T10:22:51+01:00</updated>
<published>2014-12-08T10:22:51+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107773#p107773</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107773#p107773"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107773#p107773"><![CDATA[
Czy jest ktoś w stanie pomoc mi połączyć to w całość ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 8 gru 2014, o 10:22</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[kicajek]]></name></author>
<updated>2014-12-06T17:42:22+01:00</updated>
<published>2014-12-06T17:42:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107608#p107608</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107608#p107608"/>
<title type="html"><![CDATA[Re: enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107608#p107608"><![CDATA[
Witam<br /><div class="quotetitle">motoinox napisał(a):</div><div class="quotecontent"><br />Udało mi się znaleźć  w necie  bardzo dobrze działająca obsługę enkodera inkrementalnego<br /></div><br />...no i?<br />Po pierwsze wklejając kod użyj &quot; listing kodu&quot; - Basic<br />po drugie nie opisałeś problemu  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <br /><br />Pozdr.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=826">kicajek</a> — 6 gru 2014, o 17:42</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[motoinox]]></name></author>
<updated>2014-12-06T19:18:11+01:00</updated>
<published>2014-12-06T17:37:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107606#p107606</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107606#p107606"/>
<title type="html"><![CDATA[enkoder potrzebuje pomocy]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9566&amp;p=107606#p107606"><![CDATA[
]Witam.<br />Na początku chciałem się przedstawić i przywita, jestem nowy i niestety życie mnie zmusiło w końcu zagłębić się i nauczyć programowania niestety mam z tym problemy ponieważ jestem początkujący i w tym celu proszę o pomoc.<br /><br />Udało mi się znaleźć  w necie  bardzo dobrze działająca obsługę enkodera inkrementalnego <br />[syntax=basic4gl]           <br />-------------------------------------------------------------------------------<br />' Filename : QuadrDec_1.0.bas<br />' Purpose  : Quadrature Decoder/Counter and Display<br />' Author   : Ger langezaal<br />' Date     : 5 April 2002<br />' Compiler : BASCOM-AVR   Rev. 1.11.6.5<br />'<br />'-------------------------------------------------------------------------------<br />'<br />' Algorithm:<br />' Interrupt on both edges of phase A<br />' Test phase B in ISR<br />' When phase B &lt;&gt; phase A then decrement counter<br />' When phase B = phase A then increment counter<br />' Convert counter value to displacment units<br />' Format value in string and display<br />'<br />'-------------------------------------------------------------------------------<br />'<br />' Setup for AT90S2313-10<br />'<br />' INT0 edge is set to rising edge<br />' INT1 edge is set to falling edge<br />' Encoder phase A to INT0 and INT1  (PD2 and PD3)<br />' Encoder phase B to PD4<br />' Pushbutton between Portd.5 and GND  (display zero)<br />' LCD at PortB<br />'<br />' Example for PROXXON KT150 XY table:<br />' Displacement/rev = 2 mm<br />' Encoder resolution = 20 pulses/rev<br />' Interrupt on both pulse edges = 40 interrupts/rev<br />' Dial resolution: 2 mm / 40 = 0.05 mm<br />' The optical encoder came from a used mouse (two available)<br />'<br />'-------------------------------------------------------------------------------<br />'<br />' Options/Compiler/Chip:<br />' HW Stack   48<br />' Soft Stack  8<br />' Framesize  16<br />'<br />'-------------------------------------------------------------------------------<br />'<br />$regfile = &quot;2313def.dat&quot;<br />$crystal = 10000000                                         '10 MHz<br /><br />Dim X_axis As String * 8                                    'LCD format string<br />Dim Axis_raw As Integer                                     'optical pulse counter<br />Dim Axis_mm As Integer                                      'counter value converted to mm<br />'                                       'range: -327.65 to +327.65 mm<br /><br />Const Enc_res = 20 * 2                                      'encoder resolution * 2<br />Const Conv_mm = 200 / Enc_res                               'dial resolution = 0.05 mm<br /><br />Config Portb = Output<br />Config Portd = Input<br />Portd = 255                                                 'enable Portd pullup's<br /><br />Config Lcdbus = 4<br />Config Lcd = 16 * 1<br />Config Lcdpin = Pin , Db4 = Pb.4 , Db5 = Pb.5 , Db6 = Pb.6 , Db7 = Pb.7 , E = Pb.3 , Rs = Pb.2<br />Cls<br />Cursor Off<br /><br />Phase_a Alias Pind.2                                        'INT0 also connected to Pind.3 = INT1<br />Phase_b Alias Pind.4<br />Axis_rst Alias Pind.5                                       'reset counter if low<br /><br />'---[ Set Interrupt logic ]-----------------------------------------------------<br /><br />Mcucr = &amp;B00001011                                          'set interrupt edges<br />On Int0 Phase_a_edge                                        'ISR on rising edge<br />On Int1 Phase_a_edge                                        'ISR on falling edge<br />Enable Int0<br />Enable Int1<br />Enable Interrupts<br /><br />'---[ Initialization ]----------------------------------------------------------<br /><br />Lcd &quot;X-Axis   Rev.1.0&quot;<br />Waitms 1000<br />Cls<br />Axis_raw = 0<br /><br />'---[ Main program loop ]-------------------------------------------------------<br /><br />Do<br />  If Axis_rst = 0 Then Axis_raw = 0                         'reset counter if low<br /><br />  Axis_mm = Axis_raw * Conv_mm                              'convert to mm<br />  X_axis = Str(axis_mm)                                     '<br />  X_axis = Format(x_axis , &quot; +0.00&quot;)                        'format without leading zero's<br />'  X_axis = Format(x_axis , &quot;+000.00&quot;)   'format with leading zero's<br /><br />  Locate 1 , 1<br />  Lcd &quot;X &quot; ; X_axis ; &quot; mm&quot;                                 'display<br />  Waitms 200<br />Loop<br /><br />'-------------------------------------------------------------------------------<br />End<br /><br />'---[ Interrupt Service Routine ]-----------------------------------------------<br /><br />Phase_a_edge:                                               'Interrupt on rising and falling edge<br />  If Phase_b &lt;&gt; Phase_a Then                                'test phase B<br />    Decr Axis_raw                                           'CCW<br />  Else<br />    Incr Axis_raw                                           'CW<br />  End If<br />Return<br /><br />'-------------------------------------------------------------------------------<br />      [/syntax]<br /><br />Niestety tylko jednego potrzebuje rozszerzyć  do obsługi dwóch jednocześnie i tutaj proszę o pomoc  robię gdzieś błędy i nie mogę dojść gdzie<br /><br />kręcąc y liczy do przodu i do tyłu prawidłowo  i jednoczenie liczy do przodu x<br />nie wiem jak rozwiązać aby pokazywał  osobno dla x oraz y<br />[syntax=basic4gl]<br /><br />$regfile = &quot;m162def.dat&quot;<br />$crystal = 8000000<br /><br /><br />Config Lcd = 20 * 4<br />Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Porta.0 , Db6 = Porta.1 , Db7 = Porta.2<br />Config Lcdpin = Pin , E = Portb.1 , Rs = Portb.2<br /><br /><br /><br /><br /><br />Config Pinc.3 = Input<br />Config Pinc.2 = Input<br />Config Pina.3 = Output<br />            Porta.3 = 1<br />Config Portc.4 = Input<br />Config Portd = Input<br />Config Portb = Output<br /><br /><br /><br />Dim X As String * 8                                         'LCD format string<br />Dim X_raw As Long                                           'optical pulse counter<br />Dim X_mm As Long                                            'counter value converted to mm<br />'<br /><br />Dim Y As String * 8                                         'LCD format string<br />Dim Y_raw As Integer                                        'optical pulse counter<br />Dim Y_mm As Integer                                         'counter value converted to mm<br />'<br /><br />Const Enc_res = 500                                         'encoder resolution * 2<br />Const Conv_mm = 5                                           'dial resolution = 0.05 mm<br />Const Yenc_res = 500                                        'encoder resolution * 2<br />Const Yconv_mm = 5<br /><br />Portd = 255<br /><br /><br /><br /><br /><br /><br />Cls<br />Cursor Off<br /><br /><br /><br />In1_a Alias Pind.1                                          'INT0 also connected to Pind.3 = INT1<br />In1_b Alias Pind.2<br />X_reset Alias Pind.5<br /><br />In2_a Alias Pind.3                                          'INT0 also connected to Pind.3 = INT1<br />In2_b Alias Pind.4<br />Y_reset Alias Pind.5                                        'reset counter if low<br /><br />'---[ Set Interrupt logic ]-----------------------------------------------------<br /><br />  X_reset = 0<br /> X_reset = Portd.5<br />   Y_reset = 0<br /> Y_reset = Portd.5<br /><br /><br /><br /><br /><br />Enable Interrupts<br /><br />'---[ Initialization ]----------------------------------------------------------<br />Locate 2 , 3<br />Lcd &quot;  Zadajnik MPG&quot;<br />Waitms 1000<br />Cls<br />X_raw = 0<br />Y_raw = 0<br />'---[ Main program loop ]-------------------------------------------------------<br /><br /> Mcucr = &amp;B00001011<br /><br />On Int0 Phase_a_edge                                                    'ISR on rising edge<br />On Int1 Phase_a_edge<br />                                       'ISR on falling edge<br />Enable Int0<br />Enable Int1<br />Enable Interrupts<br /><br />Do<br />  If X_reset = 0 Then X_raw = 0                             'reset counter if low<br /><br />  X_mm = X_raw / Conv_mm                                    'convert to mm<br />  X = Str(x_mm)                                             '<br />  X = Format(x , &quot; +0.00&quot;)                                  'format without leading zero's<br />'  X_axis = Format(x_axis , &quot;+000.00&quot;)   'format with leading zero's<br /><br />  Locate 2 , 3<br />  Lcd &quot;X &quot; ; X ; &quot; mm&quot;                                      'display<br />   Waitms 20<br /><br />  If Y_reset = 0 Then Y_raw = 0                             'reset counter if low<br /><br />  Y_mm = Y_raw / Yconv_mm                                   'convert to mm<br />  Y = Str(y_mm)                                             '<br />  Y = Format(y , &quot; +0.00&quot;)                                  'format without leading zero's<br />'  y_axis = Format(y_axis , &quot;+000.00&quot;)   'format with leading zero's<br /><br />  Locate 3 , 3<br />  Lcd &quot;Y &quot; ; Y ; &quot; mm&quot;                                      'display<br />  Waitms 20<br /><br /><br />Loop<br /><br />'-------------------------------------------------------------------------------<br />End<br /><br />'---[ Interrupt Service Routine ]-----------------------------------------------<br /><br />Phase_a_edge:                                               'Interrupt on rising and falling edge<br />  If In1_a &lt;&gt; In1_b Then                                    'test phase B<br />    Decr Y_raw<br />                                            'CCW<br />  Else<br />    Incr Y_raw<br /><br />  End If<br /><br />    If In2_b &lt;&gt; In2_a Then                                  'test phase B<br />    Decr Y_raw                                              'CCW<br />  Else<br />    Incr Y_raw                                              'CW<br />  End If<br /><br /><br />Return<br />[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6955">motoinox</a> — 6 gru 2014, o 17:37</p><hr />
]]></content>
</entry>
</feed>