Using the Cypher Max
The Cypher Max uses the DutyCycleEncoder class from WPILib for absolute reading. View WPILib docs for up to date information. For quadrature reading use the normal Encoder class. WPILib Encoder
Example code​
tip
The Cypher Max Absolute angle increases in the Clockwise direction. The quadrature count increases in the Counter-Clockwise direction.
info
The Cypher Max supports simultaneous use of the Absolute and Quadrature outputs.
Absolute Encoder​
- Java
- C++
import edu.wpi.first.wpilibj.DutyCycleEncoder;
// Using DIO Port 0
DutyCycleEncoder cypherMax = new DutyCycleEncoder(0);
// Get Absolute Angle
SmartDashboard.putNumber("CypherMax", (cypherMax.Get() * 360.0) % 360.0);
#include <frc/DutyCycleEncoder.h>
// Using DIO port 0
frc::DutyCycleEncoder cypherMax{0};
// Get Absolute Angle
frc::SmartDashboard::PutNumber("CypherMax", (cypherMax.Get() * 360.0) % 360.0);
Quadrature Encoder​
- Java
- C++
import edu.wpi.first.wpilibj.Encoder;
// Using DIO port 0 (A) and 1 (B)
Encoder cypher = new Encoder(0, 1, false, EncodingType.k4X);
// Get Raw Count
SmartDashboard.putNumber("Cypher", cypher.getRaw());
#include <frc/Encoder.h>
// Using DIO ports 0 (A) and 1 (B)
frc::Encoder cypher{0, 1, false, frc::CounterBase::EncodingType::k4X};
// Get Raw Count
frc::SmartDashboard::PutNumber("Cypher", cypher.GetRaw());