When the controller is attached the gate wires are under 2 inches which was as short as I could go without a pcb.
The gate leads aren't really a big deal, if it's not being driven hard. The load current path is the biggest area of concern.
You can always do better -- here's one way, with copper strips and free air (point to point) wiring:
Note that the gate leads aren't particularly short (like 10" to the driver circuit), which is fine for the drive strength.
(There's a formula for that, by the way: what lead length is acceptable, given drive strength or resistance, and transistor ratings.)
Note how short the load current path (supply capacitor to drain to source to diode back to supply capacitor) is. That's how little wiring length you can afford!
The inductor is not gapped as far as I am aware. I just wrapped 10 awg wire around the EE core.
Hmm, seems like maybe 50 turns? At 40A, that's 2000 amp-turns, which is enough to saturate even a distributed-gap core, like a T300-26D (the toroid used here
https://www.seventransistorlabs.com/Images/Buck3.jpg ). You'll need, probably around 1/16" of air gap on that thing, to keep it linear. (There are formulas for this as well; to use them, you'll need to measure the size of the core, particularly the cross-sectional area of the center limb the wires are wrapped around.)
My control loop uses the pots as setpoint only which get read by the adc and which ever pot is higher is what controls what sensor is looked at so when I want CV I look at the voltage dividers and when I want CC I look at the shunt. Never both at the same time.
Whoa! So, if it's sitting there, working into a high resistance load (so the voltage is nominal and the current is small), set at some voltage, then you raise the current setting past the voltage pot setting, and suddenly it jumps up to maximum output (full voltage, nominal amps), because it's trying to drive current now?
Holy moley! Let me off this rollercoaster!
What you need is more like: feedback <= max(voltage_sense, current_sense).
But that still wouldn't make sense, because you'd be trying to set both with one pot. What you actually need is: two control loops, one for voltage and one for current; each one receives its respective inputs (voltage setpoint pot, and voltage sense; current setpoint pot, and current sense), and they output two different "error" signals. You set PWM <= max(V_error, I_error).
That way, whichever sensor is closer to the set threshold, is the one doing the regulation.
The best method, however, is to cascade the loops, so PWM is set by the current controller (inner loop). Current setpoint is then set by min(voltage controller output, current pot), and voltage setpoint is set by the voltage pot.
This way, the inductor (and therefore switch) current can never exceed the set current, and the voltage cannot exceed the set voltage for longer than it takes the voltage controller to respond (which is typically in the milliseconds).
Note the current shunt needs to be on the inside (i.e., before the output filter cap), otherwise it isn't measuring only inductor current, and the control will be terrible.
I do understand a little of the post you provided and it sounds like for the inrush current was to high and that was blowing up the fets but if I did my math correct my inrush. current should be limited to 50 amps by the inductor. Unless you think it is saturated in which case that would be bad as I never thought I would be pushing the inductor that hard. I didn't think I would need a real control loop(pid or feedfoward) because the anodizing process is so slow.
Inductors don't limit inrush current. They can soften it, but not usually much. Normally, SMPS need electrolytic capacitors large enough that the amount of softening isn't significant (i.e., peak current is limited more by capacitor ESR). You can get by with less C than this, but you need special capacitors (usually film types) that are more bulky, and expensive; and you can only do so much, anyway, before the control loop becomes unstable.
But more importantly: no matter how much inductance you have, it won't protect against a short circuit! Whether it's for lab or electrochemistry use, you
will need short circuit capability sooner or later!
The inductor is definitely saturating. It's probably saturating after just a few amperes, so it will be doing almost nothing over most of your desired operating range.
Tim