Wednesday, July 25, 2012

Spice It Up

I do not go around trying to pass myself off as a EE, but embedded software development does require a fair amount of knowledge in electronics and I thought it was high time to brush up on my circuit analysis skills ...a professional improvement activity! We have a PSpice license at my work, but it is usually needed by our EE for working on the board layout. I went looking for an alternative and discovered LTspice. Sadly this is only available for Windows, but it is free, and seems to provide fairly complete SPICE functionality in a GUI environment. I thought I'd make a few notes from my learning activities.

The following circuit is extracted from the fueling controller for which I write software in my job as a Control Systems Engineer. I thought I understood the function of the circuit, but it caused me considerable grief and wasted time trying to demonstrate the expected behavior in LTSpice.


In the circuit, Vout is connected to the gate of an N-channel MOSFET and the gate voltage is controlled by the 5V signal at Vctl. The non-inverting input of the LM2903 is connected to a voltage reference of approximately 500mV established by the potential divider at the junction of R3 and R4. The inverting input of the 2903 would be connected to the signal Voc, such that the comparator is turned on by the presence of a voltage on Voc in excess of 500mV. The intent is that Voc would be connected to some other diagnostic or protection circuitry, and used to detect when the gate drive to the MOSFET (connected at Vout, not shown) should be disabled because of some kind of fault condition. My understanding is that it is the open-collector characteristic of the LM2903 output that enables this to work as intended. Although the comparator can't drive it's output high (allowing Vout to be 5V when Vctl pulse is high), the 2903 is nonetheless able to pull Vout low when the inverting input voltage exceeds the .5V threshold. In the example circuit, Voc is connected to ground, in order to force the comparator ON for the demonstration.

The output of the circuit is shown in the waveform trace. I believe the open-collector characteristic of the 2903 is not being correctly modeled, preventing Vout from being pulled to 0V when the Vctl pulse goes low. The LM2903 model was downloaded from the ON website


The following circuit, when simulated, provides the desired behavior. Vout is pulled low by Vctl even though the 2903 output state is high. It uses an LM2903 model downloaded from the Texas Instruments website.




Apparently it is "buyer beware" when using 3rd party models in SPICE!