Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Model of LM331 for LTSpice

Status
Not open for further replies.

alec_t

Well-Known Member
Most Helpful Member
Stimulated/provoked by other threads related to this topic I have come up with the attached model for the LM331/231 in a test rig.
It's just an asc schematic, so cut and paste the bits within the dotted rectangle as required.
No doubt someone out there will be able to convert it to to a general-purpose sub-circuit which LTS recognises. I tried but failed, and would be interested to know how it's done.

Edit: I've fallen into a previous trap! The 311 in the title should be 331.
 

Attachments

  • LM331TestRig.asc
    5 KB · Views: 2,020
Last edited:
alec,
Runs OK, I will keep it on file.

You could make a hierarchical circuit of the asc circuit.

Interesting to see if the OP from the V2F thread is able to make use of it.
 
Thanks for correcting the title, Eric. All those other posts about 311 left me befuddled!

You could make a hierarchical circuit of the asc circuit.
That's where I tried but failed. I retained just the bits in the rectangle and saved as an asc file, copied that to various LTS folders, then created a symbol. Tried adding the symbol, plus various .lib, .inc directives, to a new schematic. No joy. Error message about unknown subcircuit when the sim tries to run. Didn't know where to go from there. LTS Help says use it as a subcircuit. But how?
 
alec,
I have created a few hierarchical circuits OK, I will look thru yours, give a try.


EDIT:
This is a hierarchical circuit for a 4060, it may help you to follow the sequence

Note: you dont use an include

In your circuits keep the names the same and in the same folder, for starters.
I use the m1 as part of the name, to identify my circuits
 

Attachments

  • 4060m1.zip
    1.9 KB · Views: 636
Last edited:
alec,
LM331m1 zipped.

Place the LM331m1.asy file in the Misc folder so that you can use the symbol.

Unzip and for a test keep in same folder, its not very tidy, but it works. Use the LM331_testm1.asc to run

You could smarten it up if required.:rolleyes:
 

Attachments

  • LM331m1.zip
    2.2 KB · Views: 1,641
  • AAesp01.gif
    AAesp01.gif
    42 KB · Views: 1,330
Last edited:
Thanks Eric. I'll give it a bash.
 
I did as instructed.
It looks as though the main test asc file, the subcircuit asc file and the asy file all have to be in the same folder to get things to work. It wouldn't work when trying to run a draft schematic (in the LTSpiceIV folder), with the asy file and the subcircuit asc file both in Misc and both in .sym.
That's a shame. I was hoping to be able to use the subcircuit in the same way as LT uses its .sub files, with the subcircuit in the LT /lib/sub (or subordinate) folder and the asy file in the /lib/sym (or subordinate) folder.
It would be nice if LT could provide an enhanced folder structure with, say, an 'AddOns' handler, and an enhanced folder-search engine which looked in all folders from the LT root down, to make it easier to bolt on third-party models etc. (I know, I shouldn't look a gift horse in the mouth).
Do you know if synchronising (updating) the LT program wipes out any user additions to the LT-provided folders?
BTW, I assume the LT .sub files are encoded differently from user subcircuit files in some way to make them proprietary?
 
I did as instructed.
It looks as though the main test asc file, the subcircuit asc file and the asy file all have to be in the same folder to get things to work.
Mine runs OK, with the*.asy file in lib\Sub\Misc folder. C:\Program Files\LTC\LTspiceIV\lib\sym\Misc

I can use F2 , look in the Misc folder and select LM331m1.asy
You should keep the 'hier model' in the same folder as the LM331_test1.asc file.

It wouldn't work when trying to run a draft schematic (in the LTSpiceIV folder), with the asy file and the subcircuit asc file both in Misc and both in .sym.
Do not place the 'hier model in the sym folder.

That's a shame. I was hoping to be able to use the subcircuit in the same way as LT uses its .sub files, with the subcircuit in the LT /lib/sub (or subordinate) folder and the asy file in the /lib/sym (or subordinate) folder.

It would be nice if LT could provide an enhanced folder structure with, say, an 'AddOns' handler, and an enhanced folder-search engine which looked in all folders from the LT root down, to make it easier to bolt on third-party models etc. (I know, I shouldn't look a gift horse in the mouth).

I use also a second 'misc2' for trial work on models

Do you know if synchronising (updating) the LT program wipes out any user additions to the LT-provided folders?
BTW, I assume the LT .sub files are encoded differently from user subcircuit files in some way to make them proprietary?

I have upgraded about every 45 days from LTS, never over written of my work.

I do keep a full working back up on the D:\drive for LTS, just in case of some failure.


I will look at some options for making in more 'friendly'

I have made a neater version of the model, will post later.
 
Last edited:
alec,
This a neater symbol, also added pin numbers

Change the file extension from txt to asy
 

Attachments

  • AAesp06.gif
    AAesp06.gif
    9.9 KB · Views: 948
  • LM331m1.txt
    806 bytes · Views: 1,434
alec,
LM331m1 zipped.

Place the LM331m1.asy file in the Misc folder so that you can use the symbol.

Unzip and for a test keep in same folder, its not very tidy, but it works. Use the LM331_testm1.asc to run

You could smarten it up if required.:rolleyes:


Hello Everyone. Thanks for the LTSpice model. I have one doubt though, Why the output voltage is limited to 30-32mV range? In the datasheet it is mentioned current output is some 120uA. But here it is not the case. Thanks
 
Hello,

In LM331_testm1.asc is a liitle bug. Pin of R6 connected to Vs should be connected to Vsupply. You will achieve impulses 0-10V.
 

Attachments

  • LM331m1_test2.asc
    1.6 KB · Views: 329
Hello,

In LM331_testm1.asc is a liitle bug. Pin of R6 connected to Vs should be connected to Vsupply. You will achieve impulses 0-10V.
Hi,
I figured this 3rd party model was worth experimenting on a V-F configuration of mine, after patching this bug.
The attached schematic functions in the *real* world, but fails to simulate!
This is my initial attempt using SPICE and would appreciate any help getting simulation to function, as well.
fritual
 

Attachments

  • LM331m1_test3.asc
    3 KB · Views: 300
Hi,
I figured this 3rd party model was worth experimenting on a V-F configuration of mine, after patching this bug.
The attached schematic functions in the *real* world, but fails to simulate!
This is my initial attempt using SPICE and would appreciate any help getting simulation to function, as well.
fritual

You didn't provide the model and symbol. I have one I can provide.
Can you post a snapshot of the schematic?
 
You didn't provide the model and symbol. I have one I can provide.
Can you post a snapshot of the schematic?
eTech,
The symbol I used can be found in post #9 of this thread.
As for the hierarchical circuit, goto post #5 and put it in the same folder as my schematic in post #12.
The attached spec sheet circuit should match LM331 TestRig.asc in post #1.
HTH
fritual
 

Attachments

  • lm331.pdf
    976.3 KB · Views: 346
Last edited:
eTech,
The symbol I used can be found in post #9 of this thread.
As for the hierarchical circuit, goto post #5 and put it in the same folder as my schematic in post #12.
The attached spec sheet circuit should match LM331 TestRig.asc in post #1.
HTH
fritual

What is the measured V-to-F conversion values of your tested circuit?
2v FS in = ? Hz FS out
 
The attached spec sheet circuit should match LM331 TestRig.asc in post #1.
fritual

I seriously doubt the TestRig.asc will match the entire spec.
Can you provide specifics on which params in the specs your interested in?
 
You didn't provide the model and symbol. I have one I can provide.
Can you post a snapshot of the schematic?
Hi,
Attached schematic shows conversion factor formula.
e.g., 1 v in == 20,574 hz out, max.
fritual
 

Attachments

  • data-acq.png
    data-acq.png
    110 KB · Views: 398
I seriously doubt the TestRig.asc will match the entire spec.
Can you provide specifics on which params in the specs your interested in?
Current source, pin #1 that's fed back to pin #6.
The other concern is that the LTspice resistor's 'can' be polarized.
fritual
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top