The easiest way is use a keyboard scanner type method to sample the input states using row / column scanners ( not the N key rollover chips)
Then sample all inputs with a frame rate faster than the expected rate and debounce if necessary in s/w.
In the late 70's We would use a MC6800 to address a 1 of 16 decoder with a 1 of 8 decoder for row & column to get 128 inputs on an 8 bit bus in 16 scans. This takes (4+3=) 7 data bits to use a matrix x,y addresses and we used the 8th bit to define if the latched address was an input or an output and thus get 128 outputs as well. So for input ports write address, latch then read back results if 8th bit was = 1=in
Many other ways to do this with CPLD's
In your case there are more than one 74HC165. You can connect the outputs of different HC165 to the same input pin of controller. You have to enable one HC165 at a time scan its inputs and take action based on the input data. As HC165 is a parallel to serial shift register it will be slow. If you use Port expander then with the interrupt signal you will know that the state of the port expander has changed and you can read that port expander only when the change is setected. In HC165 you have to read the chips continuously.
Use Microchip I2C Port expanders. Use either 5 x 8 bit Port expanders or 4 x 16 bit port expanders. For 16 bit port expanders I can write code using mikroC PRO Compiler. Can you use PIC microcontroller instead of 8051?
If you mean the HC165 CLKINH pin, yes. Only SH/nLD, CLK, SER and QH used for the serial interface.So the CE pin can be grounded the whole time right
My pocket calculator keeps insisting 8*5 = 40need 50 input lines then use 5 HC165s and cascade them
int8 sr;
int8 data[NBYTE];
int8 i,j;
SHLD = 0;
// optional delay
SHLD = 1;
for (j = 0, j < NBYTE; j++) {
{
for (i = 0, i < 8, i++) {
sr = (sr << 1) | SI;
CLK = 1;
// optional delay
CLK = 0;
}
data[j] = sr;
}
My pocket calculator keeps insisting 8*5 = 40
#define data_pin portf.f0
#define clk portf.f1
#define pl portf.f2
main()
{
trisf = 0b00000001;
trisb= 0b00000000;
unsigned char data = 0;
clk = 0 ; // portf.f1
pl = 0 ; // portf.f2
//delay() // may need to call a few microsec.delay here, and other marked places too
pl = 1; //portf.f2
//delay()
If(data_pin) // read status of uc pin(which is connected to serial o/p)
data = data+1;
for(i = 0; i < 7; i++)
{
data<<1;
clk = 1;
//delay()
clk = 0;
//delay()
If(data_pin) // read status of uc pin(which is connected to serial o/p)
data = data+1;
}
while(1)
{
portb = data;
}
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 sbit DATA_IN at P1_1_bit; sbit CLK at P1_0_bit; sbit SHLD at P1_2_bit; char byte[7][8]; void Read_Keys() { char i, j; SHLD = 0; Delay_us(500); SHLD = 1; for(i = 0; i < 7; i++) { for (j = 0; j < 8; j++) { if(DATA_IN) byte[i][j] = 1; else byte[i][j] = 0; byte[i][j] <<= 1; CLK = 1; Delay_us(500); CLK = 0; } } } void main() { P0 = 0x00; P1 = 0x02; P2 = 0x00; P3 = 0x00; Delay_ms(200); while(1) { } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?