Now I have a problem if I connect the ground from arduino to the ground of the pwm circuit it blows the regulator from arduino and fries the atmel chip. The problem is I can't use 2 different power supplies (it work's perfect if the arduino and the led from TLP250 are on separate power supply completely isolated from the motor power source) because it all has to be powered by the same 12V car battery.
Since the TLP250 is opto-isolated there is no need to connect it to the PWM circuit at all, but clearly you've done something badly wrong to blow the Arduino - without a schematic there's no way to understand what though.
The first picture is what works (instead of 1 mosfet I have 2 in paralel), the second is what I need but it blows the arduino regulator each time (i also tried with separate ams1117 and same result).
MarkT:
Since the TLP250 is opto-isolated there is no need to connect it to the PWM circuit at all, but clearly you've done something badly wrong to blow the Arduino - without a schematic there's no way to understand what though.
I understand , but I need to power them both from the same 12v battery.
Ah, you connected the motor supply direct to the Arduino - that's extremely spikey and noisey since you
have no effective decoupling (the 100nF is irrelevant here as the motor draws huge currents - 1000uF or
more of low-ESR electrolytic plus some high value ceramic (10uF?) would be needed to make inroads into
30A switching noise).
If you put a 'scope on that 12V supply you'd see the problem instantly!
You may have made matters worse by poor layout (not using twisted pair everywhere).
Use a separate power supply for the Arduino, perhaps an LM2596 buck converter whose input is an RC filtered
version of the motor 12V supply (and add decoupling to the motor supply anyway, 1,000uF 25V or so).
Adding the 1000uF cap (first a tried two 470uF and then added another 2200uF) almost resolved the issue, there are still some issues at full load . I wonder adding a choke coil before the arduino regulator would help ?