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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-08-23T15:01:56+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=12&amp;t=8237&amp;mode</id>
<entry>
<author><name><![CDATA[slawek3000]]></name></author>
<updated>2014-08-23T15:01:56+01:00</updated>
<published>2014-08-23T15:01:56+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92578#p92578</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92578#p92578"/>
<title type="html"><![CDATA[Re: Dziwne zachowanie się encodera]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92578#p92578"><![CDATA[
Nie Panowie , jak zmieniłem na LCD Graficzny, bo alfanumerycznym działa, musiałem piny zamienić w programie i nie wiem czy do końca są poprawnie ustawione  ... zmienna Bytincr   powinna się zmieniać w 2 lub 1 w zależności od kierunku obracania<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=988">slawek3000</a> — 23 sie 2014, o 15:01</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[atmel]]></name></author>
<updated>2014-08-23T14:33:25+01:00</updated>
<published>2014-08-23T14:33:25+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92573#p92573</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92573#p92573"/>
<title type="html"><![CDATA[Re: Dziwne zachowanie się encodera]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92573#p92573"><![CDATA[
Jeśli problem występuje przy szybkim obrocie, wtedy jest to typowe zachowanie przy zbyt małej częstotliwości próbkowania powodujące powstanie zjawiska aliasingu tzn. gubienia stanów przejściowych enkodera informujących o kierunku jego obrotu.<br />Najlepiej zmniejszyć prescaler timer'a, albo w inny sposób podnieść częstotliwość próbkowania.<br /><br />Kondensatory co prawda eliminują pewien szum, który powstaje w przypadku zmiany stanu, jednak dla enkoderów o dużym podziale ma to raczej niewielkie znaczenie, gdyż błąd wynosi jedynie 1 krok (wartość kąta oscyluje nieznacznie).<br />Zwiększenie stałej czasowej poprzez dodanie kondensatora wpływa zdecydowanie negatywnie na częstotliwość sygnału, zmniejszając tym samym możliwość interpretacji szybkich obrotów.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1183">atmel</a> — 23 sie 2014, o 14:33</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[slawek3000]]></name></author>
<updated>2014-08-23T06:32:32+01:00</updated>
<published>2014-08-23T06:32:32+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92539#p92539</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92539#p92539"/>
<title type="html"><![CDATA[Dziwne zachowanie się encodera]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=8237&amp;p=92539#p92539"><![CDATA[
Witam,<br />Mam problem z encoderem czy kręcąc w lewo czy w prawo zlicza raz odejmując zmienną raz ją dodając <br />kod poniżej<br /> [syntax=basic4gl]'Filename   Encoder_100.bas<br />'Version    1.00<br />'Date       2012-03-19<br />'Purpose    Test of ALPS STEC11B13 encoder (reichelt.de)<br />'Author     Georg Latzel, DL6GL<br />'Copyright  (c) Georg Latzel, free for private use under GNU license<br />'Hardware   ATmega8<br />'           Crystal 16 MHz<br />'           2x16 Text LCD @ PortC<br />'           Encoder A @ PortB.0<br />'           Encoder B @ PortB.1<br />'Compiler   BASCOM-AVR 2.0.7.3<br />'           For readable &quot;camel case&quot; variables mark &quot;Don't change case&quot;<br />'           in BASCOM Options-Programmer-Environment-Editor<br />'           Flash used: 1420 bytes (17%)<br />'Edit history<br />'V1.00      2012-03-19, first release<br /><br />'==============================================================================<br /><br />'FUSE-Bits (Ponyprog-Settings, &#91; &#93;=no check, &#91;x&#93;=check)<br />'In ATmega data sheets: Bit = 1 -&gt; not set = &#91; &#93; Ponyprog<br />'                       Bit = 0 -&gt; set     = &#91;x&#93; Ponyprog<br />'- OCDEN    &#91; &#93;<br />'- JTAGEN:  &#91; &#93; (disabled!, otherwise LCD at PORT.C does not work)<br />'- EESAVE   &#91; &#93; Save EEProm on erase chip<br />'- BOOTSZ1  &#91;x&#93; Select Boot size<br />'- BOOTSZ0  &#91;x&#93; Select Boot size<br />'- BOOTRST  &#91; &#93; Select reset vector<br />'- Crystal oscillator<br />'  CKOPT:   &#91; &#93; (=1, low Oscillator amplitude or=1, &#91;x&#93;, high ampl.)<br />'  CKSEL3:  &#91; &#93; (=1, Select Clock Source)<br />'  CKSEL2:  &#91; &#93; (=1, as well)<br />'  CKSEL1:  &#91; &#93; (=1, as well)<br />'  CKSEL0:  &#91; &#93; (=1, crystal osc. fast start up 16k CK + 4ms)<br />'  SUT1:    &#91; &#93; (=1, as well)<br />'  SUT0:    &#91;x&#93; (=0, as well)<br /><br />$regfile = &quot;m644pdef.dat&quot;                                   ' specify the used micro<br />$crystal = 16000000<br />$baud = 19200                                               ' use baud rate<br />$hwstack = 32                                               ' default use 32 for the hardware stack<br />$swstack = 10                                               ' default use 10 for the SW stack<br />$framesize = 40                                             ' default use 40 for the frame space<br /><br />$lib &quot;glcdKS108.lbx&quot;<br /><br /><br />'First we define that we use a graphic LCD<br />Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portb , Ce = 0 , Ce2 = 1 , Cd = 4 , Rd = 3 , Reset = 2 , Enable = 5<br /><br />'Configure Encoder on Port B --------------------------------------------------<br />Ddrd = &amp;B00000000                                           'Portd = input<br />Portd = &amp;B11111111                                          'Activate Pullup<br />'                                                 'PIND.0 = Encoder Pin A<br />'                                                 'PIND.1 = Encoder Pin B<br />'                                                 'PIND.2 = Encoder key<br />Enc_a Alias Pind.0                                          'Encoder A<br />Enc_b Alias Pind.2                                          'Encoder B<br />Enc_k Alias Pind.1                                          'Encoder key<br /><br />'Configure Timer0 interrupt for encoder  --------------------------------------<br />'Timer0 = 8 bit<br />'Overflow time: overflow counts * Prescale / crystal frequency<br />'= 256 * 256 / 16.000.000 Hz = 4,1 msec = ~ 244 Hz<br />'Here Prescale = 256<br />'The encoder is polled every 4,1 msec. To shorten time set PresetTimer 0 &gt; 0<br />'Possible Prescales: 8, 64, 256, 1024<br />Config Timer0 = Timer , Prescale = 256<br />Const Presettimer0 = 0                                      'Initialize Timer0<br />On Timer0 Timer0_isr                                        'Timer0 Interrupt service routine<br /><br />'Common Variables, multiply used ----------------------------------------------<br />Dim Lngfreq As Long<br />Dim Lngstep As Long<br />Dim Strfreq As String * 9<br /><br />'Variables Encoder  -----------------------------------------------------------<br />Dim Bytincr As Byte                                         '=2: Encoder incr., =1: decr., =0: ./.<br />Dim Bytenc_old As Byte<br />Dim Bytenc_new As Byte<br />Dim Bitkey_enc As Bit                                       'Encoder key, =1: pressed<br />Const Doublestep = 0                                        '=1: intermediate position detected<br /><br />Declare Sub Clearlcdline(byval Bytline As Byte)<br /><br />'Main program  ****************************************************************<br />Cls<br /><br /><br />Lngfreq = 14000000<br />Lngstep = 10<br /><br />Strfreq = Str(lngfreq)<br />Strfreq = Format(strfreq , &quot; 0.000000&quot;)<br />Setfont My12_16 : Lcdat 3 , 20 , Strfreq<br /><br />Bytenc_old = 0                                              'Encoder data<br />Bytenc_new = 0                                              'Encoder data<br />Bytincr = 0<br /><br />Enable Timer0                                               'Interrupt encoder<br />Enable Interrupts                                           'enable all Interrupts<br /><br />Do<br /><br />   Disable Timer0                                           'Stop Timer0 for display<br /><br />   Select Case Bytincr                                      'Set/show TRX freq.<br />      Case 2                                                'Encoder incremented<br />         Lngfreq = Lngfreq + Lngstep<br />      Case 1                                                'Encoder decremented<br />         Lngfreq = Lngfreq - Lngstep<br />   End Select<br />       Setfont My6_8 : Lcdat 1 , 5 , Bytincr<br />   If Bytincr &gt; 0 Then                                      'Freq. was changed<br />      Strfreq = Str(lngfreq)<br />      Strfreq = Format(strfreq , &quot; 0.000000&quot;)<br />      'Call Clearlcdline(2)<br />      Setfont My12_16 : Lcdat 3 , 20 , Strfreq<br />      Bytincr = 0                                           'Reset increment flag<br />   End If<br /><br />   Enable Timer0                                            'Restart Timer0<br /><br />Loop<br /><br />End<br /><br />'End of main program **********************************************************<br /><br />'------------------------------------------------------------------------------<br />Timer0_isr:<br />'Encoder interrupt on Timer0 overflow<br />'While data are displayed Timer0 should be stopped<br />'Output: bytIncr = 2: increment, =1: decrement if encoder was changed<br />'Having processed the bytIncr data in the main program reset bytIncr = 0<br />'Switching pattern of ALPS STEC11 encoder:<br />'Turning clockwise              ... counter clockwise<br />'A    B                             A     B<br />'1    1  start detent position      1     1<br />'1    0  intermediate position 1    0     1<br />'0    0  intermediate position 2    0     0<br />'0    1  intermediate position 3    1     0<br />'1    1  next detent position       1     1<br /><br />   Timer0 = Presettimer0<br />   Bytenc_new.0 = Enc_a                                     'Set bit 0 of bytEnc_new<br />   Bytenc_new.1 = Enc_b                                     'Set bit 1 of bytEnc_new<br /><br />   'Check encoder pattern if encoder is changed<br />   'bytIncr = 1: decremented (turned counter clockwise)<br />   'bytIncr = 2: incremented (turned         clockwise)<br />   If Bytenc_new &lt;&gt; Bytenc_old Then                         'encoder is changed<br />      'from intermediate position 3 to quiescent position<br />      If Bytenc_new = &amp;B00000011 And Bytenc_old = &amp;B00000010 Then Bytincr = 2<br />      If Bytenc_new = &amp;B00000011 And Bytenc_old = &amp;B00000001 Then Bytincr = 1<br />      'from intermediate position 1 to intermediate position 2<br />      'DoubleStep = 1:  intermediate position 2 gives an additional tick<br />      '                 2 ticks between 2 detent positions on slow rotation<br />      '           = 0:  1 tick  between 2 detent positions<br />      #if Doublestep = 1<br />         If Bytenc_new = &amp;B00000000 And Bytenc_old = &amp;B00000001 Then Bytincr = 2<br />         If Bytenc_new = &amp;B00000000 And Bytenc_old = &amp;B00000010 Then Bytincr = 1<br />      #endif<br />      Bytenc_old = Bytenc_new                               'old &lt;- new for the next time<br />   End If<br />Return<br /><br />'------------------------------------------------------------------------------<br />Sub Clearlcdline(byval Bytline As Byte)<br />'Clear LCD line bytLine<br />   Locate Bytline , 1<br />   Lcd Spc(16)<br />   Locate Bytline , 1<br />End Sub<br />'------------------------------------------------------------------------------<br />$include &quot;my12_16.font&quot;<br />$include &quot;my6_8.font&quot;[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=988">slawek3000</a> — 23 sie 2014, o 06:32</p><hr />
]]></content>
</entry>
</feed>