Author | Matthew Schinkel, copyright © 2017, all rights reserved. |
Adapted-by | |
Compiler | 2.4q6 |
ls7366r is a quadrature encoder counter for counting or keeping track of the position of a optical rotary encoder or linear slide. This device can count signals of TTL type (pulses 90 degrees out of phase) or signals with up/down direction and clock signals. TTL mode is default in this lib.
https://lsicsi.com/datasheets/LS7366R.pdf
Use ls7366r_write(WRITE_MDR0, 0x00) after init() for devices with up/down direction and count clock outputs (not tested).
No dependency found
const LS7366R_EN_CNTR = 0x00;
const LS7366R_INDX_LOADO = 0x30
const LS7366R_LOAD_CNTR = 0xE0
const LS7366R_NQUAD = 0x00
const LS7366R_IDX_FLAG = 0x10;
const LS7366R_WRITE_DTR = 0x98
const LS7366R_NO_FLAGS = 0x00
const LS7366R_WRITE_MDR0 = 0x88
const LS7366R_MODULO_N = 0x0C
const LS7366R_READ_OTR = 0x68
const LS7366R_READ_MDR1 = 0x50
const LS7366R_CLR_STR = 0x30
const LS7366R_RANGE_LIMIT = 0x08
const LS7366R_QUADRX1 = 0x01
const LS7366R_FREE_RUN = 0x00
const LS7366R_BYTE_4 = 0x00;
const LS7366R_READ_STR = 0x70
const LS7366R_INDX_LOADC = 0x10
const LS7366R_DIS_CNTR = 0x04;
const LS7366R_QUADRX4 = 0x03
const LS7366R_INDX_RESETC = 0x20
const LS7366R_LOAD_OTR = 0xE4
const LS7366R_BYTE_1 = 0x03;
const LS7366R_CY_FLAG = 0x80;
const LS7366R_SYNCH_INDX = 0x80
const LS7366R_QUADRX2 = 0x02
const LS7366R_WRITE_MDR1 = 0x90
const LS7366R_BW_FLAG = 0x40;
const LS7366R_BYTE_2 = 0x02;
const LS7366R_DISABLE_INDX = 0x00
const LS7366R_SINGE_CYCLE = 0x04
const LS7366R_CMP_FLAG = 0x20;
const LS7366R_CLR_MDR1 = 0x10
const LS7366R_READ_CNTR = 0x60
const LS7366R_BYTE_3 = 0x01;
const LS7366R_READ_MDR0 = 0x48
const LS7366R_FILTER_2 = 0x80
const LS7366R_ASYNCH_INDX = 0x00
const LS7366R_CLR_MDR0 = 0x08
const LS7366R_CLR_CNTR = 0x20
const LS7366R_FILTER_1 = 0x00
const LS7366R_EN_CNTR = 0x00;
Enable/disable counter
const LS7366R_INDX_LOADO = 0x30
index_load_OL
const LS7366R_LOAD_CNTR = 0xE0
No documentation found
const LS7366R_NQUAD = 0x00
Count modes
const LS7366R_IDX_FLAG = 0x10;
IDX flag
const LS7366R_WRITE_DTR = 0x98
No documentation found
const LS7366R_NO_FLAGS = 0x00
Flag modes
const LS7366R_WRITE_MDR0 = 0x88
No documentation found
const LS7366R_MODULO_N = 0x0C
No documentation found
const LS7366R_READ_OTR = 0x68
No documentation found
const LS7366R_READ_MDR1 = 0x50
No documentation found
const LS7366R_CLR_STR = 0x30
No documentation found
const LS7366R_RANGE_LIMIT = 0x08
No documentation found
const LS7366R_QUADRX1 = 0x01
X1 quadrature mode
const LS7366R_FREE_RUN = 0x00
Running modes
const LS7366R_BYTE_4 = 0x00;
1 to 4 bytes data-width
const LS7366R_READ_STR = 0x70
No documentation found
const LS7366R_INDX_LOADC = 0x10
index_load_CNTR
const LS7366R_DIS_CNTR = 0x04;
counting disabled
const LS7366R_QUADRX4 = 0x03
X4 quadrature mode
const LS7366R_INDX_RESETC = 0x20
index_rest_CNTR
const LS7366R_LOAD_OTR = 0xE4
No documentation found
const LS7366R_BYTE_1 = 0x03;
one LS7366R_mode
const LS7366R_CY_FLAG = 0x80;
CY flag
const LS7366R_SYNCH_INDX = 0x80
synchronous index
const LS7366R_QUADRX2 = 0x02
X2 quadrature mode
const LS7366R_WRITE_MDR1 = 0x90
No documentation found
const LS7366R_BW_FLAG = 0x40;
BW flag
const LS7366R_BYTE_2 = 0x02;
two LS7366R_mode
const LS7366R_DISABLE_INDX = 0x00
Index modes
const LS7366R_SINGE_CYCLE = 0x04
No documentation found
const LS7366R_CMP_FLAG = 0x20;
CMP flag
const LS7366R_CLR_MDR1 = 0x10
No documentation found
const LS7366R_READ_CNTR = 0x60
No documentation found
const LS7366R_BYTE_3 = 0x01;
three LS7366R_mode
const LS7366R_READ_MDR0 = 0x48
No documentation found
const LS7366R_FILTER_2 = 0x80
filter clock frequncy division factor 2
const LS7366R_ASYNCH_INDX = 0x00
asynchronous index
const LS7366R_CLR_MDR0 = 0x08
LS7366R op-code list
const LS7366R_CLR_CNTR = 0x20
No documentation found
const LS7366R_FILTER_1 = 0x00
Clock filter modes
ls7366r_init()
Initialize
ls7366r_reset()
Reset
ls7366r_write(byte in op_code, byte in data)
Write one byte
ls7366r_read(byte in op_code) return byte
Read one byte
ls7366r_read_counter() return dword
Read the counter
18f4620 | 18f4620_quadrature_counter_ls7366r.jal |