<?xml version="1.0" encoding="utf-8"?>
				<!-- generator="e107" -->
				<!-- content type="Forum / topic" -->
				<rss  version="2.0">
				<channel>
				<title>8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes : Forum / topic</title>
				<link>http://www.8051projects.net/</link>
				<description>Learn to make simple microcontroller projects, pic, 8051, avr and arm projects. download 8051 projects, tutorials, libraries, sample codes. join the microcontroller discussion forum and ask doubts regarding electronics. the best source for 8051 over internet.</description>

<language>en-gb</language>
				<copyright><a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/in/" target="_blank"><img alt="Creative Commons License" width="80" height="15" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/2.5/in/80x15.png" target="_blank" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/in/" target="_blank">Creative Commons Attribution-Noncommercial 2.5 India License</a>.<a href='http://www.8051projects.net/disclaimer.htm' target='_blank' />Rickey's World Disclaimer</a></copyright>
				<managingEditor>Ajay Bhargav - contact@nospam.com</managingEditor>
				<webMaster>contact@nospam.com</webMaster>
				<pubDate>Mon, 01 Dec 2008 13:01:20 -0800</pubDate>
				<lastBuildDate>Mon, 01 Dec 2008 13:01:20 -0800</lastBuildDate>
				<docs>http://backend.userland.com/rss</docs>
				<generator>e107 (http://e107.org)</generator>
				<ttl>60</ttl>
				<textInput>
				<title>Search</title>
				<description>Search 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes</description>
				<name>query</name>
				<link>http://www.8051projects.net/search.php</link>
				</textInput>
						<item>
						<title>a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Hi,<br /><br />I have problem writing a code for the shaft encoder to decode for my PIC to read the direction.<br />Can some one please give me a sample code of the shaft encoder decodes the direction?<br /><br />thanks.]]></description>
<pubDate>Mon, 16 Jun 2008 03:33:06 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[like you have done in C already, here also you need to make a look up table for encoder to detect the change in direction.<br /><br />or... what you can do is.. create three states (CLOCK, ANTICLOCK, NOCHANGE)<br />like this:<br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;">CLOCK <span style="color: #0000ff;">equ</span> 1H<br />ANTICLOCK <span style="color: #0000ff;">equ</span> 2H<br />NOCHANGE <span style="color: #0000ff;">equ</span> 3H<br />&nbsp;</div></div><br />if encoder can be connected to interrupt pins of controller or periodic polling on any two pins, then whenever you sense a change in encoder o/p you can switch between states according to current state of encoder bits.<br />hence in your main loop when a state changes you can do work according to that state.<br /><br />I hope you have got my idea? <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>Ajay&lt;contact@nospam.com&gt;</author>
<pubDate>Tue, 17 Jun 2008 07:41:29 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Ajay, i know you already told me about this...but i try to work it out on ASM code...it doesnot work..<br /><br />can u give me a sample code of how to decode the shaft encoder direction?<br /><br />]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Mon, 16 Jun 2008 03:51:54 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[GPIO 4 is the channel A of the shaft encoder<br />GPIO 5 is the channel B of the shaft encoder<br />below is part of the program code for the encoder to decode the 4 binary bit to determine the direction.<br />shaft encoder used Bourns ECW- Digital Contacting Encoder<br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><br />START<br />&nbsp; &nbsp; &nbsp; &nbsp; btfsc&nbsp; &nbsp;GPIO,<span style="color: #ff0000;">4</span><span style="color: #adadad; font-style: italic;">; &nbsp; &nbsp;waiting for the encoder changes</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">goto</span> START<span style="color: #adadad; font-style: italic;">; keep check for the changes</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">call</span>&nbsp; &nbsp; SHAFT_0<span style="color: #adadad; font-style: italic;">; changes detected</span><br />SHAFT_0:<br />&nbsp; &nbsp; &nbsp; &nbsp; CLRF&nbsp; &nbsp; A11&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; clear memory A11</span><br />&nbsp; &nbsp; &nbsp; &nbsp; CLRF&nbsp; &nbsp; A21&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; clear memory A21</span><br />&nbsp; &nbsp; &nbsp; &nbsp; BCF&nbsp; &nbsp; &nbsp;STATUS,<span style="color: #0000ff;">C</span><span style="color: #adadad; font-style: italic;">; clear carry flag incase there is carry</span><br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC&nbsp; &nbsp;GPIO,<span style="color: #ff0000;">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; check on the changes, 0 or 1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_A11&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; if 1 go savebitA11</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_A10&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;if 0 go savebit A10</span><br />SHAFT_1<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC&nbsp; &nbsp;GPIO,<span style="color: #ff0000;">5</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; check on gpio 5 changes, channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_B11&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;if 1 go savebit B11</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_B10&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;if 0 go savebit B10</span><br />SHAFT_2<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC&nbsp; &nbsp;GPIO,<span style="color: #ff0000;">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;same as above to check to the 4th bit</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_A21&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_A20&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />SHAFT_3<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC&nbsp; &nbsp;GPIO,<span style="color: #ff0000;">5</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_B21&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SAVEBIT_B20&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A11<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; if 1 received on shaft channel A move 1 to A11 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVWF&nbsp; &nbsp;A11&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF&nbsp; &nbsp; &nbsp;A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; rotate left to make bit 0 avaible for channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SHAFT_1&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A10<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;if 0 received on shaft channel A move 1 to A11 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVWF&nbsp; &nbsp;A11&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF&nbsp; &nbsp; &nbsp;A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;rotate left to make bit 0 avaible for channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SHAFT_1&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_B11<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; if 1 received on shaft channel B move 1 to A11 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF&nbsp; &nbsp;A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;added up with channel B to form 1 complete bit for </span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF&nbsp; &nbsp; &nbsp;A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;each turn, rotate left 2 times for next bit of turn </span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;of the encoder</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SHAFT_2&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_B10<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; same as above ...for 0 bit on channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF&nbsp; &nbsp;A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF&nbsp; &nbsp; &nbsp;A11,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF A11,<span style="color: #ff0000;">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SHAFT_2&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A21<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;if 1 received on shaft channel A move 1 to A21 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVWF&nbsp; &nbsp;A21&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF&nbsp; &nbsp; &nbsp;A21,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;rotate left to make bit 0 avaible for channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SHAFT_3&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A20<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVWF&nbsp; &nbsp;A21&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;same as above</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF&nbsp; &nbsp; &nbsp;A21,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; SHAFT_3&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_B21<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;bit 1 , added up with channel A to form 1 complete bit for</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF&nbsp; &nbsp;A21,<span style="color: #ff0000;">0</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;each turn</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF&nbsp; &nbsp;A11,<span style="color: #ff0000;">0</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;at here, add up 2 complete bit to determine the </span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; DIRECTION&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; direction of the shaft encoder...</span><br />SAVEBIT_B20<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW&nbsp; &nbsp;<span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span>&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;same as above, but 0 bit received from previous action</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF&nbsp; &nbsp;A21,<span style="color: #ff0000;">0</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF&nbsp; &nbsp;A11,<span style="color: #ff0000;">0</span>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; DIRECTION&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />DIRECTION<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">CALL</span>&nbsp; &nbsp; TABLE_1&nbsp;<span style="color: #adadad; font-style: italic;">; call table to check on the direction after the total 4bit added</span><br />ANTI_CLOCKWISE<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">BSF</span>&nbsp; &nbsp; &nbsp;GPIO, <span style="color: #ff0000;">0</span><span style="color: #adadad; font-style: italic;">; set gpio 0 high</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BCF &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO,<span style="color: #ff0000;">1</span><span style="color: #adadad; font-style: italic;">; clear gpio 1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">goto</span>&nbsp; &nbsp; START<span style="color: #adadad; font-style: italic;">;</span><br />CLOCKWISE<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f; font-weight:bold;">BSF</span>&nbsp; &nbsp; &nbsp;GPIO,<span style="color: #ff0000;">1</span><span style="color: #adadad; font-style: italic;">;set gpio 1 high</span><br />&nbsp; &nbsp; &nbsp; &nbsp; BCF&nbsp; &nbsp; &nbsp;GPIO,<span style="color: #ff0000;">0</span><span style="color: #adadad; font-style: italic;">;clear gpio 0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; START<span style="color: #adadad; font-style: italic;">;</span><br />RESTART_PWM<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; START<span style="color: #adadad; font-style: italic;">; no changes go back to start</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; RETURN<br /><span style="color: #adadad; font-style: italic;">;************************************************</span><br /><span style="color: #adadad; font-style: italic;">;**** DIRECTION TABLE****************************</span><br /><span style="color: #adadad; font-style: italic;">;************************************************</span><br /><br />TABLE_1:<br />&nbsp; &nbsp; &nbsp; &nbsp; ADDWF&nbsp; &nbsp;PCL,<span style="color: #ff0000;">1</span>&nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; ANTI_CLOCKWISE&nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; CLOCKWISE&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; CLOCKWISE&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; ANTI_CLOCKWISE&nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; ANTI_CLOCKWISE&nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; CLOCKWISE&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; CLOCKWISE&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; ANTI_CLOCKWISE&nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span>&nbsp; &nbsp; RESTART_PWM&nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RETURN<br />&nbsp;</div></div>]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Mon, 16 Jun 2008 04:14:13 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[hihi, ajay,<br />my application is for the LED dimmer, i need to know when i am turning clockwise or anti clockwise of the encoder, the light is either dimmer or brighter.<br /><br />i want to know the changes of direction, so i can set the PWM.<br /><br />Thanks<br /><br />Ajay, the main problem i m having now is, how to detect the changes of the encoder signal bits, and how to save them efficiently and bring them to determine the direction using IOR table i am using.<br />thanks...<br /><br />]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Mon, 16 Jun 2008 08:17:43 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Welcome back nich well in your program you have used so many returns.. i really have no idea where you're returning <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' /> <br /><br />Well minute changes will make your program work..<br />like..<br /><div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><br />START<br />&nbsp; &nbsp; &nbsp; &nbsp; btfsc&nbsp; &nbsp;GPIO,<span style="color: #ff0000;">4</span><span style="color: #adadad; font-style: italic;">; &nbsp; &nbsp;waiting for the encoder changes</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">goto</span> START<span style="color: #adadad; font-style: italic;">; keep check for the changes</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;call&nbsp; &nbsp;SHAFT_0; changes detected</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;No need to call the next statement is same you are going to execute</span><br />&nbsp;</div></div><br />I found that there is no while(1) kind of loop in your program.<br /><br />please tell me what your application is or what you are trying to do in your program, so that i can optimize it better. and please review your code and remove the unwanted returns, because they will make your program to go mad and hang!!]]></description>
<author>Ajay&lt;contact@nospam.com&gt;</author>
<pubDate>Mon, 16 Jun 2008 07:45:27 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[I was using both of your idea in my design, i make it working on hardware now...but littlt buggy is that...when u over turned the shaft encoder, the light from the dimmest will changed to Brightest ...lol...<br />little buggy with my code here...need to prevent it to overshoot....<br /><br />thanks anyway...i will figure it out...]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Wed, 18 Jun 2008 01:11:03 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Hi Shyam, wat is mean by <br />wait until states are 1,1 , 0,1  or 1,0 ?<br /><br />is it i need to test the both bit in order to enter the loop for testing the direction?<br /><br /><br />off topic: i havent start to look for job now...i will start this weekend. do u know any job related in UK? thanks...]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 00:04:49 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[hi<br />nicholastyc<br />if u had searched the forum u wud have found an earlier post on the similar topic.<br />still  lemme tell u one technique which i use..<br /><br />u get two o/p lines<br />say A and B<br />u get data  in gray code format (cyclic).<br /><br />thhere will be two sets of data<br />1.  clockwise  (depends on what pin A or B is)<br />A|B<br />0|0<br />0|1<br />1|1<br />1|0<br />and<br />2. anticlockwise<br />A|B<br />0|0<br />1|0<br />1|1<br />0|1<br /><br />now u wud have observed the difference just compare   any two occurance of data and u will find the direction...<br />hope that helps...<br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/103.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Tue, 17 Jun 2008 06:23:43 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[i think something is wrong with my code that its only detects 1 direction!!<br />i have made my program on interrupt on change  to the both input port,<br />the will go into the ISR to save the bit data...<br />but its still failed to detect the correct direction.<br /><br />why?<br /><br />thanks Shyam for your times...i still failed..]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 04:32:27 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[<div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;"><br /><span style="color: #0000ff;">for</span> example:<br /><br />START<br />&nbsp; &nbsp; &nbsp; &nbsp; btfss &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO,<span style="color: #ff0000;">4</span><span style="color: #adadad; font-style: italic;">; check encoder changes</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">goto</span>&nbsp; &nbsp; &nbsp; &nbsp;START<br />&nbsp; &nbsp; &nbsp; &nbsp; clrf&nbsp; &nbsp; SWDAT2<span style="color: #adadad; font-style: italic;">; clear reg</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;btfss &nbsp; GPIO,<span style="color: #ff0000;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; if bit A lo</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">bsf</span> &nbsp; &nbsp; SWDAT2,<span style="color: #ff0000;">0</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; set SWDAT2 bit 0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;btfss &nbsp; GPIO,<span style="color: #ff0000;">5</span> &nbsp;<span style="color: #adadad; font-style: italic;">; if bit B lo</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f; font-weight:bold;">bsf</span> &nbsp; &nbsp; SWDAT2,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; set SWDAT2 bit 1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; movf &nbsp; &nbsp;SWDAT2,W &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; load switch data &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; andlw &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000011'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; mask encoder B and A switches &nbsp; |B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; xorwf &nbsp; ENCOLD,W &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; same as last reading? &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; bz &nbsp; &nbsp; &nbsp;START &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; yes, branch (no change), else &nbsp; |B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; xorwf &nbsp; ENCOLD,W &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; restore encoder bits in W &nbsp; &nbsp; &nbsp; |B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; rrf &nbsp; &nbsp; ENCOLD,f &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; prep for B-old ^ A-new &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; xorwf &nbsp; ENCOLD,f &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; ENCOLD bit 0 = direction &nbsp; &nbsp; &nbsp; &nbsp;|B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; rrf &nbsp; &nbsp; ENCOLD,f &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; now Carry bit = direction &nbsp; &nbsp; &nbsp; |B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; movwf &nbsp; ENCOLD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; update ENCOLD (new BA bits) &nbsp; &nbsp; |B0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; btfss&nbsp; &nbsp;STATUS,<span style="color: #0000ff;">C</span><span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">goto</span>&nbsp; &nbsp; ANTI_CLOCKWISE<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">goto</span>&nbsp; &nbsp; CLOCKWISE<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp;</div></div><br /><br />i m using pic12f629... <br />can some one suggest me a WORKED code?]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Thu, 19 Jun 2008 09:02:41 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Shyam , Ajay...Arun...<br /><br />i really need help on the encoder part...please help..i already tried my best !<br />i still cant get the right direction ... i m using pic12f629 ...<br />i am using Gpio,4 and gpio,5 as Bit A and Bit B of encoder. <br />1. clockwise <br />A|B<br />0|0<br />0|1<br />1|1<br />1|0<br />and<br />2. anticlockwise<br />A|B<br />0|0<br />1|0<br />1|1<br />0|1<br /><br />how to make a correct table? i m trying to make 1...its works on the simulation but failed on hardware...dunno y...<br />do i need the interrupt routine? because i m using the btfss gpio,4 to enter the direction loop and then check on the bit on A and B. same as the code in the thread above...<br /><br />pplease have a look...or give me a code to try...i m so so so depressed!<br /><br />thanks]]></description>
<author>nicholastyc&lt;thamyc_2000@nospam.com&gt;</author>
<pubDate>Thu, 19 Jun 2008 14:59:26 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[hi nic,<br />well   u do need those A and B pin as interrupt pins..  or else u may miss the step changes..<br /><br /><br />or u can try one thing....   <br /><br />wait until   states are   1,1<br />wait for either  0,1  or 1,0<br /><br />accordigly  u wud come 2 know the direction of rotation..<br /><br />one more point to note..<br />the shaft is usually very sensitive...<br />if u are rotating by self  (ur hand) well u might observe  both the direction    so dont panic .. stay calm cause u are using the right procedure..<br /><br /><br /><br />off topic: any new development regarding your job searh?<br />all the best.<br />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Thu, 19 Jun 2008 22:57:27 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[<div class='indent'>is it i need to test the both bit in order to enter the loop for testing the direction?</div><br /><br />nic,<br /><br /><br />take a variable  say <br />int EncCount_int.<br />int EncStateClk_int[]= {3,2,0,1}; <br />int EncStateAntiClk_int[]= {3,1,0,2}; <br />since the encoder is fast enough  ..  there is no harm in waiting for that particular stste that u can mark as START.  <br />case1.<br />  if u r not using the pins as interrupt.<br />start loop.<br />now u will have to make the uC idle untill the next state change..   i.e.  keep checking for the pins untill u notice a change in  either of the pin.<br /><br />read the pins and store in a vriable <br />int Pinval_int;<br />int index =1;<br /><br />now check <br />if  Pinval_int =  EncStateClk_int[index]<br />//  clock wise rotation<br />//decrease  EncCount_int<br /> EncCount_int = EncCount_int -1;<br />else<br />//  anticlock wise rotation<br />//increase  EncCount_int<br /> EncCount_int=  EncCount_int+1;<br />//increment index;<br /> if ( index ==4)<br />index =0;<br /><br />get back to the loop<br /><br /><br /><br />sorry for not being clear enough...   am  amidst a project needing some attention...<br />please se if it helps...<br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/103.gif' alt='' style='vertical-align:middle; border:0' />  <br />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 00:23:35 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[can i see your code again?]]></description>
<author>Ajay&lt;contact@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 08:26:51 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[yes lets see the code again..  the interrupt one.]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 08:36:34 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Hi Nic,<br />This is a small adaptation of your polling routine using a single variable A11.It savs the current and previous  AB values in this manner as a nibble....<br /><br /><img src='http://www.8051projects.net/e107_files/public/1214029517_5870_FT10071_hp.gif' class='bbcode' alt='' width='122' height='40'  />	<br /><br /> <div class='code_asm'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="asm" style="font-family: monospace;">START<br />&nbsp; &nbsp; &nbsp; &nbsp; CLRF &nbsp; &nbsp;A11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; clear memory A11</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; BCF &nbsp; &nbsp; STATUS,<span style="color: #0000ff;">C</span><span style="color: #adadad; font-style: italic;">; clear carry flag incase there is carry</span><br /><br />SHAFT_0 &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC &nbsp; GPIO,<span style="color: #ff0000;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; check on the changes, 0 or 1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_A11 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; if 1 go savebitA11</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_A10 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;if 0 go savebit A10</span><br />SHAFT_1<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC &nbsp; GPIO,<span style="color: #ff0000;">5</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">; check on gpio 5 changes, channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_B11 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;if 1 go savebit B11</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_B10 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;if 0 go savebit B10</span><br />SHAFT_2<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC &nbsp; GPIO,<span style="color: #ff0000;">4</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;same as above to check to the 4th bit</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_A21 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_A20 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SHAFT_3<br />&nbsp; &nbsp; &nbsp; &nbsp; BTFSC &nbsp; GPIO,<span style="color: #ff0000;">5</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_B21 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SAVEBIT_B20 &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A11<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; if 1 received on shaft channel A move 1 to A11 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVWF &nbsp; A11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; rotate left to make bit 0 avaible for channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_1 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A10<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;if 0 received on shaft channel A move 1 to A11 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVWF &nbsp; A11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;rotate left to make bit 0 avaible for channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_1 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_B11<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; if 1 received on shaft channel B move 1 to A11 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;added up with channel B to form 1 complete bit for</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;each turn, rotate left 2 times for next bit of turn</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; of the encoder<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_2 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_B10<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; same as above ...for 0 bit on channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_2 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br /><br />SAVEBIT_A21<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;if 1 received on shaft channel A move 1 to A21 memory</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;rotate left to make bit 0 avaible for channel B</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_3 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_A20<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;same as above</span><br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_3 &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />SAVEBIT_B21<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000001'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;bit 1 , added up with channel A to form 1 complete bit for</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF &nbsp; A11,<span style="color: #ff0000;">1</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;DIRECTION &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">; direction of the shaft encoder...</span><br />SAVEBIT_B20<br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000000'</span> &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;same as above, but 0 bit received from previous action</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IORWF &nbsp; A11,<span style="color: #ff0000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;DIRECTION &nbsp; &nbsp; &nbsp; <span style="color: #adadad; font-style: italic;">;</span><br /><br /><br />RET_FROM_DIRECTION<br />&nbsp; &nbsp; &nbsp; &nbsp; RLF &nbsp; &nbsp; A11,<span style="color: #ff0000;">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MOVLW &nbsp; <span style="color: #46aa03; font-weight:bold;">b</span><span style="color: #7f007f;">'00000110'</span><br />&nbsp; &nbsp; &nbsp; &nbsp; ANDWF &nbsp; A11,<span style="color: #ff0000;">1</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> &nbsp; &nbsp;SHAFT_2<br /><br /><br /><br /><br /><br /><br /><br />DIRECTION<br />&nbsp; &nbsp; &nbsp; &nbsp; ......<br />&nbsp; &nbsp; &nbsp; &nbsp; ......<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">GOTO</span> RET_FROM_DIRECTION</div></div>]]></description>
<author>sashijoseph&lt;sashijoseph@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 23:26:26 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[Now for the nibble A11 you can have the following valid values<br />0x01,0x07,0x08 and 0x0E representing clockwise direction<br />and<br />0x2,0x04,0x0B,0x0D representing anticlock direction.<br /><br />Thus you need to check the nibble for 1,7,8 or E (hex) for a clockwise rot and 2,4,B or D for anti.<br />Any other value means either no change or invalid... so you need to ignore.<br /><br />In the 'direction' part of the code you need to implement this logic.<br /><br />After that the nibble is rotated left once and 'anded' with 00000110 to save the current AB value(which will now become the previous AB value) and the loop is started again for acquiring  the current AB value.]]></description>
<author>sashijoseph&lt;sashijoseph@nospam.com&gt;</author>
<pubDate>Fri, 20 Jun 2008 23:40:44 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
						<item>
						<title>Re: a code for the shaft encoder</title>
<link>http://www.8051projects.net/forum-t10071.html</link>
<description><![CDATA[<br />Hi nic,<br /><br /> i think SJ nailed it !<br /><br /><br />Arun]]></description>
<author>Arun Kumar V&lt;nura1002003@nospam.com&gt;</author>
<pubDate>Sat, 21 Jun 2008 04:55:39 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t10071.html</guid>
</item>
				</channel>
				</rss>