Author Topic: Worthless rotary encoders  (Read 5267 times)

0 Members and 1 Guest are viewing this topic.

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Worthless rotary encoders
« on: April 24, 2021, 02:18:28 pm »
Why would they sell rotary encoders that give pulses on both pins ?
The pins are always high volt.

Am i being ripped off ?
Normally those china encoders work for me,
this time i ordered 100, placed them away for later use, and just found out they are not usable.
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3256
  • Country: gb
Re: Worthless rotary encoders
« Reply #1 on: April 24, 2021, 02:24:49 pm »
Why would they sell rotary encoders that give pulses on both pins ?
The pins are always high volt.

All quadrature encoders give pulses on the two output pins.  You said you are seeing pulses on both pins, but then you say both pins remain at high voltage so I'm not sure what the actual problem is?
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1314
  • Country: us
Re: Worthless rotary encoders
« Reply #2 on: April 24, 2021, 02:56:17 pm »
Post a scope trace.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2555
  • Country: us
Re: Worthless rotary encoders
« Reply #3 on: April 24, 2021, 03:08:08 pm »
The Bourns PEC11 encoders are that way.
  - They have pulses on both lines WHILE being turned.
  - With no movement, both lines are high.
 
The following users thanked this post: tooki

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #4 on: April 24, 2021, 03:11:36 pm »
Hmz, how do i get the movement then ?
It always goes up with my code now.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #5 on: April 24, 2021, 03:13:34 pm »
All quadrature encoders give pulses on the two output pins.  You said you are seeing pulses on both pins, but then you say both pins remain at high voltage so I'm not sure what the actual problem is?

Negative pulses, sorry.
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Worthless rotary encoders
« Reply #6 on: April 24, 2021, 03:17:14 pm »
either you change your code to do the decoding or hardware-decode with a 74HC74; then a rotary encoder behaves like up/down buttons
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #7 on: April 24, 2021, 03:32:16 pm »
Well, i have my code in the main loop, no interrupts.
Hardware no, it is a finished project, i just need some new encoders.

So they are still usable with interrupts, intresting to test in a simple project soon.
Thanks.

Those alps are so expensive i cant afford them.
And mouser has so many options i stopped searching after opening the site.
Just going to order those alps for around 2 euro each, i make very expensive gear now.

Did i miss something when ordering ebay encoders ?
Could i have found out ?
I did not know there are so many options.
« Last Edit: April 24, 2021, 03:34:07 pm by Jan Audio »
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #8 on: April 24, 2021, 03:42:59 pm »
Post a scope trace.

I have a single channel analog scope.
Waiting for a modern scope to come out anytime soon with better specs.
 

Offline HB9EVI

  • Frequent Contributor
  • **
  • Posts: 722
  • Country: ch
Re: Worthless rotary encoders
« Reply #9 on: April 24, 2021, 03:49:53 pm »
personally I don't know any encoders which don't do gray code output, so I'm a bit surprised that you struggle with it now.
never mind whether I used magnetic, optical or mechanical encoders, they all worked the same way, with same code on mcu side
most of my projects run with those cheap china encoders, never had any unexpected behaviour with them
« Last Edit: April 24, 2021, 03:52:28 pm by HB9EVI »
 
The following users thanked this post: tooki

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #10 on: April 24, 2021, 03:53:32 pm »
I have these from ebay :
50PCS Rotary encoder code switch EC11 audio digital potentiometer with switch 5p

ITEM PRICE:
US $22.20

Glad i dont have 100.

What does that EC11 means then ?
Same as the bourns ?
 

Offline Domagoj T

  • Frequent Contributor
  • **
  • Posts: 505
  • Country: hr
Re: Worthless rotary encoders
« Reply #11 on: April 24, 2021, 03:55:10 pm »
Are you sure your code is correct?
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #12 on: April 24, 2021, 03:59:24 pm »
I dont know, what do you mean ?

There is no further info :
https://www.ebay.com/itm/293687768027?hash=item446127b3db:g:V24AAOSwtbpeg2vb
 

Offline Domagoj T

  • Frequent Contributor
  • **
  • Posts: 505
  • Country: hr
Re: Worthless rotary encoders
« Reply #13 on: April 24, 2021, 04:23:54 pm »
You are using some software to monitor the encoder. Are you sure the software is correct?
Show us the code.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7821
  • Country: de
  • A qualified hobbyist ;)
Re: Worthless rotary encoders
« Reply #14 on: April 24, 2021, 04:44:06 pm »
If "EC11" refers to being compatible with ALPS EC11 series then the rotary encoders should have two Gray code steps per detent. However, most cheap rotary encoders have four Gray code steps (complete Gray code sequence) per detent. You can check that also with an inexpensive USB-based logic analyzer, if you don't have a multi-channel scope.
 

Offline wizard69

  • Super Contributor
  • ***
  • Posts: 1184
  • Country: us
Re: Worthless rotary encoders
« Reply #15 on: April 24, 2021, 05:09:34 pm »
Look up the manufacture and part number on google and down load the data sheet.    Right now you have people guessing at what might be the encoders behavior which is not all that useful if the actual device family is not known.

If the encoder doesn't have suitable markings nor the packaging, then I'd call this a lesson learned.   Most likely it isn't the encoder you think it is.

I have these from ebay :
50PCS Rotary encoder code switch EC11 audio digital potentiometer with switch 5p

ITEM PRICE:
US $22.20

Glad i dont have 100.

What does that EC11 means then ?
Same as the bourns ?
 

Offline rhodges

  • Frequent Contributor
  • **
  • Posts: 306
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Worthless rotary encoders
« Reply #16 on: April 24, 2021, 09:58:43 pm »
I have some ALPS rotary encoders, and here are my notes from my library:
Code: [Select]
The ALPS rotary encoder switch has 30 detent positions, each one spaced 12
degrees apart. The three (encoder) pins are A (left), Common, B (right).
Pins A and B should be pulled up to Vcc; 10K resistors are recommended to
keep current under 1mA. Here, the input pins have internal pull-ups of
about 40K.

Both A and B are stable at detent position, and both A and B will have
the same output. When the encoder is rotated clockwise, B will change
first, then A. For counterclockwise, A will change first, then B.

Instead of using Interrupt On Change, poll at a rate often enough to
catch the fastest transitions. One full revolution in half a second
might be a good starting point, which gives 60 pin changes per second,
or one every 16 milliseconds. Oversampling by 4 would give one poll
every 4 milliseconds, which is probably already a timer interrupt.

0.      Read pins A and B, save starting status.

Polling procedure:

1.      Are pins A and B the same?
        NO: Which changed from saved status? Set direction flag. Exit.
        YES: Continue to 2.

2.      Are A and B equal to last saved status?
        YES: Encoder at same detent position. Ignore. Exit.
        NO:  Save new status. Eval direction flag and indicate rotation.
You can see the source code here (it's pretty short):
https://github.com/unfrozen/stm8_libs/blob/master/lib_rotary.c
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline wizard69

  • Super Contributor
  • ***
  • Posts: 1184
  • Country: us
Re: Worthless rotary encoders
« Reply #17 on: April 25, 2021, 09:24:23 am »
I don't have any use for the code right now but I must say I like you commenting style and easy to read code.


You can see the source code here (it's pretty short):
https://github.com/unfrozen/stm8_libs/blob/master/lib_rotary.c
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2417
  • Country: us
Re: Worthless rotary encoders
« Reply #18 on: April 25, 2021, 12:53:06 pm »
I dont know, what do you mean ?

There is no further info :
https://www.ebay.com/itm/293687768027?hash=item446127b3db:g:V24AAOSwtbpeg2vb

I followed your link. What passes for a datasheet is in the 2nd image (I could read it in full screen or zoom modes). With a blowup of the mechanics in the 3rd image.

You can always rig up a test circuit with led's for both outputs. If you turn the shaft very slowly, you should be able to see the expected waveform. If you turn it faster, you should be able to see them both blinking.
« Last Edit: April 25, 2021, 12:59:48 pm by Nusa »
 

Offline rhodges

  • Frequent Contributor
  • **
  • Posts: 306
  • Country: us
  • Available for embedded projects.
    • My public libraries, code samples, and projects for STM8.
Re: Worthless rotary encoders
« Reply #19 on: April 25, 2021, 02:33:45 pm »
I can send you some ALPS encoders. Send me PM if interested.
Currently developing STM8 and STM32. Past includes 6809, Z80, 8086, PIC, MIPS, PNX1302, and some 8748 and 6805. Check out my public code on github. https://github.com/unfrozen
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #20 on: April 25, 2021, 03:09:34 pm »
LOL, thanks.

I will find out, i go solder one of these green/blue ones to a working project.
The total blue ones i always had are good.
 


Online tszaboo

  • Super Contributor
  • ***
  • Posts: 7437
  • Country: nl
  • Current job: ATEX product design
Re: Worthless rotary encoders
« Reply #22 on: April 25, 2021, 03:17:24 pm »
Well, i have my code in the main loop, no interrupts.
If you use a library, you have to call the rotary encoder handler quite often.
Really often.
If you have a display or handle anything slightly demanding, like writing to serial port, then you might already fail to call the handler often enough. Then it skips or it wont work properly. Also, pull up resistors.
 

Offline Jan AudioTopic starter

  • Frequent Contributor
  • **
  • Posts: 820
  • Country: nl
Re: Worthless rotary encoders
« Reply #23 on: April 25, 2021, 03:23:28 pm »
Maybe i should try interrupts then.

Yes i have a display, my other project also works.
Need to order those blue ones i think.

btw : the display dont halt the code, it polls the timer, even for each enable state.
« Last Edit: April 25, 2021, 03:27:02 pm by Jan Audio »
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2555
  • Country: us
Re: Worthless rotary encoders
« Reply #24 on: April 25, 2021, 03:28:25 pm »
Maybe i should try interrupts then.

Yes i have a display, my other project also works.
Need to order those blue ones i think.

Interrupts are for doing a fixed sample rate.
(i.e. NOT Interrupt-On-Change of the pins as I've seen so many do.)
Interrupt-On-Change can overload your processor.

I've found that you pretty much need to sample at 500Hz or faster to avoid missing pulses.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf