# counting and tracking revolutions from rotational sensor..

I have a non contact rotational sensor I'm partially using to measure distance traveled.

http://www.digikey.com/product-highlights/us/en/akm-semiconductor-inc-em-3242-one-chip-monolithic/615

The sensor is mounted on the center of a wheel, and I have it outputting to me in degrees. I'm wondering how I can get the program to count each revolution, how to keep track every time it goes from 360 to 1 and the opposite direction from 1 to 360.

I'm not sure how to do this any help appreciated.

I’m wondering how I can get the program to count each revolution, how to keep track every time it goes from 360 to 1 and the opposite direction from 1 to 360.

Are you able to read anything from the sensor now? According to the datasheet, it outputs a voltage relative to the angle. To me, that suggests that what you will get is an analog reading that goes up and then down, as the thing rotates one full circle, peaking at 180 degrees.

But, I could be wrong, and the peak could indeed be ay 360.

The only way to know is to experiment.

See the figure on page 2 of the data sheet. The output voltage describes a sawtooth wave, and makes an abrupt transition between 0 degrees and 360 degrees, going from 10% of the supply voltage to 90% of the supply voltage.

That transition should be pretty easy to detect and count, unless the output "dithers" around 0/360. You would want to add some hysteresis to make sure of counting only one transition.

Yes I can get all the degree outputs like mentioned, unfortunately I messed up and let the smoke out of my sensor, got a few more coming so I can't play with it for a few days.

My sketch is based off this one I found on youtube:

I'm struggling with writing the code to count the revs up and/or down for me and keep track.

Let's say i have a value, sensorOutput, which is degrees to the hundredth, 120.15, for example, and the diameter of the wheel is 1 unit, so each revolution will represent a distance of Pi. Therefore, 360degrees/Pi, gives me 114.59degrees per unit of distance traveled.

So I would take (sensorOutput/114.59) to get my distance if I were only calculating within one revolution.

What I'm unsure how to do is modify that sensorOutput value to incorporate the total # of revs, and know which direction they were in, either from 360 to 1 or 1 to 360..

That is an interesting device, how did you smoke it (so I avoid doing the same thing)?

dmjlambert:
That is an interesting device, how did you smoke it (so I avoid doing the same thing)?

Oh, you know, just hooked my 24V 50A power supply up to it by mistake.