![]() |
JAVA PID with Encoders
Hello all,
We were able to get the PIDController to work great with the gyro but are having problems with the encoders. Here is the part of the code we are using: the problem is when I run autoN it does nothing. The Output class doesn't print nor does the robot move. Quote:
Quote:
|
Re: JAVA PID with Encoders
Mark,
Quote:
This constructor should work: Code:
Encoder(DigitalSource aSource, DigitalSource bSource, boolean reverseDirection) |
Re: JAVA PID with Encoders
Yes they are the usDigital KOP encoders.
You can set them to be 1x 2x or 4x, I have tried all four without success. I have also used that constructor without the "CounterBase.EncodingType.k2X" and it still refused to work. Running encoder.get() the values print fine. |
Re: JAVA PID with Encoders
If you want a working solution now, I suggest writing your own PID controller.
You are using P only, so this should be easy. Code:
output = P * (encoder.get() - setpoint); |
Re: JAVA PID with Encoders
The issue is with the encoder. Because you can use encoders to measure either speed or distance (or both), you need to tell the encoder which measurement to use when the PIDController calls pidGet().
You can do this by adding the line (assuming you want to use distance as your measurement): Code:
LeftEncoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance); |
Re: JAVA PID with Encoders
The kDistance what kind of value does it return with pidGet()?
|
Re: JAVA PID with Encoders
Quote:
|
| All times are GMT -5. The time now is 10:30. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi