alternative to CD4538 multivibrator

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
I have a high-speed microcontroller application and I want to hook up a gpio pin on it to an output of a big delay external timer so that I don't have to hold up the microcontroller cpu just to count a long delay.

The perfect approach for me is two monostable multivibrators, because one will be used for the pin and another to refresh the clock on an external flip-flop connected to the micro for other purposes.

I tried the CD4538 chip and for the application it works perfectly, however to pull things off, I have to tie 4 items high from the chip itself... 2 inputs and 2 clear lines. This is a nuisance for PCB development as this forms the letter H under the chip on the board which prevents wires from running through.

I don't want to use another microcontroller to make the timer itself.

I have researched other chips and found 74HC121/123 with the pinout functions the same but in different order.

Is there a chip like the CD4538 but where the clear input and "B" input are internally tied high instead of offered as pins?

I also don't want to leave the inputs floating as unpredictable results can happen.
 

crutschow

Joined Mar 14, 2008
38,504
I have researched other chips and found 74HC121/123 with the pinout functions the same but in different order.

Is there a chip like the CD4538 but where the clear input and "B" input are internally tied high instead of offered as pins?
So what is wrong with the 74HC121/123?
Doe it have the same problem with pullup routing?
Just use a small resistor for the inputs to V+.
 

atferrari

Joined Jan 6, 2004
5,011
I have a high-speed microcontroller application and I want to hook up a gpio pin on it to an output of a big delay external timer so that I don't have to hold up the microcontroller cpu just to count a long delay.
You do not say what micro is that nor its' clock frequency. Please note that high as in "high- speed" and long as in "long delay" are comparison expressions.

I will not be surprised that with just a free timer, little software overhead and judicious programming of interrupts, you could go away with just the micro.

Could you please elaborate?
 

GopherT

Joined Nov 23, 2012
8,009
I have a high-speed microcontroller application and I want to hook up a gpio pin on it to an output of a big delay external timer so that I don't have to hold up the microcontroller cpu just to count a long delay.

The perfect approach for me is two monostable multivibrators, because one will be used for the pin and another to refresh the clock on an external flip-flop connected to the micro for other purposes.

I tried the CD4538 chip and for the application it works perfectly, however to pull things off, I have to tie 4 items high from the chip itself... 2 inputs and 2 clear lines. This is a nuisance for PCB development as this forms the letter H under the chip on the board which prevents wires from running through.

I don't want to use another microcontroller to make the timer itself.

I have researched other chips and found 74HC121/123 with the pinout functions the same but in different order.

Is there a chip like the CD4538 but where the clear input and "B" input are internally tied high instead of offered as pins?

I also don't want to leave the inputs floating as unpredictable results can happen.

You have to learn about interrupts (and interrupt flags) so you don't has to worry about monitoring that pin when the micro has better things to do.
 

Papabravo

Joined Feb 24, 2006
22,082
I have a high-speed microcontroller application and I want to hook up a gpio pin on it to an output of a big delay external timer so that I don't have to hold up the microcontroller cpu just to count a long delay.

The perfect approach for me is two monostable multivibrators, because one will be used for the pin and another to refresh the clock on an external flip-flop connected to the micro for other purposes.

I tried the CD4538 chip and for the application it works perfectly, however to pull things off, I have to tie 4 items high from the chip itself... 2 inputs and 2 clear lines. This is a nuisance for PCB development as this forms the letter H under the chip on the board which prevents wires from running through.

I don't want to use another microcontroller to make the timer itself.

I have researched other chips and found 74HC121/123 with the pinout functions the same but in different order.

Is there a chip like the CD4538 but where the clear input and "B" input are internally tied high instead of offered as pins?

I also don't want to leave the inputs floating as unpredictable results can happen.
How many layers are you using for traces? If one, then you are practicing a false economy.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
You do not say what micro is that nor its' clock frequency. Please note that high as in "high- speed" and long as in "long delay" are comparison expressions.

I will not be surprised that with just a free timer, little software overhead and judicious programming of interrupts, you could go away with just the micro.

Could you please elaborate?
The micro is an AT89C4051 with a 20Mhz crystal attached to it for high speed.Documentation tells me at this rate, I could process 1.6 million instructions a second (about 0.6uS single instruction execution time)

If I were to do a delay in software of one second then I need nested loops to make the chip count from 0 to 1.6 million as follows:

Code:
mov R1,#19h ;25 is highest bit
mov R2,#0h
mov R3,#0h
loop2:
    loop1:
        djnz R3,$
    djnz R2,loop1
djnz R1,loop2
As you can see, that code forces the processor to stop doing useful things for the second.

Yes I could use interrupts which is what I want to connect the output of my external 1 second timer to but its the external timer I need to figure out here.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
How many layers are you using for traces? If one, then you are practicing a false economy.
I'm using a single sided board for 2 reasons:

1. costs less to produce both commercially and at home
2. creating double-sided boards at home is a joke, especially now that clear transparencies are commonly not available like they were years ago
 

Sensacell

Joined Jun 19, 2012
3,784
There are many ways you can implement delays without going into a dedicated delay loop.

Invest the time to learn how to fix this in software, you will not regret it.
 

GopherT

Joined Nov 23, 2012
8,009
The micro is an AT89C4051 with a 20Mhz crystal attached to it for high speed.Documentation tells me at this rate, I could process 1.6 million instructions a second (about 0.6uS single instruction execution time)

If I were to do a delay in software of one second then I need nested loops to make the chip count from 0 to 1.6 million as follows:

Code:
mov R1,#19h ;25 is highest bit
mov R2,#0h
mov R3,#0h
loop2:
    loop1:
        djnz R3,$
    djnz R2,loop1
djnz R1,loop2
As you can see, that code forces the processor to stop doing useful things for the second.

Yes I could use interrupts which is what I want to connect the output of my external 1 second timer to but its the external timer I need to figure out here.
If you are in a loop to kill time, put your command to check the pin inside your loop. Break out of your loop if needed or set a flag to know that a pin went high when you were in the delay loop so you can address the issue when you exit the delay.
 

Papabravo

Joined Feb 24, 2006
22,082
I'm using a single sided board for 2 reasons:

1. costs less to produce both commercially and at home
2. creating double-sided boards at home is a joke, especially now that clear transparencies are commonly not available like they were years ago
Luddites were the original practitioners of false economy. Bless you brother.
 

atferrari

Joined Jan 6, 2004
5,011
The micro is an AT89C4051 with a 20Mhz crystal attached to it for high speed.Documentation tells me at this rate, I could process 1.6 million instructions a second (about 0.6uS single instruction execution time)

If I were to do a delay in software of one second then I need nested loops to make the chip count from 0 to 1.6 million as follows:

Code:
mov R1,#19h ;25 is highest bit
mov R2,#0h
mov R3,#0h
loop2:
    loop1:
        djnz R3,$
    djnz R2,loop1
djnz R1,loop2
As you can see, that code forces the processor to stop doing useful things for the second.

Yes I could use interrupts which is what I want to connect the output of my external 1 second timer to but its the external timer I need to figure out here.
Figure out how to use an internal timer instead for all that and you are done. You will then realize HOW MUCH free time your micro will have to do ther tasks.
 

djsfantasi

Joined Apr 11, 2010
9,237
Code:
While(forever){
    long end;
    end=millis()+1000
    // do something useful
    If (millis()>end) break
    }
// one second elapsed
Change the value of 1000 to the time of your long delay in milliseconds.

This a pseudo-code based on Arduino C.. ANSI C needs a function defined, similar to this.
 

Marley

Joined Apr 4, 2016
519
Basically, use the internal timer/counter to generate a regular interrupt. Nice if it can be every millisecond, for example. Makes calculating the timing easier. But can be any fixed rate. This runs all the time.

Then, in the interrupt routine have a variable which is your virtual "timer" - you can have as many of these as you like as you like. Have a flag (a bit) that controls this timer from the code outside the interrupt. When the flag is clear (timer stopped), set the register to your timing value. When the flag is set (timer running) decrement the register every interrupt. When the register reaches zero - the time delay is complete and you stop decrementing.

Only a few lines of code. How are you writing the code: C or assembler?
 
Top