![]() |
Magnetic Encoder Programming Question\Consult
Ok, it is 11:30pm. I have been working on this dilemma off and on since 10am this morning; researching the WPI Library, USFirst Forum, FIRST Forge, Chief Delphi, and NI Communities and i have not been able to figure out if there is a class designed to communicate with the magnetic encoders over PWM. I am looking for something along the lines of the Jaguar class (used to control the Jaguar motor controllers) or the existing encoder class (optical only or requires the usage of 2 channels A and B) but to use the single PWM unfiltered out put from the Magnetic Encoder that was included in the KOP. I have not been able to find anything to date...:( If there is something out there please let me know...:yikes:
With the understanding that there is nothing that I can find that exists already I am looking at creating something to do this task for me. I am thinking of using a Digital Input class with the Get() function (not sure if it will work or what it will 'get' me) or an interrupt in combination with a timer to time the rise and fall of the PWM signal to calculate the time of the pulse. The only other idea i have could be to use the Counter class with the Timer class to accomplish a similar effect. Any way it is after midnight now and my pregnant wife is telling me to shut the light off and go to sleep. So i look forward to your ideas...! Thanks for your help in this mater... John Erdelyan Team 2910 Jack in the Bot |
Re: Magnetic Encoder Programming Question\Consult
The LabVIEW example for the magnetic encoder treats the sensor output as analog. It takes the default analog values and multiplies by 72. It also shows a simple filter to handle rollover.
If you have LV installed, you might run the example so you can debug the wiring and such. Greg McKaskle |
Re: Magnetic Encoder Programming Question\Consult
I spent the better part of a day looking at the magnetic encoder I/O options. We ruled out the analog angle output because of the slow response at the rollover point. I did not give the PWM output much thought. I tried two different approaches for which I am including code samples. The first reads the data digitally using the SPI support and the second uses two analog channels to read the sin/cos outputs (be sure to remove the solder jumper to enable these ports).
Here is the digital one using SPI: Code:
/*Code:
/* |
Re: Magnetic Encoder Programming Question\Consult
Thanks for the help on this. In looking at your code it appears that there are some other functions out there that may work for me as well.
I noticed that this code is in Java but i hope that the functions are names are similar (i remember reading that somewhere). If i get something to work today i will post the code later tonight...! JE |
Re: Magnetic Encoder Programming Question\Consult
Ok, so i wanted to get the PWM working without modifing the chip any more (we already burnt one up). so i played with the code and was able to get code working to sample the PWM on a digital input port of the digital sidecar. i have attached the example below in c++.
Code:
void OperatorControl(void)I hope that this can help somone else who is thinking of doing the same thing...:D John K. Erdelyan Lead Mentor & Programming Mentor Team 2910 |
| All times are GMT -5. The time now is 10:41 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi