LTspice and pulse voltage  - Page 1
Forum section: electronics / projects

author: lk
author_rank: Regular Contributor
timestamp: August 03, 2012, 08:44:47 pm
content: Greetings,I was playing around with LT Spice, and i wanted to simulate a relay switch between two power sources, i planned to do it with a negative pulse on the voltage source, i don't know if this is the right way to do this. According to the datasheet for the relay the switch time is 1ms.but what i do know is that the massive spikes can not be good at all, but i guess that is normal behavior when you cut the current path with an inductor in there.I guess my question is, does this setup properly simulate the relay action, eg the 1 ms switch time where the power is "disconnected". Maybe there is a problem with my raise and fall times, could it be that my load is infact without power for 3 ms?this is 24 volts and i peak load is 6 A.-l

author: PA0PBZ
author_rank: Super Contributor
timestamp: August 04, 2012, 12:07:34 pm
content: Congratulations, you just invented the boost converter.I'm not sure what you are trying to do, but yes, these spikes are to be expected in this setup.If you are trying to switch a relay, shouldn't the relay coil be parallel to the supply?

author: lk
author_rank: Regular Contributor
timestamp: August 04, 2012, 07:51:29 pm
content: DohNo I'm not trying to switch the relay, I'm trying to make the "output" of my relay drop voltage as little as possible when the "relay" switches, that's why I'm talking about the 1ms switching time. So I'm trying to figure out if i need to do something to my output to keep it high, or just hope that the 24v PC power supply in this case can survive. That's why I'm messing with the pulses.So i have 2 independent 24 volt inputs that i need the relay to switch between to the same output, that switch takes 1ms, so i was trying this to see what i could do so that i see as little drop on the output as possible.i hope this makes some sense-lk

author: TerminalJack505
author_rank: Super Contributor
timestamp: August 04, 2012, 08:20:04 pm
content: I'm not sure I understand what you're trying to do but if you're trying to keep the relay's coil energized while you switch between two power sources then you might try the attached schematic.It will, in a sense, allow you to power the relay from two power sources simultaneously. In fact, the power supply with the higher voltage will power the coil. If one power source falls off then the other will pick-up automatically.You can use the circuit for switching between two power sources as well. You can bring one power source online while the other power source is still online thus preventing the relay from dropping out.The freewheeling diode across the coil will keep the coil energized for a short while in the case where both power supplies fall off. (You need it anyway to avoid the voltage spikes.)

author: jahonen
author_rank: Super Contributor
timestamp: August 04, 2012, 08:21:50 pm
content: If you want to simulate a relay contact changeover, use the voltage controlled switch component, "SW". You just need to parametrize it.Regards,Janne

author: PA0PBZ
author_rank: Super Contributor
timestamp: August 05, 2012, 08:49:48 am
content: So if I understand correctly this is what you are trying to do.How are you going to control the relay?

author: lk
author_rank: Regular Contributor
timestamp: August 05, 2012, 06:55:33 pm
content: PAOPBZ,This is exactly what i wanted to to, as for how to control the relay, i will most likely need a micro controller, as i have a feeling that even with hysteresis a stand alone comparator looking at the "flaky" source, in this case a PV setup, there is no reason to switch back if its 0100 in the morning, and there is no sunlight, even if the battery should somehow recover.Jahonen, i will give the "sw" component a look.But i guess i should still be able to simulate the relay switchover withe the negative pulse i use.-lk

author: PA0PBZ
author_rank: Super Contributor
timestamp: August 05, 2012, 07:30:31 pm
content: I think a simulation would not be very accurate, because what you are interested in is the output of the power supply (so the 3.3, 5 and 12 volts), and not the input, and you are not going to simulate the whole power supply are you?And since there are no relays in LT Spice you.d have to build one yourself first. What I would do is take your relay and connect the PSU to both the outputs, switch the relay manually and put a scope on the outputs of the PSU while loading them with what you are intending to do. That way you can see what happens to the outputs while switching the input under load.something like this:

author: lk
author_rank: Regular Contributor
timestamp: August 06, 2012, 09:19:44 am
content: Hi PA0PBZ,I'm getting an off the shelf 120 watt PSU, i don't want to deal with something like that with my limited knowledge. On your last drawing(I'm wondering what tool you use), the relay should switch between 2 different 24 volt inputs, to a single 24 volt output, and the coil in the relay is driven from a 5 volt source, but that does not really matter, as i wanted to see how much the output line would "sag"/"drop" during the switch over, while the load is 6A.And i would like to do this with real parts, but my lab PSU is only 2A, i don't have the batteries or the panels or the PSU. This is the reason why i was trying to simulate a relay switchover, so i at least catch the "low hanging fruit" before i buy anything that turns out not to work as i expected.-lk

author: PA0PBZ
author_rank: Super Contributor
timestamp: August 06, 2012, 04:18:41 pm
content: Quote from: lk on August 06, 2012, 09:19:44 amThe above drawing was just an idea of how you can test the setup, no need to take anything apart, just measure the different voltages when switching the relay with the pushbutton. The drawing was made on circuitlab.com, I normally use LT Spice too but there are no relays in there.QuoteI still think that you can not simulate it without simulating the whole PSU, it strongly depends on the parts inside there, like how big the capacitors are and such. However, my feeling is that a 1 ms lack of supply should not be a problem.

author: PA0PBZ
author_rank: Super Contributor
timestamp: August 06, 2012, 05:11:30 pm
content: This is the best I can think of using LT Spice. If you want to play with it copy the below to an .asc file.Code:Version 4SHEET 1 880 680WIRE 128 112 16 112WIRE 224 112 208 112WIRE 320 112 304 112WIRE 400 112 320 112WIRE 320 128 320 112WIRE 192 176 192 160WIRE 144 192 144 160WIRE 192 192 192 176FLAG 16 192 0FLAG 144 192 0FLAG 400 192 0FLAG 320 192 0FLAG 192 272 0FLAG 192 176 SWFLAG 400 112 OUTSYMBOL voltage 16 96 R0WINDOW 0 24 16 Invisible 2WINDOW 3 -67 55 Left 2WINDOW 123 0 0 Left 2WINDOW 39 0 0 Left 2SYMATTR InstName V1SYMATTR Value 24SYMBOL sw 112 112 R270WINDOW 0 24 16 Invisible 2WINDOW 3 24 96 Invisible 2SYMATTR InstName S1SYMBOL res 320 96 R90WINDOW 0 0 56 Invisible 2WINDOW 3 -39 56 VTop 2SYMATTR InstName R1SYMATTR Value 0.1SYMBOL polcap 304 128 R0WINDOW 0 24 8 Invisible 2WINDOW 3 -84 34 Left 2SYMATTR InstName C1SYMATTR Value 10000µSYMATTR Description CapacitorSYMATTR Type capSYMATTR SpiceLine V=35 Irms=995m Rser=0.067 Lser=0SYMBOL voltage 192 176 R0WINDOW 0 24 16 Invisible 2WINDOW 3 38 105 Left 2WINDOW 123 0 0 Left 2WINDOW 39 0 0 Left 2SYMATTR InstName V2SYMATTR Value PULSE(5 0 0.002 0 0 0.001)SYMBOL res 384 96 R0WINDOW 0 36 40 Invisible 2WINDOW 3 63 57 Left 2SYMATTR InstName R2SYMATTR Value 4TEXT 232 240 Left 2 !.model SW SW(Ron=10m Vt=2.5)TEXT -52 302 Left 2 !.tran .004

author: lk
author_rank: Regular Contributor
timestamp: August 07, 2012, 06:38:35 am
content: Thank You PA0PBZ,I'm very grateful for the time you have spend helping me with my somewhat imprecise odd questions, but maybe this helps others as wellWhen i have all the bits and pieces i will make a posting on it, if all this has been in response to a problem that is infact not a problem, i think you are right in this.-lk

author: lk
author_rank: Regular Contributor
timestamp: August 07, 2012, 07:30:25 pm
content: And sometimes problems are just imagined, looks to me like the entire switchover event is done in 50ns, there is no catch diode installed, and its only run off 12volts as that is what the coil can handle. So i guess that i can get away with 1000uF capacitance.-lk

author: PA0PBZ
author_rank: Super Contributor
timestamp: August 08, 2012, 10:48:33 am
content: What are we looking at here? Yes, a Rigol scope screendump but it doesn't tell much without the circuit it's measuring.