Help me to troubleshoot the TDA1060 spice model - Page 1
Forum section: electronics / beginners

author: proxymo
author_rank: Contributor
timestamp: July 12, 2025, 06:00:35 pm
content: Hi,I trying to make a spice mode for the TDA1060 but the oscillator does not work.The circuit is a SPICE netlist for a sawtooth oscillator, where the oscillator's current is set by an external resistor (RX) and capacitor (CX), with additional features like feed-forward (FW) and synchronization (SYN) control.The challenge is that most SPICE-related resources for sawtooth oscillators rely on PULSE or PWL (piecewise linear) functions to define waveforms, especially in LTspice or PSpice tutorials. My netlist, however, creates a sawtooth waveform through a self-oscillating circuit without relying on predefined waveform sources like PULSE.Is that possible in LTspice?* --- Oscillator ---* Oscillator current set by external RX resistorE_RX_BIAS RX VEE VALUE={2.5}G_CHARGE VEE CX VALUE={IF(V(UVLO_OK)>0.5 & V(OSC_RUN)>0.5, -2.2*I(E_RX_BIAS), 0)}S_DISCHARGE CX VEE OSC_DISCHARGE VEE SW_MODEL.MODEL SW_MODEL VSWITCH RON=10 ROFF=10G VOFF=0.5 VON=0.5B_OSC_SET OSC_TRIG_SET VEE V={IF(V(CX,VEE) >= V(SAW_H_EFF), 1, 0)}B_OSC_RESET OSC_TRIG_RESET VEE V={IF(V(CX,VEE) <= V_SAW_L, 1, 0)}X_OSC_LATCH OSC_TRIG_SET OSC_TRIG_RESET OSC_DISCHARGE OSC_DISCHARGE_N VEE SRLATCH* Feed-Forward (FW) increases sawtooth peakB_SAW_H_EFF SAW_H_EFF VEE V={V_SAW_H + V(FW,VEE)}B_OSC_RUN OSC_RUN VEE V={IF(V(SYN,VEE) > V_SYN_H, 1, 0)}S_SYNC_RESET CX VEE SYN_RESET_CTRL VEE SW_MODELB_SYNC_CTRL SYN_RESET_CTRL VEE V={IF(V(SYN,VEE) < V_SYN_L, 1, 0)}

author: iMo
author_rank: Super Contributor
timestamp: July 12, 2025, 06:26:07 pm
content: Would be better if you create a schematics of the chip in the LTspice.The saw-tooth generator block could be simulated either by the PWM signal (parametrized), or you may create a schematics for it..

author: proxymo
author_rank: Contributor
timestamp: July 12, 2025, 07:06:14 pm
content: no, that does not help, the tda1060 is very complicated and the best way is the one that I am using, but I guess LTspice can only use the PULSE command.I need a super mega expert of LTspice because not even all the AI chat can solve it.

author: MariuszD
author_rank: Regular Contributor
timestamp: July 12, 2025, 08:56:13 pm
content: Quote from: proxymo on July 12, 2025, 07:06:14 pmThe best way is to simulate only what is necessary to run the project. Why do you need to simulate this ancient IC? Using LTSpice is not a problem for me, the issue is the incomplete documentation of the TDA1060. It is impossible to accurately model components whose operation is not fully described. By taking measurements on a real circuit, you can gather the information, needed to build a complete model. But it might not be worth the time spent.The netlist is good when you are talking to a computer, for a conversation with a human, prepare a schematic. When you were writing the netlist, you had to make a schematic.Quote from: proxymo on July 12, 2025, 07:06:14 pmAI is no better than the dumbest person in the world.

author: proxymo
author_rank: Contributor
timestamp: July 12, 2025, 09:02:00 pm
content: I disagree on everything you said.all the .lib file is correct, but the oscillator does not work, and I need the tda1060, that it!People still doing retro-gaming (ancient?) but they like it, so do I.I hope that some one will be able to solve this puzzle or tell me that LTspice can only handle PULSE.PS. Please if you have to leave unnecessary comments, do not do it, I only need answers!

author: MariuszD
author_rank: Regular Contributor
timestamp: July 13, 2025, 04:58:03 am
content: Quote from: proxymo on July 12, 2025, 09:02:00 pmHow do you know? Simulating your circuit is not possible without an oscillator.Quote from: proxymo on July 12, 2025, 09:02:00 pmThere is nothing difficult about creating an oscillator, an example is attached. But I don't have all the information about the parameters of TDA1060, that is why the amplitude is correct but the frequency is not.I can fix your oscillator circuit, but I need to understand the reasoning behind your solution. That's why I want to see the schematic. The netlist is unreadable for humans, so it needs to be translated into a schematic. I don't want to do it myself since the person who created it must have created a schematic for himself.Quote from: proxymo on July 12, 2025, 09:02:00 pmRetro gaming makes sense to me. Retro gaming doesn't require the TDA1060 spice model. Creating a realistic model of the TDA1060 is more work than creating a functioning power supply with this circuit or fixing old one. That's why I'm asking why you need it.Is your model created by AI?If this is true, it will never work properly.

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 07:18:01 am
content: I think you failed to notice that there is a zip file with all the files to test, so just download it, is attached to the first post. Also it is very easy to find the datasheet for the TDA1060. I need it to troubleshoot various welders that use that IC and mostly because is a challenge. Yes the model was created by AI following the specs in the datasheet and was checked by various AI and I have done even more complicated things with AI and at the end they all work (like c implementation of tensorflow from scratch).Your oscillator has nothing to do with TDA1060 it is a circuit and obviously works, but unfortunately there is no block diagram for the sawtooth generator in the TDA1060, so has to be done internally.

author: Ian.M
author_rank: Super Contributor
timestamp: July 13, 2025, 07:32:37 am
content: What everyone is objecting to is you expecting us to reverse engineer your netlist to get an understandable schematic for the internals of the model. *SHOW* *US* *THE* *CIRCUIT* not the <double-expletive> NETLIST!LTspice even supports hierarchical schematics (see Help: Schematic Capture: Hierarchy) which can be used to develop block models in the schematic editor GUI. Once they are bug-free its easy to export the netlist and make a few manual edits to convert it to a .subckt model for general use.And *YES* LTspice is quite capable of generating waveforms from basic circuit principles rather than the limited selection of 'canned' waveforms offered by a voltage or current source. I've done something similar myself when modelling a SMPS, but didn't bother wrapping it up as a subcircuit model.

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 11:35:18 am
content: You are right, so I started all over again and done the sawtooth circuit as the NE5560 datasheet which is equivalent to the TDA1060 but still no luck, zipped all the files.

author: Zero999
author_rank: Super Contributor
timestamp: July 13, 2025, 01:15:25 pm
content: Windows says the zip files you've posted are invalid. What format did you use?I'll try later using my Linux machine, but until then can you please post plain text file? .asc can be uploaded as-is and in the case of .lib, .sym and ,sub files, just append .txt to the file name i.e. change TDA1060.sub to TDA1060.sub.txt

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 01:39:28 pm
content: here we go

author: Ian.M
author_rank: Super Contributor
timestamp: July 13, 2025, 02:14:33 pm
content: Windows may not like the .zip, but IZarc (which I use by preference) here is fine with it, as is WinZip!You have four critical faults:Missing ground on source V1 (charging supply for timing capacitor)Broken wire from U2 to U3 R in underneath the netlabel 'N002'Your flipflop doesn't work as expected: applying logic high to S does not make Q high, and applying logic high to R does not make QN highYour switch model doesn't properly specify the threshold voltage and hysterisisAlso annoyances:Poor use of net labelsPoor choice of timescale relative to RC time constantCrossing wires joining! (node 'Vct')Expecting spice engine to honour initial conditions without UIC in the .TRAN commandHere's a fixed version that *does* oscillate as expected, using a native LTspice A device 'srflop' instead of your borked flipflop.Thank you for providing a schematic this time. I hope you can now see why we demanded the schematic, not just a netlist! Also that's why I haven't attempted to fix your flipflop . . .

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 02:23:32 pm
content: Thank you very very very very much indeed, could you please elaborate on each of the failed points?also is the sub for mycomparator right? Do I need to add Hysteresis?

author: mtwieg
author_rank: Frequent Contributor
timestamp: July 13, 2025, 02:24:54 pm
content: Ian beat me to it.I got the circuit to roughly work by editing all three subcircuits. In addition to what he listed, your comparator models had Cstate in series with the output, rather than being from out to gnd. The flip flop had S and R backwards. And not sure what IF(V(VEE)>0, V(VEE), 12) was meant for, I just replaced that with a fixed 12.I agree that you should make use of existing behavioral models when possible. For example the logic elements in LTspice work fine (you can tailor them to have whatever speed and logic levels you like). Comparators can be implemented with simple dependent voltage sources.If you do intend to make your own subcircuits, you should test each one before attempting to use them in a larger simulation. I think if you try this the problems will immediately be clear.

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 02:31:25 pm
content: Well mycomparator is not mine is taken from this professor:So since is a professor I trusted him.https://github.com/marcosalonsoelectronics/LTspice-5https://sites.google.com/view/j-marcos-alonso/homeSo what is wrong with it?Shall I add hysteresis?However The file given by Ian.M (thanks again) the comparator is like the original, namely:* Ideal Comparator* Marcos Alonso - May 2021*.subckt MyComparator in+ in- pos neg outE1 out 0 value={if(V(in+,in-)>0, V(pos),V(neg))}R1 in- in+ 1e6R2 neg 0 1e6R3 pos 0 1e6.ends MyComparatorAs for the rest, yes you can not trust any of the AI chat!

author: mtwieg
author_rank: Frequent Contributor
timestamp: July 13, 2025, 02:37:42 pm
content: Quote from: proxymo on July 13, 2025, 02:31:25 pmI see nothing wrong his comparator models.QuoteYou added Cstate and Rstate, but connected them wrong.

author: Ian.M
author_rank: Super Contributor
timestamp: July 13, 2025, 02:48:12 pm
content: Personally, I'd use the native digital (A device) 'diffschmtbuf' as a comparator.The down-side is its 'self-powered' and its output acts as a source i.e. it doesn't use supply voltages, but if you need realistic supply currents and supply disturbances to appear on its output, that can be solved if you swap it for 'diffschmtinv' and buffer its output with a pair of MOSFETs (or a single one for open drain) in the classic inverting buffer configuration.You also need to set appropriate instance parameters, the most important of which are Vt=0 (to act as an ordinary differential comparator), and sufficiently small Vh.Quote from: mtwieg on July 13, 2025, 02:37:42 pmWhich is why its best to debug block models as hierarchical schematics, and thoroughly test them in a test jig before exporting their netlist and converting it to .subckt form.

author: MariuszD
author_rank: Regular Contributor
timestamp: July 13, 2025, 03:24:52 pm
content: The oscillator posted by Ian.M has one flaw. It discharges the capacitor too quickly, that's why the voltage drops to 0 instead of 1.1 V. Add some resistance in series with the switch.This oscillator works, but it is not fully compatible with TDA1060. The resistor must be connected in a different way. The datasheet states that 6.4 kOhm and 6.4 nF give 30.5 kHz. In the simulation, you have 22 kHz.

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 03:52:07 pm
content: Can you rectify that and post the files?

author: Zero999
author_rank: Super Contributor
timestamp: July 13, 2025, 05:57:52 pm
content: If it's a rail-to-rail comparator, then use a couple of voltage controlled switches. If you want to slow it down, put RC circuits on the inputs. The output can be slowed down with capacitors to the positive and negative rails..subckt cmpR2R +in -in +V -V outS1 out +V +in -in SWCS2 out -V -in +in SWC.model SWC SW(Ron=1 Roff=1T Vt=0 Vh=1m).ends

author: MariuszD
author_rank: Regular Contributor
timestamp: July 13, 2025, 06:00:44 pm
content: I fixed what I know so far.Rx and Cx are connected to the ground and frequency is 30.5 kHz for Rx 6.4 kOhm and Cx 6.4 nFFor now, there are no feed-forward and sync inputs

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 06:24:20 pm
content: Great thanks, because there is not enough information in the datasheet of TDA1060, I am using the pin to pin equivalent NE5560, which has more details of each block of the IC.Fig6. shows the sawtooth generator and that is how I initially modelled this on.I hope that the circuit is close enough to that

author: proxymo
author_rank: Contributor
timestamp: July 13, 2025, 08:29:05 pm
content: Implemented the Feed-Forward hoping that is OK, but I am straggling to do the SYN pin 9.

author: mtwieg
author_rank: Frequent Contributor
timestamp: July 14, 2025, 12:40:31 pm
content: If your aim is to create an accurate behavioral model of the TDA1060 with all its optional functions, then I don't think the information in the datasheet will be sufficient. You would need to experiment with real parts to infer various things about what's going on inside.For example, regarding the SYN pin, the datasheet only states that when this pin is low, the sawtooth generator is "stopped". Does it leave the ramp voltage floating? Or pull it to GND? Or hold it at 1.3V? Who knows.Is there some reason you're interested in this specific part (homework assignment)? There are many other pwm controllers with similar function sets, but are documented much more thoroughly and are much easier to model.

author: proxymo
author_rank: Contributor
timestamp: July 14, 2025, 02:04:14 pm
content: You need to check even the NE5560 datasheet which is pin by pin compatible and with a lot more informations

author: proxymo
author_rank: Contributor
timestamp: July 15, 2025, 04:03:49 pm
content: For anyone that has downloaded the fast-forward file pin - of G1 must be connected to ground

author: proxymo
author_rank: Contributor
timestamp: July 15, 2025, 10:27:05 pm
content: Can someone help me to make this ltspice model work?