LTSpice Counter Help

Thread Starter

odm4286

Joined Sep 20, 2009
265
Hello,

I've looked up how to use the counter in LTSpice but I am wondering if there is any way to change its starting behavior. You can see in the picture below that the timer output correctly asserts high when the 5th rising edge is detected but it also starts high. This completely defeats the purpose for my application as it will result in a false trigger. Any way to change/get around this?

Does anyone have an 8bit binary counter model? Worst case, I could build one out of flipflops but would like to avoid that if there is an easier way.

Blue trace: CLK input
Red trace: Counter output

1640206890766.png
 

Papabravo

Joined Feb 24, 2006
18,444
With respect to the built-in counter I can't help you, because I have only looked at it, but never used it, so I don't know the answer to your question.
In the logic libraries, available from different sources, there are several different 4-bit counter models that can be cascaded into an 8-bit counter. Will that work for you?
 

Thread Starter

odm4286

Joined Sep 20, 2009
265
With respect to the built-in counter I can't help you, because I have only looked at it, but never used it, so I don't know the answer to your question.
In the logic libraries, available from different sources, there are several different 4-bit counter models that can be cascaded into an 8-bit counter. Will that work for you?
Absolutely! Can you point me in the right direction? The cascading will be new to me, is there a roll over pin or something like that?
 

Papabravo

Joined Feb 24, 2006
18,444
Absolutely! Can you point me in the right direction? The cascading will be new to me, is there a roll over pin or something like that?
Yes there is.
The 4-bit binary counter that I favor is the 74XX161 where XX denotes the logic family. Here is a sample LTspice schematic that uses one.
In the schematic below U3 is the least significant 4 bits and U4 is the most significant. [U4:U3] forms an 8-bit up counter. The outputs are 1's complemented and added to 0 plus a carry in of 1. This subtracts each unsigned positive integer from 0, making a down counter feeding an R-2R ladder network to make a DAC (Digital to Analog Converter), which is then buffered by U13 configured as a unity gain follower.

On U3 the "TC" output, which stands for "Terminal Count" is a logic 1 when U3{Q3:Q0] = 1111 binary = 15 decimal = F hexidecimal
This is fed to the "CET" input on U4 which allows U4 to increment every 16th clock cycle.
 

Attachments

eetech00

Joined Jun 8, 2013
3,162
Hello,

I've looked up how to use the counter in LTSpice but I am wondering if there is any way to change its starting behavior. You can see in the picture below that the timer output correctly asserts high when the 5th rising edge is detected but it also starts high. This completely defeats the purpose for my application as it will result in a false trigger. Any way to change/get around this?

Does anyone have an 8bit binary counter model? Worst case, I could build one out of flipflops but would like to avoid that if there is an easier way.

Blue trace: CLK input
Red trace: Counter output

View attachment 255816
Hi

While those devices can be configured to "divide by", they are intended to be used as design aids for developing complete logic models like counters. It would be much quicker and easier to use a counter component from one of the existing digital part libraries, such as the CD4000 or 74HC libraries.
 

Thread Starter

odm4286

Joined Sep 20, 2009
265
Hi

While those devices can be configured to "divide by", they are intended to be used as design aids for developing complete logic models like counters. It would be much quicker and easier to use a counter component from one of the existing digital part libraries, such as the CD4000 or 74HC libraries.
Thanks, where can I find these libraries and how do I install them?
 

ronsimpson

Joined Oct 7, 2019
2,087
You can see in the picture below that the timer output correctly asserts high when the 5th rising edge is detected but it also starts high.
I don't see how to fix the counter. But
I inverted the input clock by switching the on voltage and off voltage. Got a different output.
I also looked at the other output and got a different output.
I can make it different, but I cannot see how to reset the counter on power up.
 

Papabravo

Joined Feb 24, 2006
18,444
Thanks, where can I find these libraries and how do I install them?
You can go to the @Bordodynov website : http://bordodynov.ltwiki.org/ click on the first download link, the 18Meg file "Additional library for LTspice..,"
You can also go to the groups.io website: https://groups.io

You download them, unzip them and either create a private library which you add to your library search path in the LTspice control Panel, or you merge those libraries with the standard distribution.
 
Top