Go to Post My suggestion is to first focus in on your drive base. Get it running, and drive it into the ground and see what breaks. Then fix it. Rinse wash and repeat. - Andy A. [more]
Home
Go Back   Chief Delphi > Technical > Programming
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 21-01-2017, 10:54
urg8rb8 urg8rb8 is offline
Registered User
FRC #0108
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Plantation
Posts: 23
urg8rb8 is an unknown quantity at this point
How to interface with absolute encoder using WPILib?

I am using the following absolute encoder:

http://www.mouser.com/ds/2/54/EMS22A-50229.pdf

I has one digital out pin that spits out the position (0-1024) of the encoder. I have used two-channel encoders in the past with no issues but trying to figure out how to use the WPILib classes to read the position of this new absolute encoder. For some reason I'm having troubling finding sample code.

Any help would be greatly appreciated!
Reply With Quote
  #2   Spotlight this post!  
Unread 21-01-2017, 12:33
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 265
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: How to interface with absolute encoder using WPILib?

Quote:
Originally Posted by urg8rb8 View Post
I am using the following absolute encoder:

http://www.mouser.com/ds/2/54/EMS22A-50229.pdf

I has one digital out pin that spits out the position (0-1024) of the encoder. I have used two-channel encoders in the past with no issues but trying to figure out how to use the WPILib classes to read the position of this new absolute encoder. For some reason I'm having troubling finding sample code.
This encoder has a microcontroller in it and so the roboRio needs to generate a clock and chip select to get the serialized data back. There's no built in support for this device in WPILib, but you might try using the SPI class (and the dedicated pins for it), as SPI should be able to generate signaling similar to what this device needs. Hook up SCLK to the clock, CS0 to the chip select, and MISO to the data output. Based on the timing diagram you might need to artifically increase the length of the data and ignore some of the bits to meet the minimum CS timing before and after the data. You'll need to get the clock polarity settings correct for the device as well.

In the worst case you could probably bit-bang it (e.g. drive the clock and chip select pins as DigitalOutputs and use a DigitalInput to read the shifted serial data) but I'd see that as a last resort as it's significantly slower and processor intensive.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)

Last edited by Peter Johnson : 21-01-2017 at 12:35.
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 23:54.

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