We're trying to use our encoders. motorD seems to be controlled but motorE acts as if it is not being controlled. The link below is exactly our problem:viewtop...=2774&start=15

It was fixed in ROBOTC 3.54. We are running ROBOTC 3.62

Using the code below, MotorD turns 1/4 revolution at what appears to be 50% power. MotorD seems to behave as expected if you change its values for nMotorEncoderTarget[motorD] or motor[motorD]. On the other hand, MotorE ALWAYS runs at 100% power and ALWAYS turns several full revolutions before it stops when it finally reaches the set target value (negative) as seen in the NXT Device Control Display debugger window. If you change motorE's power setting it is ignored.

Both encoder wires are plugged into the motor controller so the orange wire faces the motor controller's lettering and are plugged into the motors so orange is left-most when looking at and reading the label on the motor. We have tried swapping motor controllers, the encoder cables, and we've hooked up motorD as mtr_S1_C1_2 and motorE as mtr_S1_C1_1 all with the same result. It also does not matter which motor is reversed in the pragma. I've opened up the encoder on motorE and it seems to be installed correctly. We have not swapped the encoders themselves because that would entail pulling off the encoder wheels, which I'm not ready to do.

We are using this power-up sequence:1. Power up 12v to motor controller2. Power up NXT3. Download and run program

I haven't worked with encoders much but you might want to consider this code in the RobotC help section, it seems to achieve something similar to what you want but in a different fashion.

Code:

nMotorEncoder[motorB] = 0; // reset the Motor Encoder of Motor Bwhile(nMotorEncoder[motorB] < 360) // while the Motor Encoder of Motor B has not yet reached 360 counts:{ motor[motorB] = 75; // motor B is given a power level of 75 motor[motorC] = 75; // motor C is given a power level of 75}motor[motorB] = 0; // motor B is given a power level of 0 (stop)motor[motorC] = 0; // motor C is given a power level of 0 (stop)

while(nMotorEncoder[motorD] < 720) // while the Motor Encoder of Motor D has not yet reached 720 counts:{ motor[motorD] = 50; // motor D is given a power level of 50 motor[motorE] = 50; // motor E is given a power level of 50}

motor[motorD] = 0; // motor D is given a power level of 0 (stop)motor[motorE] = 0; // motor E is given a power level of 0 (stop)}

But again, I haven't worked with encoders much so this could very well be wrong, but worth a try possibly

The problem with the examples is that if motorD is working correctly on PID control and motorE is not responding to PID control the two motors run badly out of synch.

The other ---possibly unrelated but don't know --- problem seems to be the encoder values for motorE are incrementing approximately 80x slower than that for motorD. This seems to happen regardless of loop setting.

The only combination that gives me anything that works is running both motors open loop and look only at motorD 's encoder. Through trial and error I found a "multiplier" that when applied to motorE's speed setting it matches motorD pretty well over several feet. It's not an Ideal solution but it works for our limited use and we have to move on.

Very frustrating to spend all this time on something and not be able to make it work or even understand why it's happening..

I will add diagnostics and see what I get. Will the ones suggested give any additional information than to that provided on the NXT Devices debugger window? MotorE encoder is incrementing much slower (and incorrectly) compared to motorD. When under PID control, it also runs at 100% regardless of the speed setting. In summary when motorE is set to PID control it acts as if it is not being controlled at all.

Wed Jan 01, 2014 11:37 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: One Encoder Works; The Other Ones Does Not

It sounds like you may have a defective encoder. Try the following code. It doesn't run the motors but just monitors the encoder readings. Just run the program and manually turn the wheels 1 revolution and see what the readings are.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum