Armabot turret 240

We are using a Armabot turret 240 with the AS5600 encoder. We are trying to read the position, but when we use the code on the website, https://cdn.shopify.com/s/files/1/1518/8108/files/Armabot_A0085_Turret240_Encoder_Board_RevB.PDF with .getPulseWidthRiseToFallUs(); it doesn’t seem to be giving us values that make sense. We’ve also tried getPulseWidthRiseToFallUs() which at times seem to be giving us consistent values, but other times don’t.

Here is the code we are using just to try to print the position, move the turret for half a second and then print the position again:

System.out.println("Turret Rotator PWM  at start: " + turretRotator.getSensorCollection().getPulseWidthPosition());



turretRotator.set(ControlMode.PercentOutput,.35);

Timer.delay(.5);

turretRotator.set(ControlMode.PercentOutput,0);



System.out.println("Turret Rotator PWM  at end: " + turretRotator.getSensorCollection().getPulseWidthPosition());

Any help is appreciated. Thanks!

We have the same turret, and we couldn’t get the provided encoder to work either. We ended up mounting a different encoder to it all together.

3 Likes

The AS5600 is like a box of chocolates…
Lemme start over.
The AS5600 is a highly programmable device which makes it flexible but mysterious if you don’t know how it’s been programmed.
And we don’t.
What I do know about the AS5600 is that when it comes out of the package from the manufacturer the default programming is for an analog output. We chose to change the 8-pin IC on the encoder board, install the 3-pin header, and use an analog input on the roboRIO.

The easiest way to get data from the AS5600 (if you don’t have the analog version) is to take the AS5600 code provided and make it its own file. So this code would go in its own file

package frc.robot;

import com.ctre.phoenix.motorcontrol.SensorCollection;

/** * Reads PWM values from the AS5600. */
public class AS5600EncoderPwm {
    private final SensorCollection sensors;
    private volatile int lastValue = Integer.MIN_VALUE;

    public AS5600EncoderPwm(SensorCollection sensors) {
        this.sensors = sensors;
    }

    public int getPwmPosition() {
        int raw = sensors.getPulseWidthRiseToFallUs();
        if (raw == 0) {
            int lastValue = this.lastValue;
            if (lastValue == Integer.MIN_VALUE) {
                return 0;
            }
            return lastValue;
        }
        int actualValue = Math.min(4096, raw - 128);
        lastValue = actualValue;
        return actualValue;
    }
}

Then in Robot.java

TalonSRX talon = new TalonSRX(0); //Insert your talon here
AS5600EncoderPwm encoder = new AS5600EncoderPwm(talon.getSensorCollection());

@Override
public void teleopPeriodic() {
   System.out.println(encoder.getPwmPosition());
}

This should give you the absolute value from the sensor. If this doesn’t work just let me know and I’ll help out any way I can.

1 Like

Thanks for sharing, it’s much appreciated!

Yes, we’ve run that exact code and essentially get random values… as the turret rotates in one direction. We even plotted it and with the turret not moving at all, occasionally we get values like -50,000. Sounds like we’ll head the analog route.

That sounds like something may be wrong with the encoder itself or with the wiring, at this point going analog seems to be your best route. If analog doesn’t work properly either you may want to look into a replacement encoder.

Should’ve asked this earlier, but what are you plugging the encoder into?

Talon SRX.

Then my best guess is that something isn’t communicating correctly between the two, the safest option for now would be to try analog. If that doesn’t work my only guess would be a hardware problem in the encoder itself.

Seems reasonable. There were a few posts some weeks back that indicated the digital encoder’s hardware was somehow faulty. We emailed ArmaBot yesterday while in the process of making this CD post and emailed them again today asking how we can get our hands on the analog one. That one’ll connect directly to the Rio, yeah?

That is correct, to one of the 3 pin analog ports. We’ll get that analog encoder out right away.

Thanks! Appreciate this a bunch :slight_smile:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.