Optical Shaft Encoders being used on an arm

So my team has this arm, and we would like to be able to put it in position just by pressing a button on our controller. We think this would be possible using potentiometers, but how would we program it (in Easy C)? Does anyone know how to do this? Thanks.

Can’t help with Easy C, but I will offer this:

The optical shaft encoder is “incremental”, which means it only tells you how much the shaft has moved since you powered up the Vex (and, you need the new ones with two output cables).

To do what you want, you will need a “home” switch that is closed when the arm is in a specific position, usually at one extreme of it’s travel. When you power on your bot, you move the arm toward the home switch until it closes. You now know where your arm is, and the shaft encoder will tell you exactly how far it moves.

An easier alternative is to use the new Vex Potentiometers, which give you an absolute indication of what angle they are at. They can only rotate about 250 degrees, so you wouldn’t use them on a drive wheel to measure distance. They are, however, perfect for your application since the arm will have travel limits.

You read them just like a light sensor, and you’ll have to experiment to figure out which values correspond with the positions you care about.

Cheers,

  • Dean

That is exactly what I need, thank you so much.

If you don’t want to buy more sensors you can still build this.

I can help with easy c

Basically you need to set an rx input on the controller to trigger the auto positioning.

If you push say channel 5 up the value would be like 255 for rx input channel 5 so you would say if rx input = 5 then.

Then your robot would set a motor going until the shaft encoder reaches the desired distance.

Robofreak, how would I set up an if channel 5 (or whatever) statement? Thanks for telling me that, but my team doesn’t actually have an optical shaft encoder, this was just what a team mate of mine was saying we should get to do this arm stuff.

Also, how would I program the potentiometer?

The pot’s electrical resistance changes as a shaft you put through the pot rotates (max rotation angle is about 260 degrees).

Configured for analog input, a Microcontroller port will create and measure a voltage across the pot. This voltage will change as the pot’s reistance changes as the inside of the pot is rotated.

EasyC has an anlog input block. Read the EasyC Help info to learn about how that block works.

Read the pot’s Inventors Guide material to confirm that you know how the pot works and that my leaky memory didn’t forget something or give you the wrong value for how far the pot’s insides can rotate.

As always - Just read the manual and you will find most of what you need to know. Ask tough question here, after reading the manual.

Blake

Definitely use a potentiometer or (I’ve never tested either of these, just going off insticts) possibly a quadrature encoder, now that those exist. Reason being is you need to have an ABSOLUTE positioning system (vs the RELATIVE one you would get with a regular optical shaft encoder). With some clever mounting techniques and some PID programming, you should be able to make this work quite nicely!

Good luck!

You can also do this without any other sensors than a limit switch. All you do is make the arm always go to a default position (which would be after hitting and moving away from the limit switch) and then either just time the movement or else you can use or buy a optical shaft encoder (since I don’t have any quadratic).

Use a pot its so much easier than an encoder. Since a pot will always read the same value when at the right height VS an encoder which will only read how far you moved to get there.

Also if you did not see I think Team #3 Mr. Roboto used them on there robot for the same thing that you are going to do.