Simple simulation not working - Page 1
Forum section: electronics / projects

author: ricko_uk
author_rank: Super Contributor
timestamp: November 21, 2021, 11:26:04 am
content: Hi,I just tried simulating a very simple current sink circuit in Altium and it does not seem to work regardless of which spice model I use for both the mosfet and the op-amp.I tried attaching different spice models to the op-amp, to the mosfet and to both. Nothing...- In some cases it says there is no convergence- in some cases it shows voltage at C at 150V when the maximum voltage available is 3V3- in some cases voltage at D is 0 (even zooming in as much as possible it shows no sign of the signal)Attached is also the zip with the whole project and inside the folder there are various spice models for both mosfet and op-amp.Is altium simulator just rubbish? It seems too simple of a circuit for it to be an issue with Altium. So what have I been doing wrong?NOTE: I updated the schematic which originally was showing incorrect bias with 2 x 100K resistors (I just uploaded the wrong screenshot while trying to change all sorts of things to check Spice behaviour at various points in the circuit).Thank you

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: November 21, 2021, 01:29:09 pm
content: Hi ricko_uk,I don't know anything about the Altium simulator, but I do know a lot about LTspice and circuit designI don't think the issue is Altium specific, I think this is a design issue.If I analyze your circuit, without running it in a simulator I can see a few issues:1) There is no part number assigned to Q2, I am not sure what the default MOSFET is.2) With VDD = 3.3V there may not be enough voltage to turn on the MOSFET. Check the gate threshold voltage of the MOSFET.3) Examine the DC operating point. The op-amp will try and make the voltage on both the inputs the same.The positive input is at VDD/2The op-amp will try and make the non-inverting input VDD/2 to match.This condition cannot be met because the maximum voltage at D is Vdd x (R6/R6 + R7) = Vdd x 11 / 42The output of the op-amp will go to Vdd.The op-amp may oscillate in this circuit.In others words there is a lot wrong with the circuit before you blame the simulator ...Try this circuit:You will probably have to put in a similar MOSFET. I chose a low voltage 20V device to get a low Vgs(th) value.Substitute the LTC6241 with the MCP6201 op-amp.I have marked the DC voltages.See if you get the same answer.Jay_Diddy_B

author: Nominal Animal
author_rank: Super Contributor
timestamp: November 21, 2021, 01:38:07 pm
content: Quote from: Jay_Diddy_B on November 21, 2021, 01:29:09 pmI stand corrected, and removed my misleading post; apologies. Me no EE!

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 21, 2021, 05:38:23 pm
content: I think Jay_Diddy_B already gave you the key points.One obvious thing here is that your input voltage is centered around Vdd/2 (1.65 V) and your shunt resistor is 11 ohm. Thus, if the circuit indeed operated as a constant current sink, it would sink Vdd/2/11 = 150 mA. Your load is 31 ohm. That would be a 4.65 V drop across the load, which is obviously impossible since your supply voltage is 3.3 V. And the main other point was also the Vgs(th) of the MOSFET which you must be aware of.As to the simulator itself, I don't know Altium's simulator but I'm pretty sure it's Spice-based. It's not uncommon at all to get aberrant results, in particular when your models are simplified and not used within their expected operating range (that would be to explain the 150 V you get.) One very simple way of getting a physically stupid simulation result in Spice is to put an ideal current source in series with an ideal voltage source and a resistor. Try a 3.3 V voltage source, in series with a 1 k resistor and a 100 mA current source. You'll get a 100 V voltage across the resistor.Of course *you* did not create such a circuit yourself, but this may be "hidden" within one of the models you used.

author: ricko_uk
author_rank: Super Contributor
timestamp: November 23, 2021, 04:37:24 pm
content: Thank you all and thank you Jay_Diddy_B also for the simulation.Regarding the input bias, I was trying all sorts of changes to see if I could figure out what was going on with spice models and I posted the wrong screenshot. I was already biasing it to a correct voltage level like you are suggesting.With respect to the mosfet, I have been trying various low Vgth mosfets like BSS806NH6327XTSA1, DMG2302UKQ and FDV303N. But none of them seemed to work.I replicated Jay_Diddy_B with the above mosfets and various op-amp models but nothing...That is why I think there is some issue with Altium spice or the models I have chosen or the way I attached the models to the schematic symbol.After keep reading quite a bit about Spice, I am wondering whether I need to perhaps define an initial condition somewhere or create a specific setup. But Altium gives all green ticks on the setup pages...If anybody is familiar with Altium simulator please feel free to suggested anything I might have been doing wrong (files attached).I think in the meanwhile I will have to learn LTspice as it seems everybody prefer that.Thank you all as always!!

author: SiliconWizard
author_rank: Super Contributor
timestamp: November 23, 2021, 05:52:25 pm
content: Quote from: ricko_uk on November 23, 2021, 04:37:24 pmAh good point. You might want to try setting initial conditions for this kind of circuit, since it's a closed loop and the simulator might not be able to properly infer the initial state.One IC you could try is to set the output of the opamp as 0 V as an initial condition (just add a label to the node to do this easily.)

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: November 23, 2021, 07:43:18 pm
content: Hi,You should also be aware of numbering conventions.For example the convention for a MOSFET is:1 Drain2 Gate3 Sourcethis is critical when you use third party models.It looks like the Altium symbol does not follow this convention.There are similar conventions for the op-amp for example the mCP6001.ckt model starts:.SUBCKT MCP6001 1 2 3 4 5* | | | | |* | | | | Output* | | | Negative Supply* | | Positive Supply* | Inverting Input* Non-inverting Input******************************************************************The pins for simulation are different than the physical part.Jay_Diddy_B

author: ricko_uk
author_rank: Super Contributor
timestamp: November 23, 2021, 09:09:00 pm
content: Thank you SiliconWizard and Jay_Diddy_BI tried the initial condition and also double checked the pins (Altium has a mapping functionality which I initially used and now double checked and was already correctly assigned). There must be either some issue with all the models I tried and/or some issues with Altium setup and/or engine.I tried LTspice and it worked straight away. See screenshot.So I will use that instead. Quite annoying because it needs re-inputting the schematic every new project and LTSpice user interface is not exactly user friendly.Thank you

author: ricko_uk
author_rank: Super Contributor
timestamp: November 23, 2021, 09:23:51 pm
content: BTW, in a simulation like this one which has a mosfet, which parameters value does the model use?For example for Vgth, would it use the min, typ or max?Do the models have all three values (min typ and max) included?If so how do I pick the one to use?Thank you