English
Language : 

HCTL-2032 Datasheet, PDF (19/20 Pages) Agilent(Hewlett-Packard) – Quadrature Decoder/Counter Interface ICs
Get_2nd:
2nd_old = Pina
'Get current data
2nd_new = Pina
'Get 2nd Data
If 2nd_new = 2nd_old Then
Result_2nd = 2nd_new
'Get stable data
Return
Else
Goto Get_2nd
End If
Get_3rd:
3rd_old = Pina
'Get current data
3rd_new = Pina
'Get 2nd Data
If 3rd_new = 3rd_old Then
Result_3rd = 3rd_new
'Get stable data
Return
Else
Goto Get_3rd
End If
Get_lo:
Lo_old = Pina
Lo_new = Pina
If Lo_new = Lo_old Then
Result_lo = Lo_new
Return
Else
Goto Get_lo
End If
'Get current data
'Get 2nd Data
'Get stable data
Figure 18 Cont. Typical Program for Reading HCTL-2032 with Atmel AVR
ACTIONS
1. At first, Port B4, B5, and B6 are setup for 4X encoding and X/Y axis selection.
2. The HCTL-2032 detects that OE/ are low on the next falling edge of the CLK and asserts the internal inhibit signal. Data
can be read without regard for the phase of the CLK.
3. SEL1 and SEL2 are setup to select the appropriate bytes. The "Get_hi" subroutine is called and the data is read into the
AVR.
4. Step 3 is repeated by changing the SEL1 and SEL2 combinations and specific subroutine is called to read in the
appropriate data.
5. The HCTL-2032 detects OE/ high on the next falling edge of the CLK. The program set OE/ high by writing the correct
value to the respective Port. This causes the data lines to be tristated. On the next rising CLK edge new data is transferred
from the counter to the position data latch.
6. For displaying purposes, the data is arranged in 32-bit data by shifting the MSB to the left through multiplication.
19