I am having a problem where my team’s integrated encoders aren’t reading past I2C_1. Can anyone help?
Sure, but I need a bit more than that, usual stuff.
ROBOTC or EasyC? (sounds like ROBOTC)
How many encoders?
What color is the LED on the encoder?
Did you configure them in sensors & motor setup?
are you using nMotorEncoder with the motor port number, don’t use I2C_1 etc. not the way to use them.
this is how the motors/sensors are configured:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl1, Red_Or_Blue, sensorTouch)
#pragma config(Sensor, I2C_1, driveEncRight, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_2, driveEncLeft, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_3, ArmEnc, sensorNone)
#pragma config(Motor, port2, RightMotor, tmotorVex393, openLoop, encoder, encoderPort, I2C_1, 1000)
#pragma config(Motor, port3, LeftMotor, tmotorVex393, openLoop, encoder, encoderPort, I2C_2, 1000)
#pragma config(Motor, port4, leftArmGear, tmotorVex393, openLoop)
#pragma config(Motor, port5, rightArmGear, tmotorVex393, openLoop, reversed)
LEDs are either red, green, or off
It looks like you missed configuring I2C_3, add that to the arm motor and you have this.
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl1, Red_Or_Blue, sensorTouch)
#pragma config(Sensor, I2C_1, driveEncRight, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_2, driveEncLeft, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Sensor, I2C_3, ArmEnc, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port2, RightMotor, tmotorVex393, openLoop, encoder, encoderPort, I2C_1, 1000)
#pragma config(Motor, port3, LeftMotor, tmotorVex393, openLoop, encoder, encoderPort, I2C_2, 1000)
#pragma config(Motor, port4, leftArmGear, tmotorVex393, openLoop, encoder, encoderPort, I2C_3, 1000)
#pragma config(Motor, port5, rightArmGear, tmotorVex393, openLoop, reversed)
Indicating which encoder had which color leds would have been better information, anyway…
In general, if the LED is red/orange then the I2C sensor has not been initialized, check the cables are plugged in correctly.
A working sensor should flash the led green occasionally, the last sensor in the chain will have a double flash. When you run the motors the led should flash green at a faster rate until it stays on constantly at the maximum motor speed. If the led does not turn on when running the motor perhaps you forgot to change the motor gear to the encoded gear.
You would access these three sensors using nMotorEncoder as follows.
nMotorEncoder RightMotor ] or
nMotorEncoder LeftMotor ] or
nMotorEncoder leftArmGear ]
What can you see in the ROBOTC motor debug window when running the motors?
in the debug, I can see the encoder value for I2C_1 change with motor power, but none of the others change. I have moved the location of the sensors in the chain, and added extras, or taken them away with the same result, nothing on I2C_2 or I2C_3.
Then first check all the wires. Connection to the cortex is like this.
Then each encoder has a connection like this, notice how the cable has a different polarity for the output.
Make sure the wires are pushed in all the way and none of the pins are missing. If everything looks good, report back exactly what the led on each encoder is doing, the color, flashing etc.
Are you running the latest version of ROBOTC?
I checked the wires earlier, they’re all in. I only saw green on the first encoder. We are running the latest RobotC. I’m not near the robot now so I can only go from memory. I can remember red LEDs on I2C_2 and I2C_3.
Then they are not initialized, check or replace the cable from I2C_1 to I2C_2. Initialization happens when the cortex is first turned on, you do not even need to run your code for this to happen. Have you tried I2C_2 or 3 independently (swap them into position 1) ?
I have had the same issue of I2C_2 not being read in the Sensor Debug Window. I am only using 2 motors and 2 integrated encoders. The I2C_1 encoder LED is giving a short green flash. It is reading on sensor debug fine. I2C_2 is giving 2 short green flashes. This seems like a correct thing for the last int encoder in the chain to do. However, no readings consistently come into sensor debug. Once, i received some values from I2C_2. Then they stopped. The wire did not seem to be loose. Sensor debug seems to know that I2C_2 exists, but won’t send info. Anyone know the solution to this? Solving this seems necessary for auto straightening.
Is the second IME assigned to a motor? Can you see the IME values in the motors window ?
Which version of ROBOTC are you using? I’ve not seen anything like this before, it sounds like the leds on the IMEs are correct and initialization has happened correctly.
Can you post a simple program that demonstrates the problem?
I have found two cases now where an IME does not provide data, the device on the motor has the correct ‘flash’ code i.e. one blink if in the chain and two blinks if at the end of the chain. but the data from the encoder in the debug window would alternate 1 to 0 or perhaps -1 to 0 I can’t remember now, in both cases all the other IME’s in the chain would report correctly. The first time this happened we got an RMA from VEX and sent back the faulty unit. The latest failure was last week, and although we replaced the motor on the robot, we have not contacted Vex.
So I guess it could possible you have a defective IME. have you any other motors with IME’s you could try instead?
Also it might be obvious but have you verified this IME did work at one time? is it assembled correctly? I once put the gears in wrong and the painted gear was not on top, I got no readings until I swapped the gears and assembled the unit correctly.
Cheers Kb
It’s ironic that this was posted so recently because I just began using IME’s today, so I don’t even have to feel bad reviving this thread.
But anyways…yeah I’m having the same problem.
I’ve got a test robot with me and it has two motors on the drive (one on right and one on left), and two IME’s (one on right and one on left).
I’ve tried the default code and I’ve tried my own. Both of the codes work with the first IME on the daisy chain, but not the next one. So I have tried using each IME separately as the first one on the daisy chain and the first IME reads, but not the next.
Has anyone else been having this problem? I’m still trying to solve it.
The usual questions, which IDE, which version etc. etc.
Have you tried swapping the IMEs (daisy chain order)?
Have you tried each one on it’s own to verify operation?
Did you install the encoder gear correctly?
RobotC v3.62. Not sure what you mean by IDE? The Cortex is fully up to date though.
I have tried swapping the IME order. I have tried each one on its own to verify operation. I did install the encoder gear correctly because they work on their own.
What do you mean by IDE?
Integrated development environment (IDE). I just get tired of saying EasyC or ROBOTC (but there, you made me type it anyway).
So they each work on their own.
Are you sure you plugged the cables in all the way, they can be quite hard to install.
What are the leds doing ? (orange, green, flashing).
Sorry about that. I am using ROBOTC.
Yes the cables are plugged in all of the way. I tried it multiple times and the cable plastic ends are flush with each other pushed fully into the module.
The LED on the first IME (no matter if I plug the left one or right one in first) is going to be slowly blinking green and reading correctly. The second IME on the chain is a red/orange color with a slight tint of green.
I read that if they are that color they are not initializing, but I initialized the first one the same way I initialize the second one.
I have tried three different 4-way wires (not sure of the specific name of the wires) so that shouldn’t be the issue. Each of the three different wires each work with the first IME.
IME is not initialized.
Correct. Your code has nothing to do with initialization, it happens when the cortex is powered and the ROBOTC firmware runs. The IMEs should initialize even if you don’t use them in the code.
To be honest I never upgraded from 3.60 to 3.62. I though that they were the same firmware, but perhaps not. what is the fw version shown on the ROBOTC startup screen ? (ROBOTC 3.60 uses firmware 9.68). It’s probably nothing to do with firmware but best to check.
I will install 3.62 later and test if you have not sorted this out by then.
The only other thing I can think of is a problem with the termination (and I mean the pass through switch) on the IME, but that’s very unlikely.
Any chance you have EasyC (or ConVEX) installed anywhere so we could check them with that ?
The fw version is 9.68, so the same firmware is the same.
I think I already used up the EasyC trial so I’ll install ConVEX right now to test the IME’s in there.
I’ll give you an update when I test it in ConVEX once it installs. In the meantime - do you have any sample code for the IME’s in ConVEX?
Getting ConVEX up and running may take some time of you have not done that before, however, if you are able to get it installed, ConVEX will initialize the IMEs when it runs, the user code does not matter, I suggest you just compile and download one of the demos. Don’t forget to remove any motors that may be different. I don’t really want to get into a tutorial on ConVEX in this thread, my normal recommendation would be to install on top of PROS so you can use their downloader.
It does sound like a hardware problem to me.
Edit:
In fact, if the ROBOTC firmware is the same then I know that it works, installing ConVEX is probably a waste of time for you.
Just installed ConVEX and eclipse and I believe it was everything I should have installed, but it was way over my head haha.
I just installed EasyC and gave it a shot though. Both of the IME’s are reading correctly. So now it appears to be a ROBOTC issue.
EDIT: Is it possible to revert to a previous version of ROBOTC (v3.60 since you said they work in that version)?