CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

rotary encoder

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pcmguy



Joined: 24 Oct 2005
Posts: 5

View user's profile Send private message

rotary encoder
PostPosted: Thu Oct 27, 2005 3:25 am     Reply with quote

I have an 360 pulses rotary encoder from omron (model: e6b2-cw26c), it gives a, b, z output, means I can detect the encoder rotate clockwise and anti clockwise.

So, anybody got the sample program to detect the rotary encoder angle?

Any component need to added in the design (beside pic), any proper wiring diagram?

Thanks!

pcmguy,
neil



Joined: 08 Sep 2003
Posts: 128

View user's profile Send private message

PostPosted: Thu Oct 27, 2005 4:23 am     Reply with quote

I think triggering an external interrupt on each pulse and then looking which phase is high, would do it. I wrote simple code a few years ago which took phase A into the ext interrupt and in there looked at whether phase B was high or low to give direction. This of course gave only half the resolution, which was a bit of a pain because my encoder had detents.

If you EXOR the two phases and use this as your 'rotation' pulse, then look at the relative polarity of A & B (which one leads) this will give direction information. Perhaps the way to go would be to use Port B interrupt on change, rather than the B0 interrupt?

Are you using the Z phase as well for detecting the origin?

Neil.
Ttelmah
Guest







PostPosted: Thu Oct 27, 2005 9:32 am     Reply with quote

Do a search in the archives for 'quadrature'. I posted code to do this on the 18F family some time ago. On the interconnection, it depends actual unit. A look at the data sheet is necessary. However the software solutions all have the potential to miss pulses at higher speeds, and then a hardware solution becomes 'better'. This ranges from a simple bit of logic to do X2 decoding, and feeding the outputs into the conter inputs on the processor, through to using a fully hardware solution like the 7166.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group