Understanding an Optical Shaft Encoder

Hello. I just ordered and received an encoder kit and have been reading up on the fundamentals, but i still have a few questions.
Basic info- plan on using these sensors to calculate position of a moving arm.
only going to be moving the arm 90-120 degrees

  1. I have a somewhat large dear-train for the arm. should i stick the encoder to read the position of the shaft actually turning the ‘final’ gears that move with the arm or should the encoder read the motor shaft’s position? and how will this affect my calculations in programming how long to run a motor to achieve my desired distance? (gear ratio is 3/35 btw)

  2. EasyC is the first programming interface i’ve ever used. ive seen the encoder test and other people’s explanations on how to use the readings of the encoder, but do not understand how to convert what’s been said
    (ex: unsigned long right_encoder;
    unsigned long left_encoder;
    // 1 Revolution = 90 Clicks)
    i’d like to know what some of the encoder commands actually mean.

  3. is it possible to have a program set up so that i could press the up arrow on ch5 (not hold down) and the arm would move to a certain position, then press down to move it back? or is this easier done with limit switches? an example would be nice :slight_smile:

  4. can i have multiple encoders managing different data at the same time? like having one encoder at one point of articulation and another encoder at a different point of articulation? i didnt know if one microcontroller could handle that.

i think what might help me the most is a starter program that i can tinker with, the sample didnt help much

Sorry 'bout the paragraphs
all advice is appreciated :smiley:

If you are purchasing new encoders make sure you update to the latest version of easyC at easyC V2 - Intelitek

1.) If you want a higher resolution then attach the encoder to one of the gears in the gear train. 2 : 1 = 2 X 90 = 180 clicks per revolution. But you could end up with some backlash in the system. Connecting the encoder to the output shaft directly will give you 90 clicks per rev but should reduce any backlash in the system. If you don’t know what backlash is ask Google.

2.)I recommend reading the help file and waiting till you get your encoders, it will all make sence then.

3.)Yes, there is an example in the easyC technical FAQ using a potentiometer which works very similarly to an encoder.

4.)You can run 6 encoders at the same time durring normal programming. You can run 4 using a competition template, because ports 5 and 6 are used for autonomous and operator control jumpers.

Well, i made a program to make my arm go x clicks of the encoder, which works fine, but everything i want my bot to do after that in autonomous doesn’t work. i tried to figure it out, and it looks like only stuff in the while loop is happening. so, i put the rest of my commands in there and it tried to do them all at once.
help?

actually, i just got it to perform the next commands in order by including them in one of my if blocks. but, this time, it doesn’t shut off that next command like i wanted in its wait command, and it just runs till the end of the autonomous period (20sec).
:frowning:

again, answered my own question. stuck a break in the else-if block then added a new function containing my next commands. :slight_smile:

Glad to help… :stuck_out_tongue: