I've Got The Magnetic Encoders Working Over SPI

I just spent a day and half trying to figure out how to access the AS5030 magnetic encoders included in the kit over SPI. I finaly got it working and figured I could save others some time by posting my code here. As far as I can tell, there isn’t an example for this out there anywhere. This isn’t official, this is just the result of one person’s research and tinkering, so don’t trust it too far.

http://www.mediafire.com/file/nmtgyowdtg1/MagEncoderCode.vi

Please tell me what I did wrong and what could be improved.

Nice, is there a particular reason how it worked out to be that “11111” is sent through the SPI?

Thats 11111 binary. The command you send to initiate a read is 00000, but because of the way the breakout board provides a 4 wire interface, commands sent to the encoder are inverted.

You’re correct… there is no official example for using this sensor over SPI.

From looking at your code it looks like you are accessing it correctly. Well done! You could clean it up a bit by choosing Most Significant Bit First in the Advanced Config VI… then you wouldn’t have to reverse the data you get back (don’t forget to change the output command too). I would also make subVIs out of the Open and Get parts of the functionality to make it easier to include in user code and remain encapsulated.

-Joe

For years with the IFI controller there were constant moans about the hardware SPI being tied up. Now that we have SPI there has been little talk about it. Good work. The AS5030 Is ok but there are better solutions out there. Avago makes a absolute magnetic encoder that is inexpensive and would be a good choice for some robo applications. Melix makes a good chip that comes on a demo board. It has some advantages over the Astria micro chip. Using spi can have advantages over the analog types.

Nicely done! I really want to figure out someway to use the absolute encoders and accelerometer in the kit this year just to get the experience of using serial sensors now that we have them and they were free. Congratulations on the bus hacking!

Do you still have this code? I am interested in using the encoder this year and would like to use SPI.

Thanks

Steve

Here’s that file again. Hope it helps!

http://mit.edu/mspatz/www/MagEncoderCode.vi

Hi Techies,
Just I am checking the feasibility of using AS5030 with standard CPU SPI interface to our new design.

From my understanding the FET logic like Adapter board implementation is the way to interface AS5030 in Read/Write mode with standard SPI interface from CPU. I have documented my understanding. Please correct me if anything wrong…

And also can I get the code in viewable in text editor format (MagEncoderCode.vi), looks like it is Labview file and not able to open in text editor.

Thanks
Ranjith

AS5030_SPI_Interface_Understanding.pdf (159 KB)


AS5030_SPI_Interface_Understanding.pdf (159 KB)

I’m going to try and resurrect this thread. I went and found these sensors, and we’re going to try to use them this year for shaft encoding. When I open the VI you posted above, Labview cannot find most of the dependencies that are necessary. Does anyone know if this VI should still work in this year’s copy of Labview, or is there an old dependency that was removed this year?

Thanks in advance!

The location it is looking for the files is the 2009 location. You should be able to find them all in C:\Program Files\National Instruments\LabVIEW 2011\vi.lib\Rock Robotics\WPI

Thank you! I was able to find all of the files except the first couple, “DigitalModule.ctl” “ConfigureAdvancedOptions.ctl” and “DIOChannel.ctl”

Do you know where I can find these?

Thanks again!