Reply by October 26, 20052005-10-26
Hans-Bernhard Broeker wrote:
> Yes. If you have no particular reason for the latch output ever *not* > to provide data to the 7-segment display, you don't need the output > enable signal controlled by the MCU --- so tie it to the 'enabled' > state, which in your case is equivalent to one.
Be very careful with this one! Check the data sheet for your latch and make sure the output enable is level sensitive and not edge sensitive. This is one of the major differences between a "latch" and a "flip-flop" and people often use the terms interchangably when they shouldn't. A D type flip-flop will not propogate the input signal to the output signal without seeing a clock edge! So if you are using a D flip-flop to latch your data you will need to strobe (send a pulse with a high and a low edge) the clock pin. Simply tying the line high or low will NOT work. If you are unsure what kind of hardware you're dealing with, post the part number or a link to the datasheet and we'll check it over. -Will
Reply by Fao, Sean October 25, 20052005-10-25
Hans-Bernhard Broeker wrote:
> Fao, Sean <enceladus311@yahoo.comi-want-no-spam> wrote: > >> I was with you up until the last sentence. By "active state", do you >> mean that I wire the output enable pin to be at a constant high? > > Yes. If you have no particular reason for the latch output ever *not* > to provide data to the 7-segment display, you don't need the output > enable signal controlled by the MCU --- so tie it to the 'enabled' > state, which in your case is equivalent to one.
Well that's almost too simple! And as long as there are no adverse affects, I don't believe I currently have any reason not to have the signal sent as soon as I set the input pin high. Although, I must admit that I can think of at least one example where it would come in handy to have the choice.
> Figuratively speaking: if you have no intention ever to use the brake > on your car, you might as well get rid of the brake pedal to save some > precious legroom. ;-)
With gas prices the way they are, I might as well take off the brake pads, too...it'll cut back on friction and improve fuel economy. Got anything else I can take off? ;-) Thanks again for the help, -- Sean
Reply by Hans-Bernhard Broeker October 25, 20052005-10-25
Fao, Sean <enceladus311@yahoo.comi-want-no-spam> wrote:

> I was with you up until the last sentence. By "active state", do you > mean that I wire the output enable pin to be at a constant high?
Yes. If you have no particular reason for the latch output ever *not* to provide data to the 7-segment display, you don't need the output enable signal controlled by the MCU --- so tie it to the 'enabled' state, which in your case is equivalent to one. Figuratively speaking: if you have no intention ever to use the brake on your car, you might as well get rid of the brake pedal to save some precious legroom. ;-) -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Reply by Hans-Bernhard Broeker October 25, 20052005-10-25
Howard Henry Schlunder <howard_hs@yahoo.com> wrote:

> What you originally thought is correct. I am aware of no > microcontrollers which will behave differently.
Then, as the song goes, you ain't seen nothin' yet. A round of applause, please, gentleman, as the all-time classic 8051 bi-directional port mounts the stage, which at least in some devices/configurations will: 1) drive a logic zero written to the port's register hard enough to make it stay zero (or die trying) 2a) drive a logic one just as hard, but only for a very short moment, and after that 2b) drive it high by only a pull-up resistor roughly in the 100 kOhm range, so a connected device gets a chance to drive it to logic zero by overpowering the pull-up 3) report back not the bit that was last written into the output latch, but rather the actual state of the pin, but yet 4) refer to the most recently written value for read-modify-write style instructions in order to have those behave as expected -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Reply by Howard Henry Schlunder October 25, 20052005-10-25
"Fao, Sean" <enceladus311@yahoo.comI-WANT-NO-SPAM> wrote in message 
news:AOednS6q2IqYzMDeRVn-hg@adelphia.com...
> Scott Moore wrote: >> Fao, Sean wrote On 10/24/05 05:46,: >> >> >>>This is where I start to get confused. What was the point of the latch? >>>Why not just set the bits high/low on my MCU and be done with it? Also, >>>unless I'm missing something, I'll need two bits in addition to the seven >>>that I'm already using for my 7-segment LED display so that I can assert >>>the "input enable" and "output enable" pins when I'm ready for them. >> >> >> If you have a MCU which can set that line to high or low and keep it >> there, >> then the MCU already has a latch, inside the chip, that drives that line, >> so you would be correct in thinking you can do without it. >> > > Quote honestly, I'm not sure; but, I'm guessing that unless it's internal > to the processor (Atmega128) that I my board (MAVRIC-IIB from > http://www.bdmicro.com) does not have one. I'll have to read the > datasheet.
There are indeed output latches internal to the Atmega128 on all I/O ports. If you have control of a pin/port, and you write to it, the value you write will stay there indefiniately until you write a new value.
> Maybe I'm assuming too much because I thought that if I set a pin > high/low, it would just stay there until I said otherwise. I guess this > not true on some MCU's?
What you originally thought is correct. I am aware of no microcontrollers which will behave differently. An output port which is free to change value after you write to it would be completely useless in most applications. If such a microcontroller did exist, it would be clearly documented how to externally latch the output values. The idea behind a microcontroller is to be highly integrated with minimal external parts count to keep final device costs low.
Reply by Fao, Sean October 24, 20052005-10-24
Hans-Bernhard Broeker wrote:

> An 8-bit latch is, basically, just one byte of external dual-ported > static RAM. The MCU can write to it anytime it wants, and a client > (e.g. your 7-segment display) can read from it any time it wants. In > the case at hand, you wouldn't have to control the output enable by > the MCU, though --- you can just tie it to active state.
I was with you up until the last sentence. By "active state", do you mean that I wire the output enable pin to be at a constant high?
> Or you could use a 7-segment display with an integrated latch. Or > even one with an integrated BCD-to-7-segment decode and latch.
Another good suggestion and I'll keep this in mind for the future. Although, for this particular project, I think I'll stay with an external latch so I can --hopefully-- use it for other projects. Also, I already have the 7-segment LED displays ;-). Thank you very much for your reply, -- Sean
Reply by Fao, Sean October 24, 20052005-10-24
larkmore@aol.com wrote:
> Sean, > There a two big reasons to use latches in > microcontroller/microprocessor systems. The first is if you are short > on IO pins on your device. The second is if you are expecting input > that changes faster than you are able to read it. More specificly this > happens with pulse based interrupts. > > A latch is a way of saving a value for later without having to dedicate > resources to it. This will make more sense with some examples based on > the above scenarios. > > In the first case, let's say you have a microcontroller with 16 IO pins > free. At first glance it looks like you could connect at most 16 > signals to the device. But if you get several 8 bit latches and put > their data lines on the same pins, and their enable lines on separate > pins, you can quickly multiply the available outputs. Using the chip > you describe that has two enables per latch chip, you could have four > latches of eight bits each. The data lines remain the same, but you > would choose one chip's enable line at a time to tell it you want to > talk to it. It is very common for systems to use another chip called a > selector/decoder/demultiplexor which further expands the number of > latches you can support. These work by taking a binary input on the > address pins and setting exactly one of its otuputs high or low based > on the binary value. With one of these chips you could then have eight > bits of addressable space or 256 latches with a single enable signle > for each. This binary addressing is actually how most microcontrollers > internal memory mapping is accomplished. For eight bits of data you > can have 256 "locations". > > The second use of latches is when you need to save an incoming signal > that might not last long. For example, if you are monitoring a circuit > that sends you a brief pulse to let you know something occured, like a > motion sensor perhaps, your software may be busy doing something else. > If the pulse has vanished by the time your software checks that pin > again you will miss that information. A latch keeps the data after the > pulse ends and lets the microcontroller check it when its ready. In > this case the latch chose usually has a reset signal that allows it to > be cleared after servicing. Think of it as a mousetrap that catches > and holds the signal until the user comes around and deals with it. >
Your examples have cleared things up a LOT! I have a much better understanding now. Also, another bad assumption of mine was that I was limited by the # of IO pins I had on my board as to how many external devices I could use. And to be honest, I had never ever considered second example. I learned a lot from your post. Thank you very much for your reply, -- Sean
Reply by Fao, Sean October 24, 20052005-10-24
Scott Moore wrote:
> Fao, Sean wrote On 10/24/05 05:46,: > > >>This is where I start to get confused. What was the point of the latch? >> Why not just set the bits high/low on my MCU and be done with it? >>Also, unless I'm missing something, I'll need two bits in addition to >>the seven that I'm already using for my 7-segment LED display so that I >>can assert the "input enable" and "output enable" pins when I'm ready >>for them. > > > If you have a MCU which can set that line to high or low and keep it there, > then the MCU already has a latch, inside the chip, that drives that line, > so you would be correct in thinking you can do without it. >
Quote honestly, I'm not sure; but, I'm guessing that unless it's internal to the processor (Atmega128) that I my board (MAVRIC-IIB from http://www.bdmicro.com) does not have one. I'll have to read the datasheet. Maybe I'm assuming too much because I thought that if I set a pin high/low, it would just stay there until I said otherwise. I guess this not true on some MCU's? Thank you for the response, -- Sean
Reply by Scott Moore October 24, 20052005-10-24
Fao, Sean wrote On 10/24/05 05:46,:

> > This is where I start to get confused. What was the point of the latch? > Why not just set the bits high/low on my MCU and be done with it? > Also, unless I'm missing something, I'll need two bits in addition to > the seven that I'm already using for my 7-segment LED display so that I > can assert the "input enable" and "output enable" pins when I'm ready > for them.
If you have a MCU which can set that line to high or low and keep it there, then the MCU already has a latch, inside the chip, that drives that line, so you would be correct in thinking you can do without it.
Reply by sonos October 24, 20052005-10-24
Somewhere on usenet Mon, 24 Oct 2005 08:04:25 -0700, larkmore wrote:

> The second use of latches is when you need to save an incoming signal > that might not last long. For example, if you are monitoring a circuit > that sends you a brief pulse to let you know something occured, like a > motion sensor perhaps, your software may be busy doing something else. > If the pulse has vanished by the time your software checks that pin > again you will miss that information. A latch keeps the data after the > pulse ends and lets the microcontroller check it when its ready. In > this case the latch chose usually has a reset signal that allows it to > be cleared after servicing. Think of it as a mousetrap that catches > and holds the signal until the user comes around and deals with it.
is the 'pulse' digital or analog, or both? how is your description similar/different from a capacitor's sample and hold for an ~ac signal?