Go to Post The Pet Rock was very original, but not necessarily a great thing. - IKE [more]
Home
Go Back   Chief Delphi > Technical > Control System > Sensors
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-02-2016, 18:29
moomoomoo309 moomoomoo309 is offline
Registered User
FRC #0224
 
Join Date: Jan 2016
Location: Piscataway
Posts: 9
moomoomoo309 is an unknown quantity at this point
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.
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2016, 18:38
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 516
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
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.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2016, 19:49
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,986
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: am-2899 Absolute Encoder

Quote:
Originally Posted by moomoomoo309 View Post
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.



Reply With Quote
  #4   Spotlight this post!  
Unread 06-02-2016, 17:08
moomoomoo309 moomoomoo309 is offline
Registered User
FRC #0224
 
Join Date: Jan 2016
Location: Piscataway
Posts: 9
moomoomoo309 is an unknown quantity at this point
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!
Reply With Quote
  #5   Spotlight this post!  
Unread 11-02-2016, 12:36
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,064
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: am-2899 Absolute Encoder

Quote:
Originally Posted by Ether View Post
...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>
Reply With Quote
  #6   Spotlight this post!  
Unread 11-02-2016, 12:55
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,986
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: am-2899 Absolute Encoder

Quote:
Originally Posted by Jared Russell View Post
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?


Reply With Quote
  #7   Spotlight this post!  
Unread 11-02-2016, 13:32
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,064
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: am-2899 Absolute Encoder

Quote:
Originally Posted by Ether View Post
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...
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:28.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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