Rotary Encoder as sensor of position

Status
Not open for further replies.

Atom07

New Member
Hey guys,

I need to know the angular position a stepper motor is at the moment. Can I do it with a rotary encoder?
 
Yes. However, the more common way to use a stepper is to put a separate switch/optical sensor which closes at just one position per revolution, or one position at the end of stage travel if the motor is driving an X-Y stage. As the motor is stepped, zero out a software up/down counter used to track position. Once zeroed, increment/decrement the counter for each motor step.

If you lose power to the Arduino, and need to re-establish a new starting position, just slew the motor until you get the sensor output, re-zero the software position counter, and you are good to go until the next time you lose power.

I use this technique in a remote antenna tuner I built. I use stepper motors to position both a large variable capacitor, and a larger roller inductor. It re-calibrates itself every time I power it up.
 
For those of you remember the Commodore 64 (and Plus 4) floppy disk drives, they simple drove the stepper 256 steps towards the start of the disk, regardless of where it was - hammering against the physical end stop. They made an awful row every time they did this.
 
Hah. So it just designed to handle the stall and assumed the worst case scenario that it was as far away from the start-point as possible and blindly attempted a full rotation towards it?
 

How can I do it? Must I couple it to the stepper?
I´m curious to know how you used switches with a stepper too.
 
How can I do it? Must I couple it to the stepper?
I´m curious to know how you used switches with a stepper too.
The switches just go to the arduino and let the arduino know that the stepper has reached a known point. From there, the arduino just counts how many times the stepper has been commanded to move away from that known point, and assumes that the stepper moved without issues and nothing can overpower the stepper and move it against itself. So the switches go on whatever mechanical set up the stepper is driving.

If the stepper is spinning something continuously then you can have some kind of switch or indicator that fires whenever the same point is crossed during the rotation.

If the stepper is moving something not in a continuous rotation (like a rail back and forth), then you can put the switch at one end or both ends so that the switch fires whenever the rail reaches the end.

You might have noticed that the arduino just keeps track of how many times the stepper has been commanded to move and just assumes that the stepper did move and nothing stopped the stepper from moving or overpowered and moved the stepper. That means that this method will NOT work if the stepper is expected to encounter a load that is able to overpower the stepper and move against itself. You actually do need an encoder in that case.
 
Last edited:
... That means that this method will NOT work if the stepper is expected to encounter a load that is able to overpower the stepper and move against itself. You actually do need an encoder in that case.

In the antenna tuning unit I built, the tuning capacitor has no stops; it can rotate clockwise or counterclockwise forever without encountering much resistance. The switch closure is found by turning the capacitor shaft clockwise, and can always be found within 200 steps, because the motor has 200 steps per revolution.

In the roller inductor, it takes 14 revolutions of the motor to get from one end of travel to the other. Therefore it can take up to 2800 steps to slew the motor toward its limit switch. Since the inductor is usually parked about 1/3 of the total travel, the starting point usually gets found in fewer steps.
 

My issue is how I can make the switch close. My stepper is couple to a Digital Antenna (TV) so I´m thinkink how I can make it, or what I can couple together to press the switch when the antenna is pointing over it.
 
It doesn't need to be a mechanical switch. It doesn't even need to be coupled to the antenna. As long as the switch is such that it lets you have an absolute reference for the stepper relative to the antenna, you are fine.
 
My issue is how I can make the switch close. My stepper is couple to a Digital Antenna (TV) so I´m thinkink how I can make it, or what I can couple together to press the switch when the antenna is pointing over it.
I am assuming you are using the stepper to change the azimuth (direction) of the TV antenna. I further assume that either you have a very powerful stepper, or you are using some sort of gear train between the output shaft of the stepper and the rotating mast on which the antenna is mounted. If not, you should be using a gear because steppers do not do well when coupled to a rotating load that has a large moment of rotational inertia.

If you use a 200 step per revolution stepper, and a 10:1 gear train, then it would take 2000 steps to move the antenna through 360 degrees. I would mount a microswitch such that it closes when the antenna is pointing due North. Then it will be possible to slew the antenna + or -180 degrees to get to any azimuth from 0 to 359 degrees in the minimum time.

If a mechanical microswitch is closed for a few steps, then average the step number at which the switch closed and step number at which the switch opens while stepping in one direction. Use the step number that is "halfway" between the make and break as the reference position...
 
Last edited:

I´m using a NEMA with 23kgf, no gear. My antenna is not a very high load, it´s very light even, so it´s working well. Yes, it´s 200 steps per revolution, full step.
 
Have you thought of making a gray code absolute position encoder ? Many years ago when I used to play round with the Oscar amateur satelites I made an eight bit gray code encoder (Which gave 256 positions. ) for antenna positioning. it worked very well. I made a large scale drawing and photographically reduced it. It as about 6 inches (150mm) diameter and the tracks ocupied about the outer inch. I had a light source on one side and small photodiodes on the other.

Les.
 
Hah. So it just designed to handle the stall and assumed the worst case scenario that it was as far away from the start-point as possible and blindly attempted a full rotation towards it?

Exactly - bearing in mind there was only 40 tracks (or was it 80?), yet they did 256 steps to ensure they reached the start.

It was really a VERY nasty design.
 
I was told at the time that the 1541 drive was designed as a student project!!

Mike.
 
Presumably they failed the course?.
Why would a student fail a course for doing that? I think it is pretty clever. It makes it possible to index a linear stage being driven by a stepper motor WITHOUT adding a separate limit switch. A stepper doesn't draw hardly any more current if it is stalled compared to running, or even parked, so other than a little noise while the drive re-indexes itself at power up, what is there to criticize?

Actually, this might be the solution to the OP's problem. Assuming that his Over-the-Air TV stations are distributed like mine, I would only have to move the antenna to about three different azimuths, about 30degs, 120deg, and 180deg. I would put a physical stop on the antenna mast at about 25deg. On wake-up, drive the stepper sufficient number of steps (180-25)/1.8 = 87 to guarantee bumping into the stop, then back up either 5, 95, or 155 degrees to position the antenna to the three useful headings...
 
Last edited:
I think it is pretty clever.
.
.
what is there to criticize?
Some would call it crude.
Some would call it crude but effective.
Some would call it cost effective. It was basically a consumer product.

At company where I once worked, an offshoot of a large UK electronics company which was set up to service the offshore oil industry, there was a development department which had a habit of taking on "summer students".
At the behest of the management, who thought that this was a great source of cheap labour, these students would often be given the task of building one-off equipment which was actually deliverable to the client.
Bare in mind that these students were somewhere in the middle of a 3 or 4 year university course, and had a minimum of practical experience.
There were a couple of full time experienced technicians in the department to guide and help them, but even so.

After a student took part in the building of a large control system cabinet with lots of ribbon cables with IDC type connectors at each end, the technicians developed a theory that you should never give a job to a student that you are not prepared to throw away and rebuild from scratch.

By the way, that "large UK electronics company" no longer exists.

JimB
 
I´m thinking about make it with reed switch instead of a mechanical micro switch and put something with a magnet in the antenna then when it cross the switch it closes.
 

You've obviously never used a 1541 disk drive
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…