Idea for monostable but triggerable square pulse generator

Thread Starter

spookydd

Joined Aug 12, 2013
45
Hi all,
I'm looking for ideas for a monostable square pulse generator, that would be triggerable at will, by a cpu/mcu, either on a falling or rising edge for the trigger, and the pulse width should be programmable in width, in microseconds.
The output should be TTL compatible, and the pulse width can be programmed in microseconds by a 16bit value, that can be latched by the mcu/cpu.
This could be done in fpgas of course, even the mcu/cpu part, but I'm only aiming at a discrete design, possibly using a Z80 for cpu, but that could very well be a 6502, 6800 or even some 8051 or similar (through hole parts, no smt, for easy hobby build).
The way I see it, the cpu would be able to chip select that circuit to either want to latch the 2 bytes of pulse length, or trigger the pulse that was programmed into it, at will.
Of course this can be done with a bunch of circuits, but is there an elegant and simple solution not requiring too much circuit complexity?
Any ideas?
Thanks
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
I understand that, and my goal is to not link the calibration of the pulse length to the clock rate of whatever mcu/cpu is used, and so avoid having the program to be the one making the pulse. Besides, the pulse generated by program would not have an accurate length as desired but rather be a multiple of the clock rate, which is one thing I'm trying to avoid.
 

crutschow

Joined Mar 14, 2008
34,411
You need to do it digitally with a clock period that's at least 65,536 times the minimum pulse width, to get 16 bit accuracy.
It can't practically be done in analog, as Albert noted.
 

AnalogKid

Joined Aug 1, 2013
11,037
16 bit accuracy and 16 but range are two different things. A latch, comparator, counter, and 1 MHz oscillator can give a 65535:1 output pulse width range in 1 us increments, but if the oscillator frequency is +/-5% accurate (extreme example), all pulse widths will be also. I think this is what the TS is after.

You can do this with fewer chips by using programmable down counters and test for roll-under.

ak
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
Quite right. I was not looking for 16 bit accuracy, but the range, with each increment being 1us, and this not being dependent on a processor clock, so it would not matter if it was running off of a 1mhz 6502 or a Z80A at 4mhz. This is why I'm trying to avoid the pulse width being entirely generated by program, to be totally independent on the processor's clock cycle.

Yes for the latch, that was my thinking, and it can have 2 address location to latch 2 bytes, one at a time, easy to handle from a cpu/mcu.

I was at first thinking about using a timer, such as a CTC from a Z80, but that's overkill for complexity and dependent on the Z80 only. Although I am indeed contemplating the Z80 as the cpu to run this, I may also want to use others.

Ultimately, the whole thing could be put into an fpga, processor and all, but not the initial goal. I want to aim for all through hole parts, no smt, for easy hobby build, even by older hobbyists such as myself, who's lost some dexterity and eyesight over the years.

fpgas are super cool and it's astounding what we can cram in them, but it's not within reach of the average hobbyist.

I'm thinking there must be some clever and elegant way to do this without too much complexity and minimize the part count. All while making this adaptable to whatever cpu/mcu we choose.
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
16 bit accuracy and 16 but range are two different things. A latch, comparator, counter, and 1 MHz oscillator can give a 65535:1 output pulse width range in 1 us increments, but if the oscillator frequency is +/-5% accurate (extreme example), all pulse widths will be also. I think this is what the TS is after.

You can do this with fewer chips by using programmable down counters and test for roll-under.

ak
I was entertaining several possible ways to generate the pulse itself, while it has to be digitally calibrated, it could be generated by some analog method and its length digitally driven. But this idea of the down counter is a pretty good one, and that pulse would be entirely digital.

It does require its own clock though.

How simple can we make something like this?

A latch with some TTL ICs like the 74374 or similar would do the trick to make the 2 registers for the 16 bit driven pulse length parameter.

That 16 bit word can then be used to start the down counting. I guess if we have a 5% accuracy on the clock it would be close enough.
 

AnalogKid

Joined Aug 1, 2013
11,037
5% is very sloppy; a 555 can do better, they are not all that accurate. Since the required pulse width range is a secret, it's hard to say whether or not a crystal oscillator solution would work.

Again, with presettable down-counters, separate latch parts are not needed. Unless there are other system requirements...

If you really want to use latch parts, 16 bit bus latches are available single-chip.

ak
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
5% is very sloppy; a 555 can do better, they are not all that accurate. Since the required pulse width range is a secret, it's hard to say whether or not a crystal oscillator solution would work.
Well, instead of a crystal for clock, perhaps a 555 could be a better choice, that's fine, if it gets closer to the 1us goal, then the counter would provide more precise pulse lengths.

Again, with presettable down-counters, separate latch parts are not needed. Unless there are other system requirements...
I'm not aware of down-counters that would handle the latching and take in 16 bits. Perhaps you could provide an example?

If you really want to use latch parts, 16 bit bus latches are available single-chip.
That's what I meant by "similar" when mentioning the 374, but if the latching function exists in the counter, then there is no need.

This whole thing could then be fairly simple with a somewhat low part count if a single 555 provides the clock and a counter that latches. Not much else would then be needed exact the addressing stuff on the cpu side.
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
I've been looking for a single chip 16 bits counter that could be used as the down counter, and found posts out there from others seeking that as well, and so far none seem available and the only way could be a couple of 8 bits counters cascaded, or worse yet, something like the 74193, which is only 4 bits, and that would make an unecessary high part count, with 4 chips just for the 16 bits counter with 4 cascaded 193s.

And those would still require a bunch more circuitry around to allow latching the 16 bits word to set the count down, plus a clock circuit... Not so efficient.

However, although it would seem like an overkill, I've been looking into 8 bits mcus like the PIC or those ATtiny from Atmel, that do come in some flavors in DIP cases, not too big and with features to spare. Those can be cheap, and they would do the job with a single chip.

Plus some of those Atmel ATtiny 8bit AVR mcus can be in-system programmed, which would provide possibilities for firware updates if needed.

The main issue is which to choose to limit the interfacing circuitry, and how to program some of them...
 

AnalogKid

Joined Aug 1, 2013
11,037
Well, instead of a crystal for clock, perhaps a 555 could be a better choice, that's fine, if it gets closer to the 1us goal, then the counter would provide more precise pulse lengths.
No, it can't. It can provide longer pulse intervals, but the precision is set by the oscillator accuracy.
I'm not aware of down-counters that would handle the latching and take in 16 bits.
Neither am I. But 4 counter chips that are built from the ground up for this specific application are as simple as it gets with discrete parts.


ak
 

AnalogKid

Joined Aug 1, 2013
11,037
something like the 74193, which is only 4 bits, and that would make an unnecessary high part count, with 4 chips just for the 16 bits counter with 4 cascaded 193s.
And those would still require a bunch more circuitry around to allow latching the 16 bits word to set the count down, plus a clock circuit... Not so efficient.
I don't think so. Two 8-bit counters will require external latches *plus* a more chips to form a 16 bit comparator. No way that can be done in 4 chips. The clock oscillator is a separate function, and is independent of the count and compare methods.

ak
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
So far, I'm not seeing many options, and assembling several parts just to do a 16 bit counter, plus its clock and whatever else is needed to program and trigger it from a cpu/mcu, just makes for a higher part count.
I am now more and more leaning towards using a simple mcu just for that function, which can be done with a tiny single chip that has almost everything in it, and that chip can be quite cheap, and much cheaper than the option of multiple parts.
I've been looking at PICs and AVRs, and right now I'm kind of leaning towards the PIC12, because it has a built-in 16 bit counter, its own internal clock, and is a single chip with few leads. The bad part is with its low leads count, it requires more circuitry just for the main cpu/mcu to access it.
So perhaps the better compromise would be a somewhat larger case, with 16 or more pins, but no more than 28, or that chip starts to get a bit too big.
With a chip like that, if the latching can be built-in and 8 bits of data lines can be available, the external circuitry would remain minimal.
I'm examining the PIC12, because maybe it has potential.
One simple mcu like that, can cost in the $1-$2 range, and if nearly nothing else is needed, the simplicity can't be beat.
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
Can't you load the 16-bit value serially into the PIC? That would minimise the number of I/O pins required.
True, but then something is required to serialize that data to feed it to that chip, so that could be mostly software, but then it's a whole bunch of coding just for a simple operation to latch a 16bit word into a chip...
Moving complexity around doesn't reduce it much.
I'm browsing through lots of microcontrollers, like le pic, with more pins to be able to minimize the complexity while not adding more parts.
At the very least, if there is let's say a chip select for that chip, plus an address line to select each half of the 16 bit word to latch, plus the 8 bit data bus, the 2 power lines and the output for the pulse, maybe a 14 pin chip could be used, but it might be good to have an extra signal, such as a WR or something like that, to trigger the latching action, so maybe 16 pins could be best.
There are pics with 18 or 20 pins, which should provide enough lines, and they have the 16 bit counter built in, plus they're rather cheap, most are below $1 if we get a few, so this can be a viable solution. Maybe.
 
Top