|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
am-2899 Absolute Encoder
How does one write (java) code to use this encoder? There is only one PWM port, and the Encoder class requires two.
|
|
#2
|
|||
|
|||
|
Re: am-2899 Absolute Encoder
The Encoder class is for a quadrature encoder, which is why it uses two DIO ports (not PWM). The encoder you linked needs to be connected to an analog input. Its output voltage is proportional to the angle.
Here is some psuedo-Java that could be used to get an angle: Code:
AnalogInput encoder = new AnalogEncoder(0); double angle = (encoder.getVoltage() / 5.0) * 360.0; |
|
#3
|
||||
|
||||
|
Re: am-2899 Absolute Encoder
Quote:
The MA3-P10 (and -P12) have PWM output. The FPGA, sampling at 40MHz, certainly is fast enough to detect and accurately time-stamp the edges of a PWM signal, but the FRC FPGA code does not support PWM decoding. |
|
#4
|
|||
|
|||
|
Re: am-2899 Absolute Encoder
Thanks. We looked around and found some Talon encoders which work better, but we'll keep this in mind for the next time we use these encoders!
|
|
#5
|
|||||
|
|||||
|
Re: am-2899 Absolute Encoder
<off-topic>
The FPGA does support this, though the documentation for the semi-period mode feature (at least in the Javadocs) is misleading. There is more accurate documentation here: https://wpilib.screenstepslive.com/s...using-counters I verified last night that I was able to use a pair of counters (one in semi-period mode capturing the rising-to-falling period, and one in normal mode for capturing rising-to-rising period) to measure the duty cycle of the 12-bit PWM MA3. </off-topic> |
|
#6
|
||||
|
||||
|
Re: am-2899 Absolute Encoder
Quote:
|
|
#7
|
|||||
|
|||||
|
Re: am-2899 Absolute Encoder
Quote:
We initially implemented it as two semi-period counters (one for T(on) and one for T(off)), and as you'd imagine, there were synchronization issues near the rollover point... |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|