![]() |
VEX 393 Encoder Issues
Hello everyone,
We have successfully controlled a VEX 393 IME using the Digital Sidecar in C++, but we are currently having issues with the wiring of the encoder. We have the yellow wire as A and the white wire as B, yet we are not getting any values. Any help would be appreciated! Thanks! |
Re: VEX 393 Encoder Issues
Doesn't that use an I2C communication scheme?
Are you connecting it to the I2C header pins on the Digital sidecar? |
Re: VEX 393 Encoder Issues
No, can you instruct us on how to wire that?
|
Re: VEX 393 Encoder Issues
Hi, I went under the assumption that as an I2C bus device it could not be connected to the DIO portion of the DSC like a regular USDigital encoder.
The encoder cable has white (data), yellow (clock), red (+5V) and black (ground). We made up a female-female connector so that the red maps to the top I2C pin in the DSC (5V), the yellow to the next pin down (SCL), the white to the SDA and the black to ground. I'd appreciate it if you could post your c++ code if you are reading values from the I2C bus. I can read the encoder in java by extending the SensorBase class (trying to mimic devices like the HiTechnicColorSensor and HiTechnicCompass), however the data is not making sense: The returned values for the device information seem to be missing the last byte in each address (getting only 7 of the 8, first clue something's not right!), and when I read the addresses 0x40 upwards (per http://www.vexforum.com/wiki/index.p...Motor_Encoders, compensating for the unsigned integers, I get what looks like individual values in each address which follow the motor rotation but the MSB and LSB rotation tick bits 0x40 and 0x41 seem to be reversed (second clue). I doubt that I am using the I2C read method correctly in that I should be able to read, say 4 bytes in one go, starting at 0x40 and get the first rotation bytes, then combine them to an integer number that counts up and down as the motor moves. Comes out as garbage, third clue. FRC Team 781's experience so far, I'll post if I make any progress. Pat |
Re: VEX 393 Encoder Issues
Quote:
|
Re: VEX 393 Encoder Issues
Certainly, I'll post this morning, there a just a couple of things I want to confirm first at the build site.
Pat |
Re: VEX 393 Encoder Issues
Well, morning turned into a build-related time dilation. Here is the VexIntegratedMotorEncoder.java code, which is certainly not as polished/complete as I would like! Please treat as a work in progress!
Next post will have some usage/warning info. Apologies for posting code this way. Pat Code:
/*----------------------------------------------------------------------------*/ |
Re: VEX 393 Encoder Issues
Continuing the previous post with the Integrated Motor Encoder code:
You plug the first IME into the second (right) set of I2C pins using a jumper cable as mentioned previously. The constructor sets the digital sidecar module number, the address you want to use (there are restrictions on what is allowed), the gearing type ("speed" or "torque" which changes the ticks per revolution), and the desired termination state, true being terminated. I set the first IME to address 0x50/un-terminated and the second to 0x52/terminated. You can see in the code the values which are allowed. When you first plug in and power up the encoder(s), the led light(s) should be flashing orange showing that it is using the default address and is terminated. After you run your Netbeans project, if things work, the first connected encoder should have a green flash every 3 seconds or so, and the second should double flash at about the same rate. This means the first has been readdressed and is not terminated, while the second is also readdressed but is terminated. You then read the encoders with a getRaw() for counts, a get() for degrees (wraps at 360°) and a getRevs for encoder revolutions. You can also reset the encoder to zero. While loading the code, there should be some output messages that show the addresses and termination states as they are configured. Please note that unless you power down the encoders they will keep their last set addresses and termination states, and should still work after disabling and reenabling, as well a power cycle. You can of course comment out the messages. We could not get the encoders to co-exist with a HiTechnic colour sensor plugged into the NXT port. It may work if the sensor connecting cable is short, but we found that that the encoders would not always read consistently with an NXT sensor plugged in. We also found that there appears to be a wiring problem with one of the supplied cables that we are still trying to track down. These cables are now buried in the robot, so I suggest testing a harness ahead of time to attempt to preclude such a problem. Pat |
Re: VEX 393 Encoder Issues
Quote:
|
Re: VEX 393 Encoder Issues
We're having troubles with this code. When the encoder is not plugged in, it seems to pause forever when initialising. (prints "initial device info ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++" and nothing more, freezing the entire code)
Any help? |
| All times are GMT -5. The time now is 11:19. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi