74ls165

Anobium

Senior Member
I am not getting the results I expected from a 74LS165. I have tried two different devices both 74LS165.

My code is:

'Recieve a byte from a 74xx165
'OPTIONS PICAXE-08

#PICAXE-08m

symbol latchin = 4
symbol datain = pin3
symbol clk = 2

symbol inbyte = b1
symbol bcounter = b2

pause 1000
sertxd ( "OK" , 13,10)
init:

high latchin 'init latch to hi state
main:

gosub bytein
sertxd ( #inbyte , 13,10)

goto main

bytein:
pulsout latchin,1 'latch the input into -inbyte-
inbyte = 0 'init val to 0
for bcounter = 1 to 8 'count to 8
inbyte = inbyte / 2 'shift right
if datain = 0 then 'test for data
goto nobit 'test for a data bit
end if
inbyte = inbyte | $80 ' set bit 7 of byte var
nobit: pulsout clk,1 ' clock the shift register
next bcounter
return

I do not think there is an error in the code. Yes/No?


Is this an issue with using an LS device? Should I have used an HC device?

And, if the LS is the issue - can I work around the issue by pulling all the 74LS65 input port higher?

Or, I am looking in the wrong place again?

Anobium
 
Last edited:

MartinM57

Moderator
What are you trying to do?
What results are you expecting?
What results are you getting?
What is the circuit schematic?
What about some comments in the code so that it can be peer reviewed for correctness (at both the comment and code levels)?
 

Anobium

Senior Member
Result from bit banging the 74LS165 is constantly 255. The state (high or low) of 74LS165 ports does not change the value. It is constant at 255. Thi code is lifted directly from the Picaxe book but I have added comments.

Results I am expecting? a value of 0 to 31 that represents the state of the 5 inputs. I am not using 3 of the inputs of the 165.

On the 74ls165 I have the pins as follows:
1. Latch
2. Clk

8. 0v
9. Data to pic to Pic Input 3

11 thru 14. State pins. 5v held low via a 10k, I have also tried with no resistor.

15. 0v
16. 5v

Picaxe

Input 3. Data
Out 2. Clk
Out 4. Latch



I think this has something to do with using a LS device rather than an HC device, but, I would like to sort using 74LS165 as I replacing these devices will take days.

Anobium
 
Last edited:

eclectic

Moderator
Result from bit banging the 74LS165 is constantly 255. The state (high or low) of 74LS165 ports does not change the value. It is constant at 255. Thi code is lifted directly from the Picaxe book but I have added comments.
Which book? What code?

If it's David Lincoln's book, then you need to

A. Provide a schematic
B. Provide the full code, with annotations
(as Martin suggests)


e
 

hippy

Technical Support
Staff member
I wouldn't have expected different results from a 74LS165 or a 74HC165. What is your circuit for inputs into the 74LS165 ?
 

Anobium

Senior Member
The scans of the pages from the book. I am certain the code is valid as I have ran thru the simulator and I get the expected results from the simulator.

I am hunting the web for clues....

Thank you for helping.
 

Attachments

srnet

Senior Member
I think this has something to do with using a LS device rather than an HC device, but, I would like to sort using 74LS165 as I replacing these devices will take days.
Maybe, but without a circuit diagram its guesswork.
 

eclectic

Moderator
Look very carefully at the code you posted in #1

Code:
high latchin 'init latch to hi state
main:

gosub bytein
sertxd ( #inbyte , 13,10)

goto main
I've just compared it with page 206 of my copy.

It doesn't match.

Perhaps print out and proof-read your typing?

e

(Who has never made a typo. ;-)

And don't forget to change "loop" to say "looper"
 

Anobium

Senior Member
I had to make changes as the code in the book does not work.

Loop is now a Reserved work and I added an output command.

I think these are the major differences from the book.

Anobium
 

eclectic

Moderator
And I'm confused as well.
In post #3, you stated
"Thi code is lifted directly from the Picaxe book but I have added comments."

But it wasn't.
You'd changed it.

e
 

Anobium

Senior Member
Initially, the pins were not tied down. Then, I tried the 10k pull down. Then, as a result of the web search. Kipton Moravec (the name stated in the web site) was successful using 8k pull downs. Then, as I do not have any 8k resistors, I tried 5k resistors. It does work but I am not sure why from a components point of view.

Re the code. I am sure if I posted the code from the book then you would have told me to correct the code, I was asked to add the comments to the code I was using. I am sorry for misleading you.

Case close.

Thank you everyone.
 
Last edited:

eclectic

Moderator
Initially, the pins were not tied down. Then, I tried the 10k pull down. Then, as a result of the web search. Kipton Moravec (the name stated in the web site) was successful using 8k pull downs. Then, as I do not have any 8k resistors, I tried 5k resistors. It does work but I am not sure why from a components point of view.

Re the code. I am sure if I posted the code from the book then you would have told me to correct the code, I was asked to add the comments to the code I was using. I am sorry for misleading you.

Case close.

Thank you everyone.
See also, the red
text regarding Inputs here:

http://www.kpsec.freeuk.com/components/74series.htm

e
 

Anobium

Senior Member
@eclectic

Thank you. That page is excellent.

The red items refers to the HC device but the LS is as stated below - that root cause of the issue.

Inputs 'float' high to logic 1 if unconnected, but do not rely on this in a permanent (soldered) circuit because the inputs may pick up electrical noise. 1mA must be drawn out to hold inputs at logic 0. In a permanent circuit it is wise to connect any unused inputs to +Vs to ensure good immunity to noise.


:)
 

eclectic

Moderator
@eclectic

Thank you. That page is excellent.

The red items refers to the HC device but the LS is as stated below - that root cause of the issue.

Inputs 'float' high to logic 1 if unconnected, but do not rely on this in a permanent (soldered) circuit because the inputs may pick up electrical noise. 1mA must be drawn out to hold inputs at logic 0. In a permanent circuit it is wise to connect any unused inputs to +Vs to ensure good immunity to noise.


:)
And MY apologies.
I should have removed the "red" word and simply said
Inputs.

That is a very useful site to browse.

e
 

MartinM57

Moderator
I would expect no difference between an LS or HC device in this situation.
Let me just clarify that before I leave the thread...

I would expect no difference between an LS or HC device in this situation, providing that the standard engineering practice of making sure that no inputs are ever "floating' is adhered to. Anyone leaving inputs floating and then complaining that they don't read what they think they should needs to adopt the standard engineering practice ;)
 

Anobium

Senior Member
Point accepted. I am learning all the time, I really am - in a good way. A very good way from all you on this forum.

Most grateful.

Anobium
 

srnet

Senior Member
Inputs 'float' high to logic 1 if unconnected, but do not rely on this in a permanent (soldered) circuit because the inputs may pick up electrical noise. 1mA must be drawn out to hold inputs at logic 0. In a permanent circuit it is wise to connect any unused inputs to +Vs to ensure good immunity to noise.
Posting a circuit diagram is often a good idea.
 

westaust55

Moderator
Check that you have the CE pin (pin 15) on the 74HC165 firmly pulled low (to 0V) otherwise the shift register will not work and you may just see a high bit at the output all the time.
 
Top