Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   [Help] Problems with Encoders and PID Control (http://www.chiefdelphi.com/forums/showthread.php?t=135584)

xNovax 08-03-2015 19:47

[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!

cjl2625 08-03-2015 19:53

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) {
                        resetEncoder();

Just an idea

xNovax 08-03-2015 20:01

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.

Thad House 08-03-2015 20:06

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by xNovax (Post 1455175)
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.

Remember all DIOs return true if nothing is attached to them. So if the limit switch came unplugged or went bad, the encoder would be constantly resetting. So if you were trying to test the encoders but had all other DIOs unplugged, the encoder would constantly be getting reset, unless you commented out the reset code.

xNovax 08-03-2015 20:08

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.

Ether 08-03-2015 20:08

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by xNovax (Post 1455175)
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.

Time to get out the voltmeter.



tStano 08-03-2015 20:08

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?

xNovax 08-03-2015 20:10

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Ether (Post 1455181)
Time to get out the voltmeter.



We checked the connections in both of the wires we tested with.

xNovax 08-03-2015 20:11

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by tStano (Post 1455182)
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?

We made sure that both channels were plugged in, I will try the digital input thing once I have access to the robot.

Ether 08-03-2015 20:15

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by xNovax (Post 1455184)
We checked the connections in both of the wires we tested with.

How did you check them?



xNovax 08-03-2015 20:16

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Ether (Post 1455191)
How did you check them?



Beep test (Sorry I don't know the technical term)

Ether 08-03-2015 20:22

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by xNovax (Post 1455192)
Beep test (Sorry I don't know the technical term)

What's a beep test?



E Dawg 08-03-2015 20:25

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Ether (Post 1455194)
What's a beep test?



It's a continuity test, I believe.

Ether 08-03-2015 20:28

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by E Dawg (Post 1455197)
It's a continuity test, I believe.

You can't measure volts with a continuity tester.



tStano 08-03-2015 20:59

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Ether (Post 1455181)
Time to get out the voltmeter.

How would you use the voltmeter to tell whats wrong with the encoder? Just to see that it is indeed getting power and common? The pulses on the output channels will probably be much too fast to be read without an oscilliscope, unless the encoder has really low resolution I suppose. Carry on.

Ether 08-03-2015 22:01

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by tStano (Post 1455224)
How would you use the voltmeter to tell whats wrong with the encoder? Just to see that it is indeed getting power and common?

That's a start.

Quote:

The pulses on the output channels will probably be much too fast to be read without an oscilliscope, unless the encoder has really low resolution
Or unless you rotate it by hand, very very slowly... in which case you should see the signal waveform (especially with an analog voltmeter).



The Lucas 09-03-2015 00:39

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by tStano (Post 1455224)
How would you use the voltmeter to tell whats wrong with the encoder? Just to see that it is indeed getting power and common? The pulses on the output channels will probably be much too fast to be read without an oscilliscope, unless the encoder has really low resolution I suppose. Carry on.

Many multimeters have a "Hz" setting that can be a quick check for encoder output channels, including this one that was offered in First Choice. Spin encoder by hand to test frequency of your outputs (faster spin = higher frequency).

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.

xNovax 09-03-2015 14:07

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by The Lucas (Post 1455321)
Many multimeters have a "Hz" setting that can be a quick check for encoder output channels, including this one that was offered in First Choice. Spin encoder by hand to test frequency of your outputs (faster spin = higher frequency).

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.

Thank you very much for the reply. I will make sure to look for anything in the DIO slots, test the voltage of our DIO slots, and I will see if our multimeter has a Hz mode. I will post back after my meeting tonight to follow up.

jbernardis 12-03-2015 21:33

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by xNovax (Post 1455192)
Beep test (Sorry I don't know the technical term)

A simple continuity test is not enough for a cable. You also need to check the cable for short circuits - a cable with a short can and often does show continuity on each wire.

Our team learned this the hard way.

E Dawg 13-03-2015 14:16

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.

Hoover 23-03-2015 17:19

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.

ozrien 23-03-2015 22:37

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?

Hoover 24-03-2015 06:50

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.

Hoover 24-03-2015 14:56

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.

Ether 24-03-2015 15:17

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461459)
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?

Yes.

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.



Hoover 24-03-2015 16:01

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.

Ether 24-03-2015 16:17

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461707)
Yeah... speaking of voltage, we are not getting any voltage on the power pin for DIO on the roboRio.

Well, the encoder surely is not going to provide a signal without power.

That's why I always urge simple troubleshooting with a voltmeter before spending a lot of time swapping out parts.



Hoover 24-03-2015 16:44

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

Ether 24-03-2015 16:51

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461731)
We get 3.3 volts from power to signal pins. We get no voltage from the power to ground pin.

Where and how are you measuring this? At the RIO DIO with no cable attached?



JamesBrown 24-03-2015 16:56

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461707)
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.

Quote:

Originally Posted by Ether (Post 1461718)
Well, the encoder surely is not going to provide a signal without power.

That's why I always urge simple troubleshooting with a voltmeter before spending a lot of time swapping out parts.



Now that you know why you aren't getting anything from the encoder, it is time to move upstream, and figure out why you aren't getting any power on the DIO pins.

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:

Originally Posted by Hoover (Post 1461731)
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.

Define Normal

Quote:

Originally Posted by Hoover (Post 1461731)
Meanwhile our team is learning to play manually... not bad either

My only concern with this approach is that if the issue is something like a 5V short from debris in the controller, then that debris could move, causing different, potentially worse symptoms.

Hoover 24-03-2015 17:48

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.

Ether 24-03-2015 17:56

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461754)
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

No sarcasm at all intended, but was it also that way when you first did the benchtop checkout of the control system in early January?



Mark McLeod 24-03-2015 19:15

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461754)
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.

That is what is called a sticky fault and just indicates that sometime in the past the battery voltage dropped below the brownout cutoff.

It stays amber through power cycles until you explicitly clear the fault using the roboRIO WebDash.

Hoover 24-03-2015 19:43

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Ether (Post 1461759)
No sarcasm at all intended, but was it also that way when you first did the benchtop checkout of the control system in early January?



Sarcasm is deserved as I was stubborn on the voltage check. But what has happened is largely due to being a rookie to the new tech. (We had signed up for the beta program but didn't make it, so there's that). I had been thinking of deleting my posts due to sheer embarrassment, but it is a learning experience and has at least that merit.


Quote:

Originally Posted by Mark McLeod (Post 1461781)
That is what is called a sticky fault and just indicates that sometime in the past the battery voltage dropped below the brownout cutoff.

It stays amber through power cycles until you explicitly clear the fault using the roboRIO WebDash.

From what I've researched it looks like we clear the sticky fault by doing a self test. I will do that at my next opportunity.

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?

ozrien 24-03-2015 20:29

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)?

Mark McLeod 24-03-2015 20:40

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461792)
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?

The amber status lights on the PDP aren't really a problem, they are just information.
If you clear them to green again, then you can check them after each match to see if you had any brownouts.

Alan Anderson 24-03-2015 21:30

Re: [Help] Problems with Encoders and PID Control
 
Quote:

Originally Posted by Hoover (Post 1461707)
Yeah... speaking of voltage, we are not getting any voltage on the power pin for DIO on the roboRio.

I assume your encoder is intended to be powered from that pin. That would definitely explain why you're not getting the results you want.

Quote:

Originally Posted by Hoover (Post 1461731)
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.

What power light are you referring to? What do you mean by "normal"? The Power LED on the roboRIO ought to be green. It turns red if there is a problem with one of the power buses -- for example, the DIO power pins.

Quote:

We get 3.3 volts from power to signal pins. We get no voltage from the power to ground pin.
That is consistent with something shorting the DIO power bus to ground. The DIO signal pins have a resistor to 3.3 volts. There are two things to check immediately: look for debris in the roboRIO connectors (and remove it if found), and make sure nothing connected to the DIO pins is inappropriately connecting power to ground.

Hoover 17-04-2015 16:23

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