I am looking for help/advice, I am hoping to use a keysight technoligies HRPG AS16#51c rotary encoder, for a sixteen point wind direction sensor, for my weather station.
It uses quadrature digital output and is a 16cpr smooth running device, No detents
I have connected it to a arduino UNO and have used sketch "InteruptRotator" created by Matthias Hertel. which works well, showing 16 positions for 1 rotation which is what I want, but if I go past the 1st rotation on 2, 3, 4, rotations it counts on 16-17-18-19-20 and so on.
As I want the the 16 positions to represent the 16 different points on a compass ie eg pos 0 = N, 1 = NNE, 2 = NE and so on, how/can I, using a sketch stop it counting past position 15 so you get this :
rotation 1 = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, rotation 2 = 0, 1, 2, 3, 4, 5, and so on.
I hope it can be done, at present I am using a sensor based on using reed switches, which is ok, but I would like to if can be done, use the above encoder, so it will hopefully be more accurate.
Any help and advise will be greatly appreciated,