Connect with us

Binary Counter

Discussion in 'Electronics Homework Help' started by Egor, Nov 24, 2014.

Scroll to continue with content
  1. Egor

    Egor

    27
    0
    Nov 12, 2014
    Hello!
    Stuck with the simulations again. I'm trying to simulate a binary counter using CD4516. I get an error upon trying to run the simulation, can you guys please help me find the issue?
    [​IMG]
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    It seems that you don't have a model (subcircuit) for the CD4516B. As far as I know, LTSPICE doesn't include this model. You need to find one or create it on your own.
     
  3. Egor

    Egor

    27
    0
    Nov 12, 2014
    I downloaded a large model library from here: http://ltwiki.org/?title=Components_Library_and_Circuits
    I tried using 74HC-something counter, but got a similar error. I have no idea how to even start creating my own models. How can I know if a model that is searchable through LTspice will work? Maybe I have a different counter.

    EDIT:
    http://i.imgur.com/Vk0rFEF.png
    I can edit this component through LTspice, doesn't this mean I have the model?
     
  4. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    The data your screeenshot shows doesn't make sense. I do not want to download the full library. Can you extract the model for the 4516 from the library andupload it as text file here? I could then have a look at it.
     
  5. Egor

    Egor

    27
    0
    Nov 12, 2014
    I have two of those
    Version 4
    SymbolType CELL
    LINE Normal -80 32 -80 464
    LINE Normal 80 32 -80 32
    LINE Normal 80 464 80 32
    LINE Normal -80 464 80 464
    LINE Normal -80 320 -112 320
    LINE Normal -80 128 -112 128
    LINE Normal -80 96 -112 96
    LINE Normal -80 160 -112 160
    LINE Normal -61 160 -80 169
    LINE Normal -80 150 -61 160
    LINE Normal 80 416 112 416
    LINE Normal -80 352 -112 352
    LINE Normal -80 384 -112 384
    LINE Normal -80 416 -112 416
    LINE Normal 80 384 112 384
    LINE Normal 80 352 112 352
    LINE Normal 80 320 112 320
    LINE Normal 80 256 112 256
    LINE Normal -80 192 -112 192
    LINE Normal -79 224 -112 224
    WINDOW 3 -48 480 Left 0
    WINDOW 0 -14 17 Left 0
    SYMATTR Value CD4516B
    SYMATTR SpiceLine VDD=5 SPEED=1.0 TRIPDT=5e-9
    SYMATTR Prefix X
    SYMATTR SpiceModel VDD 0
    SYMATTR Description 4 bit binary up/down counter with asynchronous reset and preset
    PIN -112 96 LEFT 38
    PINATTR PinName _CIN
    PINATTR SpiceOrder 1
    PIN -112 128 LEFT 38
    PINATTR PinName U_D
    PINATTR SpiceOrder 2
    PIN -112 192 LEFT 38
    PINATTR PinName PE
    PINATTR SpiceOrder 3
    PIN -112 160 LEFT 50
    PINATTR PinName CLK
    PINATTR SpiceOrder 4
    PIN -112 320 LEFT 38
    PINATTR PinName P1
    PINATTR SpiceOrder 5
    PIN -112 352 LEFT 38
    PINATTR PinName P2
    PINATTR SpiceOrder 6
    PIN -112 384 LEFT 38
    PINATTR PinName P3
    PINATTR SpiceOrder 7
    PIN -112 416 LEFT 38
    PINATTR PinName P4
    PINATTR SpiceOrder 8
    PIN 112 320 RIGHT 36
    PINATTR PinName Q1
    PINATTR SpiceOrder 9
    PIN 112 352 RIGHT 36
    PINATTR PinName Q2
    PINATTR SpiceOrder 10
    PIN 112 384 RIGHT 36
    PINATTR PinName Q3
    PINATTR SpiceOrder 11
    PIN 112 416 RIGHT 36
    PINATTR PinName Q4
    PINATTR SpiceOrder 12
    PIN 112 256 RIGHT 36
    PINATTR PinName _COUT
    PINATTR SpiceOrder 13
    PIN -112 224 LEFT 36
    PINATTR PinName RESET
    PINATTR SpiceOrder 14
    Version 4
    SymbolType CELL
    LINE Normal -80 299 -80 464
    LINE Normal 80 32 -80 32
    LINE Normal 80 464 80 299
    LINE Normal -80 464 80 464
    LINE Normal -80 320 -112 320
    LINE Normal -80 128 -112 128
    LINE Normal -80 96 -112 96
    LINE Normal -80 160 -112 160
    LINE Normal -61 160 -80 169
    LINE Normal -80 150 -61 160
    LINE Normal 80 416 112 416
    LINE Normal -80 352 -112 352
    LINE Normal -80 384 -112 384
    LINE Normal -80 416 -112 416
    LINE Normal 80 384 112 384
    LINE Normal 80 352 112 352
    LINE Normal 80 320 112 320
    LINE Normal 80 256 112 256
    LINE Normal -80 192 -112 192
    LINE Normal -80 224 -112 224
    LINE Normal 80 299 -80 299
    LINE Normal -48 272 -48 299
    LINE Normal -80 272 -48 272
    LINE Normal -80 32 -80 272
    LINE Normal 48 272 48 299
    LINE Normal 80 272 48 272
    LINE Normal 80 32 80 272
    LINE Normal 80 336 -80 336
    LINE Normal 80 368 -80 368
    LINE Normal 80 400 -80 400
    LINE Normal 80 432 -80 432
    WINDOW 3 -48 480 Left 0
    WINDOW 0 -14 17 Left 0
    SYMATTR Value CD4516B
    SYMATTR SpiceLine VDD=5 SPEED=1.0 TRIPDT=5e-9
    SYMATTR Prefix X
    SYMATTR SpiceModel VDD 0
    SYMATTR Description 4 bit binary up/down counter with asynchronous reset and preset
    PIN -112 96 LEFT 38
    PINATTR PinName _CIN
    PINATTR SpiceOrder 1
    PIN -112 128 LEFT 38
    PINATTR PinName U_D
    PINATTR SpiceOrder 2
    PIN -112 192 LEFT 38
    PINATTR PinName PE
    PINATTR SpiceOrder 3
    PIN -112 160 LEFT 50
    PINATTR PinName CLK
    PINATTR SpiceOrder 4
    PIN -112 320 LEFT 38
    PINATTR PinName P1
    PINATTR SpiceOrder 5
    PIN -112 352 LEFT 38
    PINATTR PinName P2
    PINATTR SpiceOrder 6
    PIN -112 384 LEFT 38
    PINATTR PinName P3
    PINATTR SpiceOrder 7
    PIN -112 416 LEFT 38
    PINATTR PinName P4
    PINATTR SpiceOrder 8
    PIN 112 320 RIGHT 36
    PINATTR PinName Q1
    PINATTR SpiceOrder 9
    PIN 112 352 RIGHT 36
    PINATTR PinName Q2
    PINATTR SpiceOrder 10
    PIN 112 384 RIGHT 36
    PINATTR PinName Q3
    PINATTR SpiceOrder 11
    PIN 112 416 RIGHT 36
    PINATTR PinName Q4
    PINATTR SpiceOrder 12
    PIN 112 256 RIGHT 36
    PINATTR PinName _COUT
    PINATTR SpiceOrder 13
    PIN -112 224 LEFT 36
    PINATTR PinName RESET
    PINATTR SpiceOrder 14
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    Sorry, these are only the descriptions for the graphic symbol. These are required for drawing the schematic, but not for the simulation.

    I should have made myself more clear. What you are looking for (and hopefully will find) is something that looks like:
    Code:
    .subckt NE555 1 2 3 4 5 6 7 8
    A1 N001 2 1 1 1 1 N003 1 SCHMITT Vt=0 Vh=1m
    R1 N001 1 5K
    R2 5 N001 5K
    R3 8 5 5K
    S1 1 7 N007 1 D
    A2 N011 N003 1 1 1 1 N008 1 SRFLOP Trise=100n tripdt=10n
    A3 6 5 1 1 1 1 N012 1 SCHMITT Vt=0 Vh=1m
    S2 8 3 N009 1 O
    S3 3 1 1 N009 O
    A6 1 N006 1 N008 1 1 N007 1 OR Ref=.5 Vlow=-1 Trise=100n
    R7 8 1 4K
    R9 2 1 1G
    R10 6 1 1G
    A4 1 N008 1 N006 1 N009 1 1 OR ref=.5 Vlow=-1 Trise=100n
    A5 4 1 1 1 1 N006 1 1 SCHMITT Vt=.7 Vh=1m
    D1 4 1 DR
    A7 1 N006 1 N012 1 1 N011 1 OR
    D2 8 4 400uA
    .model DR D(Ron=150K Roff=1T Vfwd=1.6)
    .model O SW(Ron=6 Roff=1Meg Vt=0 Vh=-.8)
    .model D SW(Ron=6 Roff=.75G Vt=.5 Vh=-.4)
    .model 400uA D(Ron=1K Ilimit=400u epsilon=.5)
    .ends NE555
    This is the functional description (here for an NE555) that can be simulated. Such a description for the CMOS counter is required.
     
  7. Egor

    Egor

    27
    0
    Nov 12, 2014
    Um... I don't really know what I'm looking for, sorry. All I have in the LTspice libraries are symbol files. I can't find anything other than that for *4516 (or *4538 for that matter, that's a monostable vibrator, but this model I can simulate). What is the format of the file I'm supposed to find?

    EDIT I guess the file type is .sub? But I can't find .sub's for half the stuff I have already simulated... I'm kinda lost here. Why are simulation programs so god damn not user-friendly?
     
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    LTSPICE names these fils *.sub, but that is not mandatory. These are simple text files and can have any extension - as long as you tell LTSPICE the full filename+extension.
    If there is a subcircuit for the 4516 in one of the libraries, then you should find it by using the search function of your operating system or simply loading the library files into a text editor and using the editor's search function.
    On my windows 7 I can search all files within a directory on the command line using:
    Code:
    grep 4516 *
    which will scan all files (*) for the string "4516".
     
  9. Egor

    Egor

    27
    0
    Nov 12, 2014
    I tried searching using the regular windows search function, I came up only with symbol files. But the thing is, I simulated 4538 a couple of weeks ago, I tried searching for this and still haven't found any sub files, so how the hell did I simulate it?
     
  10. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    The file is not necessarily named .sub, it may be .lib or something different.
    On windows 7:
    • go to the folder where the library files are located.
    • open a command line window there. You can Shift+right click on the folder name and select "open command window" or similar from the contect menu (sorry, my GUI is German, I can't tell you what the entry is exactly in English).
    • a new window should open showing only a command prompt (on my computer this would be "C:\Program Files (x86)\LTC\LTspiceIV\lib\sub>")
    • type: "grep ends *" without the hyphens, press return. This should give you a list of files that contain subcircuits.
    • repeat, typing "grep 4516 *". This will show ou which file, if any, contains teh subcircuit for the 4516.
    You may have to search several directories where library files are stored.
     
  11. Laplace

    Laplace

    1,252
    184
    Apr 4, 2010
    I tried doing that on my Windows 7 but it did not work:
     
  12. Egor

    Egor

    27
    0
    Nov 12, 2014
    "grep" doesn't work, at least not on 8.1. Says it's not a command or something like that.
     
  13. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    Right, sorry again. grep is a unix utility that is not normally part of Windows. It's on my computer as component of another software installation.
    You can use the evaluation version of wingrep, grepwin or any other port of grep to Windows.
     
  14. Egor

    Egor

    27
    0
    Nov 12, 2014
    While I'm doing all of that, does anybody here have a model for ANY up/down binary counter? I simply need to simulate clock against all of the outputs and I'm done... Instead of actually learning something I'm headbutting with software. Bullshit :(
     
  15. Egor

    Egor

    27
    0
    Nov 12, 2014
    Grep doesn't seem to find ANYTHING :mad:
     
  16. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    SPICE (any flavor of it) is an analog simulator. LTSPICE does incorporate some basic digital functions, but it is not a full-fledged digital simulator. If you're only looking for the relation of outputs to clock, Google "binary counter simulator" and you will be rewarded with online simulators that show you this behavior.
     
  17. Egor

    Egor

    27
    0
    Nov 12, 2014
    I need to simulate 2 circuits for my laboratory assignment that is due in two days. I can't pick any random counter simulation off the net because I need to make a few changes to it with a CD4538 for the second simulation,. I just need a working model so I can actually start doing something today.
     
  18. Harald Kapp

    Harald Kapp Moderator Moderator

    9,488
    1,955
    Nov 17, 2011
    NXP offers SPICE models here (al models (zip)).
    I haven't tried these, but the syntax looks like regular SPICE to me. You will have to unzip the files and store them in a location that is accessible to you and LTSPICE.
    There is a ressource (Adding new components to LTSPICE) that explains how to use such models in LTSPICE. You will have to create your own schematic symbols, read the ressource for a how-to.
     
  19. Egor

    Egor

    27
    0
    Nov 12, 2014
    Eh... well, thank you for your help :) I don't want to spend additional hours trying to add the model, since I can see that I don't understand what this guide wants from me and where to start.
    I guess I'll have to compromise with the prof somehow...

    PS: Found a PSpice model library sitting in LTspice, it has 4516 in it. Doesn't help though... I tried simulating 4516 in PSpice with this library, it says "Undefined" model. Fing great.
    D4516B DUAL UP-COUNTERS
    *
    * THE CMOS INTEGRATED CIRCUITS DATABOOK, 1983, RCA
    * KN 9-9-92 REMODELED USING LOGICEXP, PINDLY, CONSTRAINT DEVICES
    *
    .SUBCKT CD4516B PS_EN_I RESET_I CLOCK_I UP/DOWN_I CINBAR_I P1_I P2_I P3_I P4_I
    + COUTBAR_O Q1_O Q2_O Q3_O Q4_O
    + OPTIONAL: VDD=$G_CD4000_VDD VSS=$G_CD4000_VSS
    + PARAMS: MNTYMXDLY=0 IO_LEVEL=0
    *
    UCD4516BLOG LOGICEXP(13,27) VDD VSS
    + PS_EN_I RESET_I CLOCK_I UP/DOWN_I CINBAR_I P1_I P2_I P3_I P4_I Q1 Q2 Q3 Q4
    + PS_EN RESET CLOCK UP/DOWN CINBAR P1 P2 P3 P4
    + COUTBAR T2 T3 T4 PRESET1 PRESET2 PRESET3 PRESET4 RESET1 RESET2 RESET3 RESET4
    + U1 U2 U3 U4 CLK CIN
    + D0_GATE IO_4000B IO_LEVEL={IO_LEVEL}
    + LOGIC:
    * BUFFER:
    + PS_EN = { PS_EN_I }
    + RESET = { RESET_I }
    + CLOCK = { CLOCK_I }
    + UP/DOWN = { UP/DOWN_I }
    + CINBAR = { CINBAR_I }
    + P1 = { P1_I }
    + P2 = { P2_I }
    + P3 = { P3_I }
    + P4 = { P4_I }
    +
    * INTERMEDIATE TERMS:
    + RESETBAR = { ~RESET } ; UP/DOWN&Q2 AND UP/DOWN|Q2 CAN MINIMIZE
    + U1 = { ~(Q1 ^ UP/DOWN) & ~CINBAR }
    + U2 = { (UP/DOWN & Q2 & Q3 & Q4) | ~(UP/DOWN | Q2 | Q3 | Q4) }
    + U3 = { (UP/DOWN & Q2) | ~(UP/DOWN | Q2) }
    + U4 = { (UP/DOWN & Q2 & Q3) | ~(UP/DOWN | Q2 | Q3) }
    + CIN = { ~CINBAR }
    +
    * OUTPUT ASSIGNMENTS:
    + CLK = { ~(CLOCK | RESET | PS_EN) }
    + PRESET1 = { RESET | ~PS_EN | ~P1 }
    + PRESET2 = { RESET | ~PS_EN | ~P2 }
    + PRESET3 = { RESET | ~PS_EN | ~P3 }
    + PRESET4 = { RESET | ~PS_EN | ~P4 }
    + RESET1 = { RESETBAR & (~PS_EN | P1) }
    + RESET2 = { RESETBAR & (~PS_EN | P2) }
    + RESET3 = { RESETBAR & (~PS_EN | P3) }
    + RESET4 = { RESETBAR & (~PS_EN | P4) }
    + COUTBAR = { ~(U1 & U2) }
    + T2 = { U1 } ; T1 = CINBAR
    + T3 = { (U1 & U3) }
    + T4 = { (U1 & U4) }
    +
    *
    U1 JKFF(1) VDD VSS PRESET1 RESET1 CLK
    + CIN CIN Q1 Q1BAR
    + D0_EFF IO_4000B
    *
    U2 JKFF(1) VDD VSS PRESET2 RESET2 CLK
    + T2 T2 Q2 Q2BAR
    + D0_EFF IO_4000B
    *
    U3 JKFF(1) VDD VSS PRESET3 RESET3 CLK
    + T3 T3 Q3 Q3BAR
    + D0_EFF IO_4000B
    *
    U4 JKFF(1) VDD VSS PRESET4 RESET4 CLK
    + T4 T4 Q4 Q4BAR
    + D0_EFF IO_4000B
    *
    UCD4516BDLY PINDLY (5,0,9) VDD VSS
    + Q1 Q2 Q3 Q4 COUTBAR
    + CLOCK CINBAR RESET PS_EN P1 P2 P3 P4 UP/DOWN
    + Q1_O Q2_O Q3_O Q4_O COUTBAR_O
    + IO_4000B MNTYMXDLY={MNTYMXDLY} IO_LEVEL={IO_LEVEL}
    +
    + PINDLY:
    + Q1_O Q2_O Q3_O Q4_O = {
    + CASE(
    + CHANGED(RESET,0) | CHANGED(PS_EN,0), DELAY(-1,210NS,420NS),
    + CHANGED_LH(CLOCK,0), DELAY(-1,200NS,400NS),
    + DELAY(-1,211NS,421NS) ;DEFAULT
    + )
    + }
    +
    + COUTBAR_O = {
    + CASE(
    + CHANGED(RESET,0) | CHANGED(PS_EN,0), DELAY(-1,320NS,640NS),
    + CHANGED_LH(CLOCK,0), DELAY(-1,240NS,480NS),
    + CHANGED(CINBAR,0), DELAY(-1,125NS,250NS),
    + DELAY(-1,321NS,641NS) ;DEFAULT
    + )
    + }
    +
    +
    + FREQ:
    + NODE = CLOCK
    + MAXFREQ = 2MEG
    +
    + WIDTH:
    + NODE = CLOCK
    + MIN_HI = 150NS
    + MIN_LO = 150NS
    +
    + WIDTH:
    + NODE = RESET
    + MIN_HI = 220NS
    + MIN_LO = 220NS
    +
    + WIDTH:
    + NODE = PS_EN
    + MIN_HI = 220NS
    + MIN_LO = 220NS
    +
    + SETUP_HOLD:
    + DATA(1) = CINBAR
    + CLOCK LH = CLOCK
    + SETUPTIME = 130NS
    + HOLDTIME = 60NS
    + WHEN = { PS_EN!='1 & RESET!='1 }
    +
    + SETUP_HOLD:
    + DATA(1) = UP/DOWN
    + CLOCK LH = CLOCK
    + SETUPTIME = 360NS
    + HOLDTIME = 30NS
    + WHEN = { PS_EN!='1 & RESET!='1 & CINBAR!='1 }
    +
    + SETUP_HOLD:
    + DATA(1) = PS_EN
    + CLOCK LH = CLOCK
    + RELEASETIME_HL = 150NS
    +
    + SETUP_HOLD:
    + DATA(1) = RESET
    + CLOCK LH = CLOCK
    + RELEASETIME_HL = 150NS
    +
    + SETUP_HOLD:
    + DATA(4) = P1 P2 P3 P4 ; CHECK SETUPTIME PS_EN TO Pn
    + CLOCK HL = PS_EN
    + SETUPTIME = 70NS
    + WHEN = { RESET!='1 & CINBAR!='1 }
    + MESSAGE = "SETUPTIME PRESET_ENABLE TO Pn TOO SHORT"
    +
    + SETUP_HOLD:
    + DATA(4) = P1 P2 P3 P4 ; CHECK HOLDTIME PS_EN TO Pn
    + CLOCK LH = PS_EN
    + HOLDTIME = 25NS
    + WHEN = { RESET!='1 & CINBAR!='1 }
    + MESSAGE = "HOLDTIME PRESET_ENABLE TO Pn TOO SHORT"
    *
    .ENDS
    *
    *$
     
    Last edited: Nov 24, 2014
  20. Arouse1973

    Arouse1973 Adam

    5,164
    1,078
    Dec 18, 2013
    I think you need to include the CMOS library on your simulation. Your path name and library name might be different to mine but the procedure is the same. The first picture is with the same error as you, the second is with the directive statement above the IC and now it works.
    Adam

    counter1.PNG

    counter2.PNG
     
    Harald Kapp, Egor and hevans1944 like this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-