![]() |
[Help] Problems with Encoders and PID Control
I have run into an issue with an encoder on my teams robot, the encoder was working fine at the beginning of the day but as the day went on the encoder stopped working. Now we cannot get any encoders to work on the robot. Here is what we have tried: Replace the encoder with a new one, change the wire connection to the encoder, changing the DIO port for the encoder, triple checking our code, testing the DIO ports with a limit switch(successful) and power cycling the robot and our drive station.
I have become stumped with what is causing the issue. My mentors seem to think that it is something to do with software but I have checked the code multiple times. Here is our code: https://github.com/Cyberfalcons/robot2015 Here is the class where the encoder is being used: https://github.com/Cyberfalcons/robo...nElevator.java Any help is greatly appreciated! |
Re: [Help] Problems with Encoders and PID Control
I once had a similar problem where I couldn't get a reading out of our lift encoder. It turned out that the limit switch at the bottom was constantly on, so the encoder kept getting reset to zero.
I see this in your code, which looked similar to what I was doing: Code:
else if (getBottom() == true) { |
Re: [Help] Problems with Encoders and PID Control
That should only cause problems if we try to go down when the limit switch is engaged. We have tried hand spinning an encoder that is not attached to any subsystems and it still does not read anything but 0.
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
We tested the limit switches to make sure they were working before we started messing with other stuff.
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
A quadrature encoder will do weird things if both channels are not plugged in. Pretty sure it would read zero. Are both channels plugged in to DIO ports?
Also, did you try inintializing the encoder as a digital input and watching the true/false flash? |
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
Aaron, As others have suggested, checking the voltage supplied to the encoder (as close as you can get the probe to the actual +5 pin on the encoder) is a good start. From some of the symptoms you describe, I suspect you may have a short on the 5v rail of your RoboRIO. There are several more convenient indicators (other than a voltmeter) that will tell you if a short has occurred. These indicators include Red Power Led on the RIO and the RoboRIO webdash. A limit switch does not require 5v power so it is not a good proxy for an encoder in a test. If you do have a short, look for any obvious swarf (metal shavings) that could be causing it. If you can't find any foreign metal shorts, then it is time to unplug everything (one by one) from 5v until it goes away. Inspect the wire with the short to find the source. One of the sneakier causes of a short is the frame violating the insulation of those 3 wire cables. I had a swarf short issue this year that took me a while to resolve the night before bag. Here is a brief summary (highlights on my mistakes) with some dead ends and hours of bot drive time removed. I first noticed the navX MXP board 3.3v LED was off. I removed the navX, expecting to find metal under the board (last time it was the 4-40 lock nut that holds the navX shield on :rolleyes: ), but no short there. Grabbed the multimeter, the 3.3v pin on the MXP tested normal. Confused (I thought the navX used 3.3v input, it uses 5V), I eventually tested the 5V on the MXP. It was 0v, and I was wondering why the MXP 5v pin was not working but the rest of the RIO had 5v (I assumed, but it did not). I slowly connected a massive amount of swarf in the DIO ports (some perfectly coiled around 5v and ground) and then noticed the Red Power LED on the RIO. It is easy to develop tunnel vision when you think you know the cause of the issue, when you need to step back take a look at the bigger picture and test your assumptions along with basic fuctionality. |
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
Our team learned this the hard way. |
Re: [Help] Problems with Encoders and PID Control
Make sure that there are no electrical issues anywhere else on the bot, as well. That has caused issues for us even though it wasn't directly connected to the sensor.
|
Re: [Help] Problems with Encoders and PID Control
This is rather urgent...
Did you ever find the problem with this? This started happening to us and it is wasting all our enbagging time. We tried 3 different encoders We have verified they are spinning We tried different digital ports We rolled back code to where we knew it worked. We recently updated the firmware to the roborio as required. Other than that, we should be in the same state we were when it was working. The problem sounds so similar to the one described in this thread I wonder if it is the same problem. |
Re: [Help] Problems with Encoders and PID Control
You probably already checked but...
Is the encoder getting power (3.3 or 5v?). Don't just inspect the wiring, probe the contact with a voltmeter and measure. Then do the same thing with quadA and quadB. They should drive high then drive low as you rotate the shaft. Basically it should square wave as you turn. What kind of encoder? |
Re: [Help] Problems with Encoders and PID Control
Hi ozrien,
We use Vex shaft encoders. http://www.vexrobotics.com/276-2156.html To test the encoder, we fired up our test robot (uses a cRio) and got valid values from it when turning it by hand. I wasn't surprised by this because if we try 3 encoders and none of them work there is very little chance they are all bad. Next, today's session, I will try it again on our current robot. If it works then the encoder is intermittent possibly due to wiring issues (see below). If it doesn't, we will write a test program for it that tests only the encoder. The best case scenario is that it is our software bug because that will be the easiest to find and fix. If none of this works on the roboRio, how do we test if we are getting output to the digital pins? Can that be done with a volt meter? If we don't see any with our simple program then what? That would seem a fairly serious problem with the hardware. If the roboRio is compromised, we don't have another. Secondly, we use these adapter cable for the encoder. I hate doing it this way and I really wish the encoder came with female ends. This gives multiple points of failure. If these are intermittent they could even be our problem. The alternative is to cut and solder microwires and we've always avoided this. We went all last year with this setup with no problem but it is still worrisome. http://www.vexrobotics.com/vex/produ.../276-2395.html In any case I will report back what we find. |
Re: [Help] Problems with Encoders and PID Control
Were in pretty deep here.
We tried the encoder on the cRio again to verify it works. We tried a new encoder as well and that works. We wrote a program that only reads an encoder. We tried that on different ports. (java) m_encoder = new Encoder(2, 3, true); ... m_encoder.get()... always returns 0. We verified the Encoder class no longer needs .start(); We tried re-running the latest firmware on the roboRio. This did not help. Where is the old firmware for the roboRio? We'd like to try that. |
Re: [Help] Problems with Encoders and PID Control
Quote:
If you have a cheap analog voltmeter use that instead of digital. Just set the voltmeter for the 12 volt scale and measure the voltage between the A channel and ground. Turn the encoder shaft very slowly and you should see the needle go from zero to some positive value. Repeat for B channel. PS it goes without saying (I hope) that the encoder must be powered. |
Re: [Help] Problems with Encoders and PID Control
Yeah... speaking of voltage, we are not getting any voltage on the power pin for DIO on the roboRio.
Any switch we have works because we don't require voltage. We think this is where we are at. |
Re: [Help] Problems with Encoders and PID Control
Quote:
That's why I always urge simple troubleshooting with a voltmeter before spending a lot of time swapping out parts. |
Re: [Help] Problems with Encoders and PID Control
We know about the 'brownout condition' of the roboRio but we don't think it is in that state as the power light is normal.
We get 3.3 volts from power to signal pins. We get no voltage from the power to ground pin. We have a tournament on Friday. We will try to learn as much about it there. Meanwhile our team is learning to play manually... not bad either |
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
Quote:
WHat color is your power LED? Red? If so you probably have a short from 5V to GND Start by unplugging everything, and visually inspect all of the slots to ensure no debris is present. Verify the Power LED is Green, and measure the voltage on the DIO +5V pins again. If you have power now, start looking for your short. Take each connector, one at a time, and verify there is no continuity between pins 2 and 3 on the connector. If there is no continuity, plug it back in and verify that you still have 5V power. If there is continuity, or when you plug it in you lose power, then inspect the cable, and device to find and fix the short. Edit- Apparently I was slow replying. Quote:
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Your concern is warranted. As it is we won't pass inspection.
The LED's on our PDP are blinking amber even when the robot is enabled. The team says they've never been anything different. That would have included our first tournament. I did do a close look for debris. We have been very diligent about debris and chaff this year. We are out of time now. |
Re: [Help] Problems with Encoders and PID Control
Quote:
|
Re: [Help] Problems with Encoders and PID Control
Quote:
It stays amber through power cycles until you explicitly clear the fault using the roboRIO WebDash. |
Re: [Help] Problems with Encoders and PID Control
Quote:
Quote:
My question is, once this is done, will it clear up the problem (assuming it no longer exists). In other words, could everything be ok now but we are still in this condition because we haven't done the clear sticky fault? |
Re: [Help] Problems with Encoders and PID Control
As far as the sticky fault in the PDP, that's just for your diagnostics. If you clear it and then notice it get set again, that just means your PDP saw <6.5 V since the last time you cleared it. That doesn't affect your robot behavior in any way, it's just a trouble code for your sake.
As far as the encoder, did you actually confirm that it wasn't getting power due to the roborio-power-fault (which has nothing to do with the PDP sticky fault)? |
Re: [Help] Problems with Encoders and PID Control
Quote:
If you clear them to green again, then you can check them after each match to see if you had any brownouts. |
Re: [Help] Problems with Encoders and PID Control
Quote:
Quote:
Quote:
|
Re: [Help] Problems with Encoders and PID Control
In the end the roboRio was deemed defective by NI, another one was sent to us, then this one was returned.
Much help was provided by the CSA at our last regional event. We opened the roboRio and found a lot of chaff inside. It was mostly Delron plastic shavings, but it showed us how much chaff can get inside and it was a lot. We should probably have considered some sort of housing for the roboRio, however in this case it was not the problem. The CSA then initiated an RMA with NI while at the event Though we could have done this ourselves, we highly appreciated the help. Since we could find no visible shorts between the pins, there was nothing else we could do. NI concurred hence the RMA. A more fortunate ending would have been to find an actual pin short. In this case we would have expected the power light to change from red to green upon eliminating the short. |
| All times are GMT -5. The time now is 06:30. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi