Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Looking for Encoder Ideas

Status
Not open for further replies.
Thanks for the added info.

BobW's method also increases the count to 4X the claimed "pulses" per revolution. I figure it is like HP, you can always throttle back. ;)

John
 
Yes some systems that use quadrature encoders will often offer the option of the system reading 1 edge\ pulse or the 2 or 4 to increase the resolution as needed.
Many encoder presently used in positioning have a resolution of 100k counts/rev!
Max.
 
Thanks for the added info.

BobW's method also increases the count to 4X the claimed "pulses" per revolution. I figure it is like HP, you can always throttle back. ;)

John
When making the "state machine" you have to use 4x, otherwise it won't work!
 
Of course, and the reason is obvious. My comment was in relation to post #20 in which it was stated that "some encoders will retain the sine waves and use the Arctangent function to increase the resolution to much higher than the slot count itself." I saw that as an unnecessary complication compared to just looking at the state changes for the range of counts under discussion.

John
 
No problem, considering that I had called you Mr. Al in my last post. :facepalm:
I'm getting my encoder threads mixed up.

Also note that I made a minor edit to the above code.

Hi,

I did that a few times myself :)

That's what the "Edit" button is for, when you make a typo you can correct it just as you did your code.

Back to the Encoders...
I got my 2 bit encoders working so well now that i probably will never need anything better. But i did run into one or two problems...
What if you wanted to use two encoders or use an interrupt for something else?
On the Arduino the lower end boards only have two pins for interrupts, and ONE encoders uses BOTH pins. How would we use a second encoder, or use one of the pins for something else.
For example, i wanted to try to sample a timing signal with one of the interrupts but if both are being used by the encoder, i am not sure how to do this yet.
Any ideas?
 
Here's a little follow-up. My first Bourns encoder died an early death, and DigiKey replaced it. I had seen pictures of how they are made, but I decided to take a look anyway. Here are some pictures. One shows the parts right after popping the back off. There is a little pot accessible from the back, but covered with the label. Then there is the LED and detector and a very nice slotted disk. The rule is in millimeters. One photo shows some silicon. I have no idea what it does except act as the photodetector. Maybe it acts like a comparator to give sharp state changes.

Regards, John

View attachment 95519 View attachment 95520 View attachment 95521View attachment 95522

Nice pics. Looks almost like the inside of a mouse.
 
Hi,

I did that a few times myself :)

That's what the "Edit" button is for, when you make a typo you can correct it just as you did your code.

Back to the Encoders...
I got my 2 bit encoders working so well now that i probably will never need anything better. But i did run into one or two problems...
What if you wanted to use two encoders or use an interrupt for something else?
On the Arduino the lower end boards only have two pins for interrupts, and ONE encoders uses BOTH pins. How would we use a second encoder, or use one of the pins for something else.
For example, i wanted to try to sample a timing signal with one of the interrupts but if both are being used by the encoder, i am not sure how to do this yet.
Any ideas?
If you only need to use the encoder at its base resolution rather than 4X resolution, then you could just use a single interrupt line for one of the encoder outputs and a regular data line for the other encoder output. In that way, the encoder output that is connected to the interrupt input becomes CLOCK, and the other line becomes DATA. Upon interrupt, your ISR need only check the state of the data line, and increment a count variable if DATA=1 and decrement if DATA=0. If you need 2X or 4X resolution, then you could XOR the encoder outputs together. The XOR gate would give a state change when either encoder output changes state. If you can set the Arduino interrupt to trigger on both edges then you could still get 4X resolution. If the interrupt can only trigger on a single edge, then you'd be limited to 2X resolution.
 
Hi there Bob,

That sounds like a good idea. I'll have to experiment with the code a little more to get that single interrupt line to make it work. If that works, at least i'll have one more interrupt.

Funny though i thought these uC chips had several lines that allowed interrupts. I know the low end PIC chips did as i used a couple one time. I wonder if the Atmel 328P chip has more interrupt lines available but not being implemented in the Arduino IDE. I'll have to check this out too.
The way the PIC chips worked is after an interrupt had occurred it would jump to the service routine and there you could check to see what input caused the interrupt so you could enter the service routine for that particular one.

The Due has programmable interrupts even in the Arduino IDE, where you can set the pin number for the interrupt.
 
Hi,

I got some reed switches yesterday and realized it would be interesting to make an encoder using the reed switches. Some of them have life time operation counts in the billions or even higher at low currents.

A raw design would have no detents of course unless we found a way to make them, or else take apart an existing one with detents and mod it with reed switches and a rotating magnet. I was thinking low resolution, where say 10 counts per rev would be good enough. That's probably good enough for knob setting applications like where we want to set the digit of some device from 0 to 9, rotating to get the right number.

Without the indents i guess it might feel a little weird, and a special algorithm to prevent extra false counts or something. With good reed switches though it would probably last a lifetime.

Interestingly, another idea to get the detents would be to use a small stepper motor with shaft extended to mount the magnet, with the reed switches mounted around the diameter. There would have to be as many reed switches as "magnetic detents" and they would have to be aligned to those detent positions. Would be pretty cool i think :)
Probably a very long lifetime.
 
There is a commercial model of a reed switch activated rotary switch but they do not last that long, when used on a daily basis in commercial machines, I have rebuild these for some years now and have tried different types of reed switch.
**broken link removed**

Max.
 
In the past, I've used a star wheel and a magnet to make detents. If you are using something like a magnetic star wheel to trigger the reed switches, then it may be a simple matter to add a fixed piece of iron in close proximity to the wheel to get your detent.
 
BobW
I like that idea. I wish the vendors would offer a non-mechanical detent. Although, in my application, I really didn't need or want a detent. Rare-earth magnets are so strong, they provide a nice tactile feedback.

John
 
There is a commercial model of a reed switch activated rotary switch but they do not last that long, when used on a daily basis in commercial machines, I have rebuild these for some years now and have tried different types of reed switch.
**broken link removed**

Max.


Hi,

That's very interesting. I would have thought it would have long life, but if not then did anyone ever do a comprehensive failure analysis? That could show what is going wrong. A typical early failure mechanism is a break in the seal between a metal lead wire and the glass envelope. It takes a while for the environment to affect it because of that fault but it ends up failing too soon anyway.

I have seen some reed switches fail somewhat soon and others of the same model last a long time. One of the problems is handling the device during mounting. Bending the leads incorrectly, soldering incorrectly, even mounting incorrectly can cause an early failure because of the metal lead/glass interface problem. They have to be treated very gently.

That's for parts that normally stand still in the application. For moving parts such as in aircraft there are other issues. For higher current apps that could be a problem too because the life of the switch is also related to the current relative to the normal rating. For example, at 100ua it may last ten times longer than at 1ma, 100 times longer than at 10ma, even though the switch is rated for 250ma. Of course the voltage relative to the rated voltage will also play a part in it.

In any case, there should have been a comprehensive failure analysis done to determine what exactly is going wrong and what is causing it.

BTW i think what John meant is he would prefer a magnetic detent over a mechanical one.
 
In any case, there should have been a comprehensive failure analysis done to determine what exactly is going wrong and what is causing it.

The problem is they are part of a CNC machining system control, but they are only used as inputs to the PLC section so I would not expect any kind of excessive current causing the failure, as to vibration, they are embedded in silicon rubber and do not experience any bending of the leads when installed.
They typically last around 3 - 5 yrs before a failure of a switch.
Max.
 
Hi again,

Well, it's not all about the application stress on the part, it is also partly about the stress on the part during installation. The leads have to be bent without causing stress on the metal to glass interface. If that is disrupted even a little bit, the future of the device is bleak.
But of course there could be other reasons for the failure too. Being mounted on automatic equipment the question of how many operations per hour they actually have to perform. If the number of operations is high over time then they will fail no matter what we do.
But that is interesting to hear about nonetheless because the question of reliability always comes up with these things. Any feedback on this topic is nice to hear.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top