Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   How to interface with absolute encoder using WPILib? (http://www.chiefdelphi.com/forums/showthread.php?t=154010)

urg8rb8 21-01-2017 10:54

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!

Peter Johnson 21-01-2017 12:33

Re: How to interface with absolute encoder using WPILib?
 
Quote:

Originally Posted by urg8rb8 (Post 1634368)
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.


All times are GMT -5. The time now is 15:31.

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