Noob Question !!! Re Interfacing to 74HCT164 to Drive LEDS
sk8conz
Posts: 9
I'm a complete Noob to Stamps, so hopefully this has a really easy answer [noparse]:)[/noparse]
I'm trying to use the Stamp (BS2SX) to drive a string of 8 LEDS via a 74HCT164.
I'm started off with the circuit from :-· http://ourworld.compuserve.com/homepages/Bill_Bowden/page5.htm#4017-2.gif· - (see Expandable 16 Stage LED Sequencer).
It uses an 74HC14 schmidt trigger to drive the 74HCT164 (or multiple cascaded ones).·
I want to use the Stamp to replace the 74HC14 so I have more control over the timing and intervals between the string flashing.
I wrote the following code :-
' ==============================================================================
'
' {$STAMP BS2sx}
'
' ==============================================================================
'
' Program Description
'
' Flash 8 LEDS in Sequence connected to a 74HCT164
'
' I/O Definitions
'
DSA CON 8···· ' 164 DSA· Data Input· (DSB tied high)
CP CON 9····· ' 164 CP Clock input (LOW to HIGH edge triggered)
MR CON 10···· ' 164 MR Master Reset
clocks· VAR Byte
dsout VAR Byte ' data to shift to 164
'
' Program Code
'
Main:
dsout = 1
GOSUB flash
GOTO main
END
Flash:
FOR clocks = 1 TO 8················ ' 8 LEDS off 164
HIGH MR···························· ' wake up the 164
SHIFTOUT DSA,CP,MSBFIRST , [noparse][[/noparse]dsout]· ' push the data out
PAUSE 120·························· ' wait
LOW MR····························· ' reset the 164
·dsout = dsout*2
NEXT
RETURN
END
And it drives things fine, the LEDS flash in sequence etc,· but as they advance down the line, the other LEDS that are off have a slight flicker, almost like chattering.··
The discrete component circuit doesn't exhbibit this.
Am I doing something really dumb and obviously wrong ?
Any comments suggestions would be appreciated, or another circuit/ program that can flash upto 40 or 50 LEDS in sequence would also be OK.
Thanks
Darrin
·
I'm trying to use the Stamp (BS2SX) to drive a string of 8 LEDS via a 74HCT164.
I'm started off with the circuit from :-· http://ourworld.compuserve.com/homepages/Bill_Bowden/page5.htm#4017-2.gif· - (see Expandable 16 Stage LED Sequencer).
It uses an 74HC14 schmidt trigger to drive the 74HCT164 (or multiple cascaded ones).·
I want to use the Stamp to replace the 74HC14 so I have more control over the timing and intervals between the string flashing.
I wrote the following code :-
' ==============================================================================
'
' {$STAMP BS2sx}
'
' ==============================================================================
'
' Program Description
'
' Flash 8 LEDS in Sequence connected to a 74HCT164
'
' I/O Definitions
'
DSA CON 8···· ' 164 DSA· Data Input· (DSB tied high)
CP CON 9····· ' 164 CP Clock input (LOW to HIGH edge triggered)
MR CON 10···· ' 164 MR Master Reset
clocks· VAR Byte
dsout VAR Byte ' data to shift to 164
'
' Program Code
'
Main:
dsout = 1
GOSUB flash
GOTO main
END
Flash:
FOR clocks = 1 TO 8················ ' 8 LEDS off 164
HIGH MR···························· ' wake up the 164
SHIFTOUT DSA,CP,MSBFIRST , [noparse][[/noparse]dsout]· ' push the data out
PAUSE 120·························· ' wait
LOW MR····························· ' reset the 164
·dsout = dsout*2
NEXT
RETURN
END
And it drives things fine, the LEDS flash in sequence etc,· but as they advance down the line, the other LEDS that are off have a slight flicker, almost like chattering.··
The discrete component circuit doesn't exhbibit this.
Am I doing something really dumb and obviously wrong ?
Any comments suggestions would be appreciated, or another circuit/ program that can flash upto 40 or 50 LEDS in sequence would also be OK.
Thanks
Darrin
·
Comments
The '164' may have an "output enable" signal -- you should add a line to disable outputs, then shift them, then enable outputs. I think the shift rate of the BS2 is around 20,000 HZ, so shifting 8 bits should take about 400 uSec. (? That seems awfully quick, though -- at 2000 instructions per second, each instruction takes 500 uSec.)
Nope, I've about convinced myself I don't know what's going wrong. You could slow the process WAY down, by adding 'pause DelayVal' lines between each instruction, then changing DelayVal up or down so you can see what's going on.
Edit to post:· I think what's going on is you don't REALLY want to hit 'master reset' all that often.· The original circuit only does it on power up.
Post Edited (allanlane5) : 7/18/2006 5:39:13 PM GMT
I was thinking about it some more and the 164 is behaving exactly as it should.· The problem was me !!!
Each time in the loop I was shifting an entire byte onto the 164.· My out data looks like :-
1
10
100
1000
10000
100000· etc
So the brief flicker was caused as the MSB 1 got shunted along ALL the registers.
The solution is of course to push one bit each cycle.·
You were also right in that there was no point cycling the MR.· Ultimately it wasn't the cause of the problem, but I found I can actually just tie it high and use one less i/o line on the Stamp.
Modified code follows :-
Main:
dsout = 1
GOSUB flash
GOTO main
END
Flash:
HIGH MR····························· ' wake up the 164
FOR clocks = 1 TO 8················ ' 8 LEDS off 164
SHIFTOUT DSA,CP,MSBFIRST , [noparse][[/noparse]dsout\1]· ' push the data out
DEBUG BIN?dsout
PAUSE 100···························· ' wait
·dsout = dsout*2
NEXT
LOW MR····························· ' reset the 164
RETURN
END
Thanks once again for the reply