Function to translate from two 90 deg shifted triangle waves to a rotation angle?

47 Views Asked by At

I have a dual output endless rotary encoder that varies it's analogue outputs as two triangle wave with a 90 degree phase shift between A and B (see graph below). Can anybody suggest an appropriate transform/function

f(a,b)=angle

enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

Assuming $a,b \in [0,1]$:

$$f(a,b) = \begin{cases} 180a &\text{if }b \geq \frac{1}{2}\\ 180(2-a)&\text{if }b < \frac{1}{2}\end{cases}$$

(Alternatively, note that you can parametrically plot $\langle a(t), b(t)\rangle$ in two dimensions; it will make a diamond shape. You can recover the angle using trigonometry, though this is more work.)