Quote:
Originally Posted by kE7JLM
I am in desperate need of help, I have been trying to integrate this compass for a while now with out any luck. At first we used interrupt code to read it, but the RC loop was too slow and did not give a accurate reading.
Thank You!
|
To read the pulse width from the compass you really need to write an interrupt function that uses the internal clock to count when the signal goes high and stop counting when the signal goes low. You can take this count convert it into microseconds (bases on frequency of the controllers internal clock) and then divide that by 100 to get a number in degrees.
I am not sure if you are using it for FIRST but be warned computers and other large metal objects will severely effect the heading of the compass. I am using one for a project for one of my classes, in the room where we have class the magnetic field varies so much that when the car with the compass is told to drive in a straight line you end up driving in a wave like shape. However in better settings (in this case a huge gymnasium) we use the compass with the same control algorithms on a blimp and get much better results.