You need to use EasyEDA editor to create some projects before publishing
Help about LM393
3360 9
mmelecchi68 7 years ago
Hello everybody ! I'm trying to make a schematic with LM393 but it doesn't work at all ! LM393 is a differential voltage comparator and looks like an OPAMP. It's output is connected to V- if "-in" is greather than "+in" and it's left in high impedance if "+in" is greather than "-in". I realized a very simple schematic using the LM393N but the output is never V-, it's always in high impedance and R5 pulls it to +5V ! Is there anybody can show me what I did wrong ? I shared the project named Provina LN393N. Thank you everybody. Marco
Comments
andyfierman 7 years ago
Hi Mmelecchi68, Welcome to EasyEDA. To save people having to rummage through your public projets, it is good etiquette to post the link to your project like this: https://easyeda.com/mmelecchi68/Provina_LM393N-hLFWQKqkC You can get the url like this: ![enter image description here][1] Now, to solve your problem. In EasyEDA there are many, many more schematic symbols that do not have simulation models associated with them than those that do so it is tricky to find the ones that you can actually use in simulation. However, help is at hand. First you are strongly advised to read the **EasyEDA Simulation eBook** at: https://docs.google.com/document/u/1/d/1OWZVVFRAe_2NW3WratpkA_SGuHa5AcRow5ZRfvcoVTU/pub (Please use this in preference to the one on the EasyEDA pages as the table of contents is broken in that one.) Here are some examples that do what you want with an in-house push-pull and an open collector copmparator model (like the LM393) and a couple of LM319 models: https://easyeda.com/example/How_to_sImulate_comparators_in_EasyEDA-ge82kCUb5 You can copy, paste into your schematic and edit the `compOC5pEE` model to make it more like the LM393. The editable parameters are shown in the netlist of the model and can mostly be derived from the device datasheets. Rename the name subckt and the name in the symbol to something like `MYcompOC5pEE` (they must be exactly the same). Then select the model text and set its `text type = spice` in the right hand navigation panel. Alternatively, you can just edit the name of the symbol used in the `compOC5pEE` examples to one of: LM393_TI LM393_ST TS393_ST LM2903_TI Or there are dedicated spice symbols for the: LM393_TI LM393_ST TS393_ST LM2903_TI and there is also a spice symbol for the ST TSX393 (using the ST subckt) which models both comparators in a package. Note that all the symbols in the `EasyEDA Libs` in the left hand `Navigation` panel have models associated with them and can have different models assigned to them as described in the Simulation eBook. You will find a list of all the spice models and subcircuits currently available for EasyEDA here: https://docs.google.com/spreadsheets/d/1KM28xzXwgQeUUj3zRMlth9BN-vs6Q98KBk1FHXmf58U/pubhtml You can enter these model names into any approriate symbol from the EasyEDA Libs and then set the spice prefix to the prefix approriate for the model (Ngspice model types: https://docs.google.com/document/u/1/d/1OWZVVFRAe_2NW3WratpkA_SGuHa5AcRow5ZRfvcoVTU/pub#h.3hv69ve) You will find all other available spice symbols here: https://easyeda.com/component/user/spicesymbol or separated into those for models and those for subcircuits here: https://easyeda.com/component/user/model https://easyeda.com/component/user/subckt [1]: /editor/20161003/57f26e81e01ab.png
Reply
mmelecchi68 7 years ago
Hi Andy ! WOW !! Thanks a lot ! First of all excuse me for all the wrong things I've done: I'll try to be better now that I know them. Then ... I'll try to do what you, very kindly, told me. Again, thanks very very much Marco
Reply
andyfierman 7 years ago
Hi Marco, No problem. EasyEDA started a few years ago as primarily a Schematic Capture and PCB design tool. Simulation was added later and the documentation for it is still a bit scattered. There are lots of examples to play with but actually finding all the available models and spice symbols is still not well integrated into the tool suite. Spice simulation is not easy to get the hang of straight away. I have been using it for about 20 years in the forms of Simetrix, LTspice and ngspice but I have never quite got the hang of using Pspice even though that's the one I started with (and it was so poor back then that I soon switched to Simetrix and then LTspice and now ngspice). So don't worry about dropping a few clangers. Just post back if you need more help. BTW you can take any simulation schematic in EasyEDA and with a bit of editing, turn it into a non-simulation schematic ready to pass into PCB. You don't need to redraw it from scratch. Search for the `Tesseract` and `Uberclamp` projects for examples of this. :)
Reply
mmelecchi68 7 years ago
@andyfierman Hello Andy !! Since our last talk I did giant steps !! And I'm so happy !! But ... I'm a SW developer and I love electronics so, as I read yours and as I realized how many components are just "empty boxes" I thought "why don't give my own contribute ??" ... I look around in google for something like "lm358 spice model" and, listen, I found it ! Not just once but some occurrences. I tried to download (ex from TI) and import into EasyEDA but those were not the right file, no one of those files. Since those are text files I'd love to spend some time trying to modify them in order to upload into EasyEDA (properly working, of course) ... can I do this ? And ... HOW ??? Is there any documentation about the format of a simulation file ? I hope this is not just a dream :) Thks, Marco
Reply
andyfierman 7 years ago
Hi Marco, Glad that you are having fun with EasyEDA. ### LMx58 opamps in EasyEDA In fact there are symbols with models in EasyEDA for the LMx58 opamps: just SHIFT+F search for LM158-N, LM258-N and LM358-N. The latest upgrade of EasyEDA has made it a bit easier to find parts with models and so on: https://easyeda.com/forum/topic/How_to_find_simulatable_parts_in_EasyEDA-1YgasK2kC ### Importing 3rd party models into EasyEDA As you have already found, that's the easy part. Getting them to work is the hard part. It's not impossible by any means but it needs a knowledge and understanding of the differences between the different dialect of spice syntax. There are several major dialects: SP2: earlier version of generic Berkeley spice. SP3: modern version of Berkeley spice with lots of new features. ngspice: FOSS. Based closely on SP3 but with some tweaks. Used as the core simulation engine of EasyEDA. Documented but much of it is just lifted straight from SP3 documentation so can be a bit impenetrable. Pspice: Cadence (originally Multisim) proprietary derived from Berkeley spice. Mostly well documented but a few vague bits. Sadly, it's the de facto industry standard and many models are encypted and can only be run in Pspice. Hspice: From Synopsis. Effectively the IC industry standard. Well documented. Many models are encypted and can only be run in Pspice. Fortunately most discrete parts also have models in Psice but may still be encrypted. LTspice: LTspice run most unencypted models with no need for modifications. Can also run it's own encypted models and users can encypt their own models. Some models cannot be run on anything but LTspice because they rely on proprietary internal models. Most special LTspice functions can be reproduced in SP3 (and have been in EasyEDA). More later. :)
Reply
andyfierman 7 years ago
More. Models written for SP2 and SP3 will (usually!) run out-of-the-box but anything else will usually require editing. The biggest problem is being able to see which parts of a model need to be edited to make them run in ngspice. This project illustrates some of the things that have to be recognised (and the fact that there may be more than one way to fix them!) to get even a simple model to run: https://easyeda.com/example/Current_source_devices-EFztNHZhy In LTspice, it is possible to measure the current in a resistor directly whereas in ngspice, a 0V source has to be inserted to act as an ammeter (which is besically all that the EasyEDA Ammeter is) and the current through that is then used elsewhere in a B source expression. Also in LTspice, several devices can have internal components such as ESR in capacitors and inductors, series resistance in voltage sources and parallel resistances in current sources, caps and inductors. None of these are available in ngspice so they have to be edited out of the components and replaced with explicit instances of the relevant components. The stepper motor model in this project shows some of the tricks that have to be put in place to make an LTspice model compatible with ngspice: https://easyeda.com/andyfierman/Motor_models-yVJx7HgQ2to In LTspice the syntax for a voltage controlled resistor is subtly different from that used by ngspice. The relay model in this project shows the ngspice syntax: https://easyeda.com/example/MOSFET_series_disconnect_overvoltage_protector-3AMYWwuFf In LTspice, there's no need for the apostrophes. LTspice has a so-called charge defined capacitor (and flux defined inductor) model for which there is no direct equivalent in ngspice and which in fact do not work correctly in certain circumstances. There is a way to do these in ngspice but seems quite messy so, although not included in the library yet, EasyEDA has a more reliable in-house subckt to implement both of these functions. I think Voltage and Current Controlled Switches in Pspice are still discontinuopus switching (bang/bang, fully on/fully off) whereas in LTspice they can be configure to have a contiuous resistsnce curve vs. control input (with two options). SIMetrix also implements a continuous switch but in a different way. The basic SW switch in ngspice is discontinuous but there is also an XSPICE version in ngspice that can be configured in a variety of continous ways (used in our logic device models). ngspice has only a limited number of native functions and several of those are broken. I have rewritten many of them for EasyEDA so that they are compatible with LTspice native functions. A few are not possible to replace. Some we put into every netlist as .func statements. The rest have to be pasted in to the schematic or subckt netlist directly. The most common one seems to be the IF() function. It pops up in lots of subckts. When used intelligently it's fine but in many models it leads to serious convergence failures. To get around this SIMetrix even has a 'soft' or 'fuzzy' IF statement! I sometimes use TANH() functions to do something similar but they don't always converge well either... More about these here: https://docs.google.com/document/u/1/d/1OWZVVFRAe_2NW3WratpkA_SGuHa5AcRow5ZRfvcoVTU/pub#h.3q5sasy Another, less obvious problem is that most opamp models are for a single device. What happens if you want to make it easy for users who want a model of a dual device? Here's one way to do it: https://easyeda.com/editor#id=914ddaada7814f8fa49c93e1d5a4d1d6 Here's another (thought up by one of our users): https://easyeda.com/editor#id=3528f438ca4e48a19e2979eb83079f96 Many device models only model device behaviour whilst used in the 'normal' way. Most do not reflect the sorts of behaviours that real devices have when users do things like connect the power supplies the wrong way round or exceed the ABS MAX supply voltage or pull an input or an output below ground or above a supply rail.... Many opamp models still do not even model the current supplied to the load through the output stages (the Boyle Model)! The 'EE' suffix models do attempt to model such 'out-of-bounds' behaviours as demonstrated here: https://easyeda.com/example/Demonstrating_the_EasyEDA_TL081EE_subcircuit_model-ZQcuM4Ygy Careful study of the netlist of the TL081EE will show the techniques to do this. A similar study of any of the EasyEDA logic devices will show the same sort of info and techniques (which make the EasyEDA logic models quite unusual in the spice modelling world). (Beware: I sometimes vary the techniques I use to implement these behaviours partly to show different ways of doing the same thing.) :) Even the humble BJT model does not model reverse VBE breakdown or Avalanche breakdown (Zetex, now Diodes Inc., have a couple of models of Avalanche transistors that do but they are quite complex subckts and not simple bjt .models). Other tricks like using B sources set up as current sources with a resistor and small cap in parallel to create a band-limited Norton Source instead of an infinite bandwidth Thevenin Source because spice likes Norton sources.... Even after all that you can still be stopped in your tracks. I have two SMPS models that I have developed for ngspice and wich have editable bits so they can run in LTspice but which run fine in LTspice and not at all in ngspice. :( Some devices do not have models at all. There's an overal caveat about copyright in many models. Quite a few 'publically available' models are so tightly controlled by their copyright or a EULA that has to be agreed to before downloading that they are effectively useless to us in EasyEDA. So then you're into the slightly grey area of users having to paste-in netlists on their own. Or we get into custom modelling. All those hardy souls who have developed spice (SPICE?! The clue is in the name!! `IC`!!!!!) models for valves/tubes. https://easyeda.com/andyfierman/Valve_Tube_examples-05ZhzR9rJ Relays. Unijunction transistors. LM56 LM2907 family LDRs Electret microphones https://easyeda.com/andyfierman/Projects_for_beginners-tqkewO60i and so on. Then there's how to test models? Users have a limited number of sim/day in EasyEDA which can easily be used up trying to get a model to run. Error reporting in EasyEDA is not brilliant. If the spice netlist is exported (and lightly edited to strip out the .control ... .endc section) from EasyEDA and pasted into ngspice.com then the error reporting is a bit better. Error reporting in LTspice is very good but then LTspice will run stuff without flagging up things that would cause errors in ngspice, so you can't win there either. :( So, the first step in learning how to get 3rd party models to run in EasyEDA depends how much time you can devote to just reading all about the basic device models in each flavour of spice. Then comes learning all the odd little quirks of ngspice *as used in EasyEDA*. For example you can use the tilde '~' character in a library netlist to indicate a logical inversion in an XSPICE A device but you can't use it in a pasted-in copy of the same netlist because the EasyEDA parsing strips it out because it is used elesewhere in the EasyEDA Source file JSON syntax... In EasyEDA, .subckt names cannot have `/` or `-` or spaces in them. Many National Semiconductor (now TI) models have `/` characters in them. The list is almost endless and I still get caught out by odd little syntax differences on even the simplest models. I should write a book about this. Oh. I think I just wrote the Intro. :)
Reply
mmelecchi68 7 years ago
... gulp !!! I have to digest all of that, and it's not easy !! Forgive me if I burp ... ;) And there is also another difficulty: I'm italian so my english is not (unfortunately) like your one :(
Reply
andyfierman 7 years ago
`... gulp !!!` Ah but if it was easy, everyone would be doing it. Just to encourage you; I'm a newbie to simulation too: I have only been doing it for 19 years... :) 'And there is also another difficulty: I'm italian so my english is not (unfortunately) like your one.' But your english is way better than my Italian so we should be OK. :) I may be wrong but you *may* be able to make an Italian language copy of the ngspice manual from here: https://sourceforge.net/p/ngspice/ngspice-manuals/ci/master/tree/ Some other sources of info: http://www.elettrotecnica.unina.it/files/demagistris/didattica/common/SpiceIntr.pdf (see Bibiography at the end)
Reply
mmelecchi68 7 years ago
All I can say is "Let's try" !! "But your english is way better than my Italian so we should be OK." ... thank you very much: I studied english at school (many years ago ... sigh ... about 30 years ago) and often I use it at work (computers & languages manuals, forum, ...). "I may be wrong but you may be able to make an Italian language copy of the ngspice manual": I thought about that, and maybe I couls try in the future, but now I think it's better to work on simulation ... if I'll be able !! Thanks again
Reply
Login or Register to add a comment
goToTop
你现在访问的是EasyEDA海外版,建议访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus- -mockplus-@1x -mockplus-

Cookie Notice

Our website uses essential cookies to help us ensure that it is working as expected, and uses optional analytics cookies to offer you a better browsing experience. To find out more, read our Cookie Notice