Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Sensors (http://www.chiefdelphi.com/forums/forumdisplay.php?f=173)
-   -   am-2899 Absolute Encoder (http://www.chiefdelphi.com/forums/showthread.php?t=143244)

moomoomoo309 05-02-2016 18:29

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.

Ben Wolsieffer 05-02-2016 18:38

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;

You could also try looking at AnalogPotentiometer, which can do the scaling for you.

Ether 05-02-2016 19:49

Re: am-2899 Absolute Encoder
 
Quote:

Originally Posted by moomoomoo309 (Post 1535709)
How does one write (java) code to use this encoder? There is only one PWM port.

The am-2899 (US Digital part number MA3-A10) has analog output, not PWM, and must be wired to an analog input.

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.




moomoomoo309 06-02-2016 17:08

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!

Jared Russell 11-02-2016 12:36

Re: am-2899 Absolute Encoder
 
Quote:

Originally Posted by Ether (Post 1535743)
...but the FRC FPGA code does not support PWM decoding.




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

Ether 11-02-2016 12:55

Re: am-2899 Absolute Encoder
 
Quote:

Originally Posted by Jared Russell (Post 1538588)
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.

When you do it that way, how do you ask the FPGA to give you the rising-falling and rising-rising from the same cycle?



Jared Russell 11-02-2016 13:32

Re: am-2899 Absolute Encoder
 
Quote:

Originally Posted by Ether (Post 1538598)
When you do it that way, how do you ask the FPGA to give you the rising-falling and rising-rising from the same cycle?



You can't do it atomically to my knowledge. But rising-rising is pretty much constant from one sample to the next (the oscillator is thermally sensitive, so it changes slowly).

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...


All times are GMT -5. The time now is 19:55.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi