74HC165 confusion!
eagletalontim
Posts: 1,399
Good evening all! I am tinkering with a 74HC165 and using the code posted below. When viewing the serial terminal, the output is either all 1's or all 0's.
I am attempting to read 7 switches that output 12V +. I have voltage divider circuits on each input pin that drops the voltage to 2.99V per input pin. The 165 is being powered from the 3.3V rail. The only time I am getting a reading is when I either ground or bring high the 8th input or input "H". According to the datasheet, "Unused inputs must always be tied to an appropriate logic voltage level (e.g., either GND or VCC)." I am using the 3 pin connection method to the Prop : Load, Clock, and Pin 9 on the 165 as the data.
What I am trying to accomplish is to get which pin is high, then run a "CASE" using the select case method according to what pin is high. If more info is needed, please feel free to ask.
_CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 CLOCK = 17 ' Connected to pin 2 of 74HC165 LOAD = 16 ' Connected to pin 1 of 74HC165 DATA = 18 ' Connected to pin 9 of 74HC165 (for inverted data use pin 7) ' The data pin should be connected to the Propeller with ' a 4.7K Ω series resistor. BITS_IN = 8 DEBUG_BAUD = 9_600 DEBUG_HEADING_X = 2 ' Output formatting data DEBUG_HEADING_Y = 2 DEBUG_DYNAMIC_X = DEBUG_HEADING_X + 8 DEBUG_DYNAMIC_Y = DEBUG_HEADING_Y + 2 VAR long xInputs OBJ Pst : "Parallax Serial Terminal" PUB Setup Pst.Start(DEBUG_BAUD) waitcnt(clkfreq * 3 + cnt) ' time to open serial terminal dira[CLOCK] := 1 outa[LOAD] := 1 dira[LOAD] := 1 Pst.Clear Pst.Position(DEBUG_HEADING_X, DEBUG_HEADING_Y) Pst.Str(string("xInputs FEDCBA9876543210", 13)) Pst.PositionX(DEBUG_HEADING_X) Pst.Str(string("------- ----------------", 13)) Pst.PositionX(DEBUG_HEADING_X) Pst.Str(string("Status ................")) MainLoop PUB MainLoop repeat xInputs := 0 ' clear variable to hold input states outa[LOAD] := 0 outa[LOAD] := 1 repeat BITS_IN xInputs <<= 1 xInputs += ina[DATA] outa[CLOCK] := 1 outa[CLOCK] := 0 Pst.Position(DEBUG_DYNAMIC_X, DEBUG_DYNAMIC_Y) Pst.Bin(xInputs, BITS_IN)
I am attempting to read 7 switches that output 12V +. I have voltage divider circuits on each input pin that drops the voltage to 2.99V per input pin. The 165 is being powered from the 3.3V rail. The only time I am getting a reading is when I either ground or bring high the 8th input or input "H". According to the datasheet, "Unused inputs must always be tied to an appropriate logic voltage level (e.g., either GND or VCC)." I am using the 3 pin connection method to the Prop : Load, Clock, and Pin 9 on the 165 as the data.
What I am trying to accomplish is to get which pin is high, then run a "CASE" using the select case method according to what pin is high. If more info is needed, please feel free to ask.
Comments