Previous in Forum: Need Help in Finding Azimuth Sensor for Solar Dish   Next in Forum: Department of C&P
Close
Close
Close
5 comments
Rate Comments: Nested
Associate

Join Date: Sep 2009
Location: Hyderabad, India
Posts: 25

Need Help- Interfacing 10 Bit Gray Code Absolute Rotary Encoder With Arduinouno

10/23/2013 10:26 AM

Dear All,

Am using 1024 resolution, Gray code, positive for CW rotation, npn configuration, 5 V power supply Autonics made absolute rotary encoder. Arduino uno board I/O pins are connected to pull-up resistance. Encoder is powered through 5V DC supply from arduino uno board.

Problem:

The sequence which am getting in gray code is 000, 001, 011, 010, 110, 111, 1111.

The last data is erroneous as it should be 101 instead of 1111 as per gray code. Plz help us where we are going wrong.

Looking forward for valuable replies..

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru
Popular Science - Evolution - New Member Popular Science - Weaponology - New Member

Join Date: May 2006
Location: The 'Space Coast', USA
Posts: 11119
Good Answers: 918
#1

Re: Need help-Interfacing 10 bit gray code absolute rotary encoder with arduinouno

10/23/2013 11:10 AM

The sequence should be 0000 0001 0010 0011 0100 0101 0111

Are you sure you have the right bits/pins assignment?

Maybe this will make more sense:

00 0000 0000
00 0000 0001
00 0000 0010
00 0000 0011
00 0000 0100
00 0000 0101
00 0000 0110
00 0000 0111

Note that the LSB (least significant bit) is the extreme right bit and the MSB is on the extreme left.

Also, note the sequence that each successive bit alternates in state.

Your posted sequence looks like this...

00 0000 0000
00 0000 0001
00 0000 0011
00 0000 0010
00 0000 0110
00 0000 0111
00 0000 1111

That looks like you have some bits swapped because even the LSB is not changing state from 0 to 1 to 0 to 1 correctly. It looks like is the 3rd bit, but starting at a count of 9 or something.

Perform your test again, but this time copy all 10-bits down and do them in a vertical column as I did and make sure every bit is in the correct position.

Register to Reply Score 1 for Good Answer
Guru
Engineering Fields - Electrical Engineering - Hmmm...

Join Date: Jul 2010
Location: Maryland
Posts: 567
Good Answers: 29
#2

Re: Need Help- Interfacing 10 Bit Gray Code Absolute Rotary Encoder With Arduinouno

10/23/2013 12:48 PM

Gray code changes only one bit at a time. Your sequence looks OK as it follows that rule. An encoder with 1024 resolution will be 10 bits. Check to see that the rest of the bits change only one at a time.

There is no single sequence for gray codes. The only stipulation is that only one bit changes at a time through the rest of your 1024 steps.

Register to Reply
Guru
Popular Science - Evolution - New Member Popular Science - Weaponology - New Member

Join Date: May 2006
Location: The 'Space Coast', USA
Posts: 11119
Good Answers: 918
#3
In reply to #2

Re: Need Help- Interfacing 10 Bit Gray Code Absolute Rotary Encoder With Arduinouno

10/23/2013 3:44 PM

Yes, actually, the sequence may be:

Register to Reply Score 1 for Good Answer
Guru

Join Date: Oct 2006
Location: 44.56024"N 15.307971E
Posts: 8277
Good Answers: 270
#4

Re: Need Help- Interfacing 10 Bit Gray Code Absolute Rotary Encoder With Arduinouno

10/23/2013 11:02 PM
__________________
"A man never stands so tall as when he stoops to help a child." "Never argue with a stupid person.They will drag you down to their level and beat you with experience" "To create an apple pie from scratch, first you must create a universe"
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#5

Re: Need Help- Interfacing 10 Bit Gray Code Absolute Rotary Encoder With Arduinouno

10/24/2013 7:00 AM

The encoder manufacturer should give the output sequence in the data sheet.
Build a rig so you can rotate it slowly and accurately. Record the data against the manufacturers data. If they agree ok. If not look to see which bit/bits are wrong.
Is this serial data or parallel?
Serial comms is a huge pain in the ass.

With only 4 bits, parallel would be so much more reliable simple etc.
Yeah I know I'm behind the times... but if you really want to screw it up, you could use a wireless link for added unreliability.

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Register to Reply 5 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

Anonymous Hero (2); HiTekRedNek (1); Lo_Volt (1); user-deleted-1105 (1)

Previous in Forum: Need Help in Finding Azimuth Sensor for Solar Dish   Next in Forum: Department of C&P

Advertisement