<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Vigorius stirring redefined. Part 2 &#8211; electronics</title>
	<atom:link href="http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/feed" rel="self" type="application/rss+xml" />
	<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics</link>
	<description>A Solder Joint</description>
	<lastBuildDate>Wed, 10 Mar 2010 14:27:08 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: oleg</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3778</link>
		<dc:creator>oleg</dc:creator>
		<pubDate>Thu, 31 Dec 2009 19:05:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3778</guid>
		<description>Somehow your previous post with code ended up in spam folder and I haven&#039;t noticed it until today. Anyway, It&#039;s nice that you had encoder control sorted out!</description>
		<content:encoded><![CDATA[<p>Somehow your previous post with code ended up in spam folder and I haven&#8217;t noticed it until today. Anyway, It&#8217;s nice that you had encoder control sorted out!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3773</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Thu, 31 Dec 2009 03:37:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3773</guid>
		<description>After a bit of twiddling I got it working - Oleg, I have to say that this is THE most elegant rotary encoder solution I have seen. I have spent the past week or so working with different routines for quadrature encoders and this is just absolutely awesome.

Thanks very much!

Brad</description>
		<content:encoded><![CDATA[<p>After a bit of twiddling I got it working &#8211; Oleg, I have to say that this is THE most elegant rotary encoder solution I have seen. I have spent the past week or so working with different routines for quadrature encoders and this is just absolutely awesome.</p>
<p>Thanks very much!</p>
<p>Brad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3772</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Thu, 31 Dec 2009 03:21:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3772</guid>
		<description>Oleg, yours is the most elegant and simple code for reading an encoder I have seen... only it doesn&#039;t work for me! Would you mind looking over what I have here and possibly giving me a suggestion?

&lt;code&gt;
#include 
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,PUT,NOPBADEN,DEBUG
#use delay(clock=20M)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include

signed char enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
byte old_AB = 0;
byte enc_value = 127;
byte old_enc_value = 0;

void encoder0Loop(void) {     // int8 enc_value
   old_AB &lt;&lt;= 2;    //remember previous state by shifting the lower bits up 2
   old_AB &#124;= ( portb &amp; 0x03 );      // AND the lower 2 bits of port b, then OR them with var old_AB to set new value
   enc_value += enc_states[( old_AB &amp; 0x0f )];     // the lower 4 bits of old_AB &amp; 16 are then the index for enc_states
      if ( enc_value == old_enc_value ) {
     return;
   }
   if( enc_value == 255 ) {       // Original line
     enc_value = 0;
   }
   printf(&quot;enc_value = %3d, old_AB = %3d, old_enc_value = %3d\n\r&quot;,enc_value,old_AB,old_enc_value);  // debugging...
   printf(lcd_putc,&quot;\fEncoder 0 = %d\n&quot;,enc_value);
   old_enc_value = enc_value;
   // set whatever variable you need to increment to enc_value here...
   } 
//////////////////////////////////////////////////////////////////#int_TIMER0
void timer0_isr()
   {
      output_toggle(PIN_A2);     // let me know it&#039;s alive...
   }
//////////////////////////////////////////////////////////////////

void main(void) {

   port_b_pullups(true);
   setup_adc_ports(NO_ANALOGS);
   set_tris_b(255);
   input_b();
   ENABLE_INTERRUPTS(global);
   ENABLE_INTERRUPTS(INT_TIMER0);
   SETUP_TIMER_0(RTCC_INTERNAL &#124; RTCC_DIV_32);

   printf(&quot;\n\r\rRotary Encoder Test 2\n\n\r&quot;);
   printf(lcd_putc,&quot;\fRotary Encoder\nTest 2&quot;);
   delay_ms(1000);

   while (true)
   {
      encoder0Loop();
   }     // end of while loop

}        // end of main
&lt;/code&gt;

I have scoped the encoder and it is working properly; currently this runs through the loop endlessly, with no response to the encoder at all! Any help would be greatly appreciated, but no problem if you don&#039;t want to!

Thanks,
Brad</description>
		<content:encoded><![CDATA[<p>Oleg, yours is the most elegant and simple code for reading an encoder I have seen&#8230; only it doesn&#8217;t work for me! Would you mind looking over what I have here and possibly giving me a suggestion?</p>
<p><code><br />
#include<br />
#fuses HS,NOWDT,NOPROTECT,NOLVP,BROWNOUT,PUT,NOPBADEN,DEBUG<br />
#use delay(clock=20M)<br />
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)<br />
#include</p>
<p>signed char enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};<br />
byte old_AB = 0;<br />
byte enc_value = 127;<br />
byte old_enc_value = 0;</p>
<p>void encoder0Loop(void) {     // int8 enc_value<br />
   old_AB &lt;&lt;= 2;    //remember previous state by shifting the lower bits up 2<br />
   old_AB |= ( portb &amp; 0x03 );      // AND the lower 2 bits of port b, then OR them with var old_AB to set new value<br />
   enc_value += enc_states[( old_AB &amp; 0x0f )];     // the lower 4 bits of old_AB &amp; 16 are then the index for enc_states<br />
      if ( enc_value == old_enc_value ) {<br />
     return;<br />
   }<br />
   if( enc_value == 255 ) {       // Original line<br />
     enc_value = 0;<br />
   }<br />
   printf(&quot;enc_value = %3d, old_AB = %3d, old_enc_value = %3d\n\r&quot;,enc_value,old_AB,old_enc_value);  // debugging...<br />
   printf(lcd_putc,&quot;\fEncoder 0 = %d\n&quot;,enc_value);<br />
   old_enc_value = enc_value;<br />
   // set whatever variable you need to increment to enc_value here...<br />
   }<br />
//////////////////////////////////////////////////////////////////#int_TIMER0<br />
void timer0_isr()<br />
   {<br />
      output_toggle(PIN_A2);     // let me know it&#039;s alive...<br />
   }<br />
//////////////////////////////////////////////////////////////////</p>
<p>void main(void) {</p>
<p>   port_b_pullups(true);<br />
   setup_adc_ports(NO_ANALOGS);<br />
   set_tris_b(255);<br />
   input_b();<br />
   ENABLE_INTERRUPTS(global);<br />
   ENABLE_INTERRUPTS(INT_TIMER0);<br />
   SETUP_TIMER_0(RTCC_INTERNAL | RTCC_DIV_32);</p>
<p>   printf(&quot;\n\r\rRotary Encoder Test 2\n\n\r&quot;);<br />
   printf(lcd_putc,&quot;\fRotary Encoder\nTest 2&quot;);<br />
   delay_ms(1000);</p>
<p>   while (true)<br />
   {<br />
      encoder0Loop();<br />
   }     // end of while loop</p>
<p>}        // end of main<br />
</code></p>
<p>I have scoped the encoder and it is working properly; currently this runs through the loop endlessly, with no response to the encoder at all! Any help would be greatly appreciated, but no problem if you don&#8217;t want to!</p>
<p>Thanks,<br />
Brad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oleg</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3770</link>
		<dc:creator>oleg</dc:creator>
		<pubDate>Wed, 30 Dec 2009 23:32:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3770</guid>
		<description>Encoder&#039;s A and B pins are connected to Atmega&#039;s PORTC pins 0 and 1. The name for the whole port byte is PINC. The magic happens on line 33 :-). &#039;PINC &amp; 0x03&#039; clears upper 6 bits of whatever was read from PORTC leaving bits 0 and 1 intact. &#039;old_AB &#124;= ( PINC &amp; 0x03 )&#039; generates an index for enc_states. This code would work on a PIC with almost no changes, the port name being the only one. You would need to have your encoder connected to 2 lower bits of a port, otherwise the code would become more complex.</description>
		<content:encoded><![CDATA[<p>Encoder&#8217;s A and B pins are connected to Atmega&#8217;s PORTC pins 0 and 1. The name for the whole port byte is PINC. The magic happens on line 33 :-). &#8216;PINC &amp; 0&#215;03&#8242; clears upper 6 bits of whatever was read from PORTC leaving bits 0 and 1 intact. &#8216;old_AB |= ( PINC &amp; 0&#215;03 )&#8217; generates an index for enc_states. This code would work on a PIC with almost no changes, the port name being the only one. You would need to have your encoder connected to 2 lower bits of a port, otherwise the code would become more complex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3768</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Wed, 30 Dec 2009 22:56:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3768</guid>
		<description>I guess what I&#039;m asking is, how do you read your encoder?? (Like you said, outputting the question clariefies it in your mind!)</description>
		<content:encoded><![CDATA[<p>I guess what I&#8217;m asking is, how do you read your encoder?? (Like you said, outputting the question clariefies it in your mind!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3767</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Wed, 30 Dec 2009 22:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3767</guid>
		<description>Neat stuff, Oleg!

I&#039;m trying to borrow your encoder routine to use in my PIC 18F4620... I&#039;ve got a couple of questions, though.

In line 33, you AND PINC &amp; 0x03, and then OR it with old_AB... what is PINC connected to? How to you get your encoder0PinA &amp; B input values into enc_value? (I&#039;m guessing here...)

Thanks for a great website and projects!</description>
		<content:encoded><![CDATA[<p>Neat stuff, Oleg!</p>
<p>I&#8217;m trying to borrow your encoder routine to use in my PIC 18F4620&#8230; I&#8217;ve got a couple of questions, though.</p>
<p>In line 33, you AND PINC &amp; 0&#215;03, and then OR it with old_AB&#8230; what is PINC connected to? How to you get your encoder0PinA &amp; B input values into enc_value? (I&#8217;m guessing here&#8230;)</p>
<p>Thanks for a great website and projects!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: oleg</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3167</link>
		<dc:creator>oleg</dc:creator>
		<pubDate>Thu, 08 Oct 2009 22:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3167</guid>
		<description>Thank you for the idea - I will surely try this!</description>
		<content:encoded><![CDATA[<p>Thank you for the idea &#8211; I will surely try this!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ferdinand</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3166</link>
		<dc:creator>ferdinand</dc:creator>
		<pubDate>Thu, 08 Oct 2009 21:58:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3166</guid>
		<description>Maybe you could use the tacho-signal to track the moment where the stirrer stops spinning. I would expect the rpm to go up if the motor is running freely.</description>
		<content:encoded><![CDATA[<p>Maybe you could use the tacho-signal to track the moment where the stirrer stops spinning. I would expect the rpm to go up if the motor is running freely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tweets that mention Circuits@Home » Vigorius stirring redefined. Part 2 – electronics. -- Topsy.com</title>
		<link>http://www.circuitsathome.com/mcu/programming/vigorius-stirring-redefined-part-2-electronics/comment-page-1#comment-3133</link>
		<dc:creator>Tweets that mention Circuits@Home » Vigorius stirring redefined. Part 2 – electronics. -- Topsy.com</dc:creator>
		<pubDate>Tue, 06 Oct 2009 22:22:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.circuitsathome.com/?p=1484#comment-3133</guid>
		<description>[...] This post was mentioned on Twitter by KnurdStuff. KnurdStuff said: Vigorius stirring redefined. Part 2 – electronics.: In previous article I started talking about construct.. http://bit.ly/UPFx [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by KnurdStuff. KnurdStuff said: Vigorius stirring redefined. Part 2 – electronics.: In previous article I started talking about construct.. <a href="http://bit.ly/UPFx" rel="nofollow">http://bit.ly/UPFx</a> [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
