Integrated Motor Encoders Only Returning Zero

I’m unable to use most of the functions I’ve written for my robot and have had to use timer based autonomouses for a while because the integrated encoders only return values of zero. They are all plugged in, the lights on all of them are on, and they’ve been configured in robotc. I have two IME’s on my drive, two on my lift, and one on the cube intake.

Is this a problem anybody else has experienced? How do I go about solving this problem?

A copy of my code is attached.
2131C Program.c (13.7 KB)

Use. nMotorEncoder[motorName] < something instead of sensor value( ), but you should still get some numbers.

Also just because the lights are green my experience dose not mean they are plugged in correctly.

The lights are orange…?

Then they are not initialized.

Make sure they are plugged in correctly. Make sure you didn’t accidentally plug into the UART port.

Are you using EasyC or ROBOTC? If EasyC, did you call the initialize function?

I am using ROBOTC.

I am certain they are plugged into the I2C port.

Here’s the weird part, they worked fine at the last competition, but now they don’t work at all.

This happened to us recently (orange lights but were green and functioning previously).

Turned out to be a really stupid thing. We use electrical tape on all of our connections, and the first extension cable from the cortex I2C port to the first IME along the daisy chain had wiggled just a tad loose. It looked connected, but when we removed the tape it was not. We connected it and fixed the problem.

Not saying this is your problem, but thought I would mention it. Sometimes its the stupid things you overlook a hundred times.

One of the wires/extensions could be faulty. Check if any have a split. If it’s contacting metal it might not transfer signals.

In my/our/this team’s experience, sometimes you have to push the wires into the IMEs pretty hard to get them to connect (green lights should mean everything’s good, while orange lights means that they’re connected but probably don’t have a good connection).

Thanks to everyone for replying.

I will check all the wires for shorts etc. The IME for the intake is 8+ feet away from the cortex in wiring. I don’t think that it is the program, because I checked it with a separate cortex and IME, but is there something that I am supposed to initialize if I am using ROBOTC?

No, ROBOTC will initialize the IME as soon as you turn on power to the cortex and the ROBOTC VM runs. An 8 feet run must be at least 8 IME 4-wire cables, to be honest I would say that’s the upper limit and I’ve never tested that far (perhaps the VEX engineers have) but I2C signals were never intended** to be run that sort of distance. As everyone else has suggested, the most likely problem is a connection between two of those cables.

** Why, well, I2C stands for “inter integrated circuit”. It’s a communications bus (quite an old one) designed to be used between two integrated circuits and is most often used for connection within a single PCB (printed circuit board) or perhaps between two PCBs.

I unplugged the Intake encoder, so that just the lift and drive encoders were left. After adjusting the motor and sensors setup to remove the intake encoder, the remaining encoders still had orange lights and returned only zeros. The lift motors are only 3 or 4 feet away from the cortex in wiring. I think it might be the cortex or I2C port on the cortex. After checking all the wires, I will test another cortex and get back to you on that.

Thank you for this information.

Our team uses an IME for a turret on top of our scissor lift. What seems to happen for us is that when we would use 5+ four wire extenders, the IME would not work. We fixed this by using as many extenders as possible, while it still works.(which is 4 or 5) But, in Driver control, we do not need it, so we let the cables unplug. For your problem, I would say get the lift in a position so the IME as close to the cortex as possible, and use as few four wire extenders as possible. Could you just try printing the value of the IME, and moving the motor small amounts, while using less extenders to see if the value changes? Also, before matches, to be safe I always check all of the connections, including into the IME, and into the cortex. I hope this helps!

Have you set up the I2C ports in RobotC in both the Motors and I2C tabs?

Also, it can take some pretty hard pushing to get the wires into the encoder ports. We’re about half as far away as wiring goes, but I don’t think that’s too much of a problem, seeing as you’re getting power.

We had the same problem right before this last tournament. On top of making sure the wiring is good, make sure that in the code, in the list of i2c encoders, they are still set as integrated encoders. Sometime when we reload our code, robotc will randomly reset all the i2cs to no sensor.