Arduino PID Soldering Station - mosfet problem - Page 1
Forum section: electronics / beginners

author: mike_mike
author_rank: Super Contributor
timestamp: April 03, 2020, 12:18:13 pm
content: Hello. I built a soldering station based on a PID controller for a Gordak soldering iron. I used a Nokia 5110 LCD as a display. The schematic and the code are attached. The problem is that I tried two times using different IRF530 transistors and the heater of the soldering iron was staying cold. When I used a K1257 or a P55NE06, the soldering station worked normally. Later I added a anti parallel diode to the heater of the soldering iron (1N4007).Why the soldering station was not able to heat my soldering iron when I was using IRF530 ?This is the original project:https://www.allaboutcircuits.com/projects/do-it-yourself-soldering-station-with-an-atmega8/My code:https://pastebin.com/uuDs7ZB0The schematic is attached.

author: mikerj
author_rank: Super Contributor
timestamp: April 03, 2020, 12:57:39 pm
content: Possibly fake or damaged parts since MOSFETs are susceptible to ESD damage.

author: mike_mike
author_rank: Super Contributor
timestamp: April 03, 2020, 04:27:23 pm
content: The mosfet is heating up to about 50 degrees C mounted on a heat sink of 3.5 x 5.5 cm.Is that normal, if the mosfet is simply driven on/off ?

author: WattsThat
author_rank: Frequent Contributor
timestamp: April 03, 2020, 09:50:43 pm
content: Typical internet crap design.The mosfet is being driven from a 5 volt PWM output on the atmega. Therefore, you need a mosfet that fully turns on with a 5 volt signal, the IRF530/540 and P55NE06 require at least 10 volts to reach their stated, lowest output resistance. What you need is a “logic level” rated mosfet that achieves its rated on resistance with 3.3-5 volts on the gate. The 2SK1257 is a logic level rated device and has a reasonably low on resistance of 24 milliohms so that is the device to use for this application.There is another common error in the design and that is the way R2 and R3 are connected, it’s wrong as it forms a voltage divider, lowering the limited available gate drive voltage. The high side of R3 should be connected to the atmega pin (MOSI) rather than the gate of the mosfet. R3 is also much lower than it needs to be, 10k is perfectly fine for the design.The reason why the mosfet gets hot is because it’s not fully turned on and operating in its linear region, acting as a variable resistor and dropping the soldering iron element current across the mosfet according to P =I^2 R. Once the mosfet is fully turned on so it’s drain to source resistance goes down to its rated on resistance, that heating effect will be greatly reduced or eliminated.

author: mike_mike
author_rank: Super Contributor
timestamp: April 06, 2020, 05:55:17 pm
content: Hello, I made the original schematic of this project using 7 segment display and Arduino Uno.The project worked fine on the breadboard but after building the PCB it shows only 888 on the display.I checked the PCB and the connections and it seems to be ok.What should I do ?The code:https://pastebin.com/0KifThXCI used common anode 7 segment display driven by 3 pnp transistors (BC327-40), each with 1K base resistors.In the schematic are Common Cathode, but I used common anode with the same pinout.If I connect the display to computer only, then it first shows 350 and after this it shows a number at about 500. But if I connect it to the 24V power supply, then it shows 888.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2020, 06:59:03 pm
content: Quote from: mike_mike on April 03, 2020, 12:18:13 pmThat schematic is using only about 4V to control the transistor's gate. That is not enough for an IRF530. For example, the datasheethttps://www.vishay.com/docs/91019/91019.pdfspecifies 0.16 Ohms for RDS(on)at VGS= 10 V. At 4V that MOSFET can barely start to open. Either you use a higher voltage to control the gate of the MOSFET, or use another MOSFET model with a lower threshold gate voltage, VGS(th).To search what models to use, you need to search for "low threshold MOSFET", sometimes improperly named "digital" MOSFETs, too.

author: mike_mike
author_rank: Super Contributor
timestamp: April 06, 2020, 07:07:11 pm
content: I already solved the problem with the mosfet. I used a logic level mosfet and the soldering station with Nokia 5110 LCD is working.I am concerned about the problem described at the reply 4.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2020, 07:51:33 pm
content: Congratulation for solving that.Solving a problem is important for today, understand what and why it happened is important for the rest of the days.About why it worked on the breadboard but it doesn't work any more on the PCB, it's because something has changed. I know this sounds like Captain Obvious, but there must be something you changed but don't know yet, maybe a mistake not yet spotted, maybe some wrong wiring. If it all worked well on the breadboard, then the same components must work on a PCB, too.Verify the PCB again, verify the wiring, or at least put some pictures with both sides and the wires.

author: floobydust
author_rank: Super Contributor
timestamp: April 06, 2020, 08:36:16 pm
content: Why is variable 'Input' a float, going intoanalogRead(),which returns an int? "Returns int (0 to 1023)". Same for double 'newSetpoint'.I would improve the thermocouple amp noise filtering, move one leg of C3 to other side of R15 and add a 10nF capacitor across R12. It's likely your 24VPSU adds noise. Rx1 is typically 1MEG.Your software for the A/D needs averaging and open-thermocouple detection, and best to not read the A/D at the same time the heater is switched as it causes a glitch.I don't think you are linearizing the thermocouple with that linear scaling - some thermocouples are non-linear in the soldering tips, depends on the make/brand.Code:uint16_t adcAvg, adcTot;adcTot -= adcAvg;adcTot += readAdc(adcChannel);adcAvg = adcTot >> 4; // exponential average 16 samples

author: mike_mike
author_rank: Super Contributor
timestamp: April 06, 2020, 09:31:05 pm
content: I managed to display 350 on the display but it does not change as I rotate the pot. The voltage at the pot pin varies from 0V to 3.62V.It works only if I connect the Arduino to the USB of the computer.If I use the 24V power supply, then it shows 888.@floobydust Thank you for the information. Currently I am working to make the soldering station to work. Then I will probably try some modifications.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 06, 2020, 10:26:34 pm
content: Looking closer, the schematic for the display is wrong.J4 pin 1 is supposed to be GND according to first page, yet in the second page J4 pin 1 is at the emitter of the PNP transistor, and expected to open those transistors with a positive voltage, which is wrong.Where from are coming the J3 pins 1, 2, 3 in page 2? Couldn't found them in page 1.Also, this doesn't make any sense:Quote from: mike_mike on April 06, 2020, 05:55:17 pmUnless you attach the schematic you used for the final version, (preferably some pics, too, so we can check for PCB errors) nobody can guess what you did.

author: mike_mike
author_rank: Super Contributor
timestamp: April 06, 2020, 10:42:40 pm
content: Please find attached the explanation about the connections between the schematics and the final versions of the schematics.In the main schematic (the one with Arduino) the connector J2 is connected pin to pin to connector J1 from the display schematic. The last 4 pins of the J2 connector (main schematic) are connected to J3 and J6 connectors from the display schematic, J6 is connected to pin 12 of J2. The connector J3 from the display schematic is connected as follows: pin 1 to pin 11 of J2 (Arduino schematic), pin 2 to pin 10 and pin 3 to pin 9.Also, please find attached the layouts. This is all I have for now. I verified a few times the connections on the physical circuit and they are fine.Edit: I managed to display the current temperature of the soldering iron but only when the Arduino is connected to the PC (USB). If I connect the 24V supply and disconnect the USB, then it shows 444 or 666 of 888. One problem was the 100nF capacitor (Cref1) which was in short circuit and I did not found it at the previous checks.Edit 2: It is working but only if I connect both USB and 24V power supply. What should I do to make it work only with the 24V power supply ?Edit 3: I found a solution for this problem: If I powered the Arduino to the Vin pin, then the minimum voltage allowed here is 7V. In my schematic, the supply voltage at this pin was 5V, so it was lower than 7V. I read that Arduino can be powered through the 5V pin, but this is not recommened. I also read that it can be powered via the USB, so I cut a USB cable then I soldered the + and - wires to the output of the 5V regulator (7805) then the other end of the cable I introduced into the USB connector on the Arduino. And it worked.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 07, 2020, 08:17:02 am
content: Quote from: mike_mike on April 06, 2020, 10:42:40 pmGood to hear you found both the problem and the workaround for it, well done!

author: mike_mike
author_rank: Super Contributor
timestamp: April 12, 2020, 03:18:43 pm
content: Hello. I am in the following situation: I am out of stock for logic level mosfet transistors and I want to adapt the schematic in order to use standard threshold Vgs mosfet (2-4 V). For example: IRF630, IRF530, IRF830.I drew the attached schematic.I modified the right side of the schematic, by adding a 12V regulator and a push pull configuration for the mosfet.Please have a look at the schematic and tell me what you think.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 12, 2020, 04:53:00 pm
content: See this PDF from TI, there are schematic examples, too:Fundamentals of MOSFET and IGBT Gate Driver CircuitsAbout picking the right MOSFET, you need to look for those with a minimal RDS(on). For example, let's say your soldering iron gas 48W. At 24V, this will mean a 2A current.Looking in the datasheets for the transistors you mention, the typical RDS(on)ofIRF830is 1.5 ohms. This means even if kept continuously on, with Vg = 10V, it will still dissipate approx. 1.5* 2A = 3W which is a bit much. The other two MOSFET models are preferable. The lower RDS(on)the better.Apart from the power dissipated by the RDS(on)during the on time, there is also power dissipated during each edge of the PWM signal, while the MOSFET is turning on or off. Even if the edges from the microcontroller's PWM are very sharp, there is always the parasitic capacitance of the MOSFET gate (or of the bipolar transistors junctions) that will accumulate charge, thus slowing down the switching times, which is bad. The first PDF explains other subtleties of switching a MOSFET.Choosing a lower PWM frequency can also help reducing the power dissipated by the MOSFET, because there is are less switching edges per second.

author: mike_mike
author_rank: Super Contributor
timestamp: April 14, 2020, 05:59:45 pm
content: It is normal for 7812 and 7805 regulators to let the high frequency noise of a SMPS (24Vdc/3A) to pass through them ?Please have a look at the attached screenshots.The yellow trace is the input from the SMPS and the blue trace is the 12V output from the L7812 - DS0277, DS0279, DS0285.jpgAnd the 5V output of the 7805 regulator (blue trace): DS0288, DS0293, DS0296.The 7812 and 7805 regulators are cascaded.Same tests, but using a transformer with rectifier and filter (3x4700uF/35V) which is having a DC output of about 20-21 V dc. Yellow trace in the input in 7812, and blue trace is output of the 7812 and 7805.L7812: DS0304, DS0311, DS0314L7805 (blue trace): DS0328, DS0330, DS0338.Please find attached the schematic of the circuit.The circuit is working normally but I was just wondering if this is normal ... (both situations with SMPS and toroiodal transformer).Edit: I don't know more information about the SMPS apart from it is a cheap Chinese one.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 14, 2020, 11:49:59 pm
content: - Switching power supply can produce strong noises, and the switching noises can propagate either through the wires/PCB traces, or through the air as electromagnetic fields. Make sure the noise you see is from the traces, and not induced in the probes. Use the GND adapter spring coming with the oscilloscope's probes, and not the long GND wire with alligator.- Once you are sure the noises you see are from the PCB and not from the probes, try to see what happens if you put a 10...100 uF in parallel with C8.- Another method to stop the high frequency noises to enter into the stabilizers is to put in series an inductance, for example in series with D2, or to use ferrite beads.

author: mike_mike
author_rank: Super Contributor
timestamp: April 15, 2020, 05:43:38 am
content: I used the measuring method presented in the video and I have got the following results:Output of the SMPS: 0429, 0430, 0432.Output of the 7812: 0437, 0441, 0442Output of the 7805: 0448, 0451, 0455Please have a look at the screenshots.I observed that a part of the noise high frequency noise disappeared.Edit: I also checked with a 47 uF/63V capacitor in parallel with C8, but it didn't improved the results (the Vpp amplitude of the signal remains the same).The waveform from 0429 has the same frequency with the PWM signal of the pin 11 of Arduino.Edit 2: I also want to say that the 7805 and 7812 are connected using wires to the PCB, because they are installed on a heat sink. This also could be a source of noise. I measured with the oscilloscope in the spot were the wires are connected to the PCB and I got the screenshots below.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 15, 2020, 08:22:55 am
content: The only spikes looking very bad are from the power supply, the rest looks reasonably OK.- Any piece of wire is also an inductor, a capacitor and a resistor. All three at the same time. Long wires, or thin wires, can create very nasty spikes with switched loads. How does the +24V waveform looks like when measured at the output of the power supply (before the wires to the soldering station)?- In the schematic there is no capacitor between +24V and GND. There should be at least 2 of them. One of a few hundreds...thousands uF to act as a local energy "reservoir", and in parallel with the +24V electrolytic another 0.1 uF so the high frequency spikes can find a short path through the 0.1uF without going through the long wires up to the power supply. C1 and C2 you have now does not help if the 24V heater is connected before the D2, as the schematic suggests. Either move the C1 and C2 at the anode side, or simply remove the diode and pay attention to the correct polarity when connecting the circuit to its power supply.- Maybe you can find a broken PC power supply and recover one of those ferrite tor coils to put it in series with the +24V, right near the solder station.- The power circuit must have thick connection wires between the power supply, the MOSFET and the soldering iron socket. For example, the 3 multi stranded wires usually found inside 220V/16A power cords (the EU ones made with copper, not cheap Chinese fake 16A - even if they look like copper, if the metal they are made of is attracted by a magnet, that's not good).- Just to be sure there are no strange ground loops between the PC, the power supply and the oscilloscope, during probing do not connect the Arduino to the PC USB cable, leave the Arduino powered by its own circuit.- Another thing (we will let this to talk about after fixing the spikes), I suspect that the turn off edge of the MOSFET is not very sharp. The charge accumulated in the GS junction is left to discharge through the 4.7K to ground. If the MOSFET still heats too much, that's where the MOSFET driving circuit can be improved. This is visible in the DS 0429.jpg, where the strong spikes appears only when the MOSFET is turned on, but not when is turned off, suggesting the turn on edge is much faster than the turn off edge. To minimize the power dissipated in the MOSFET, and therefore its temperature, we want fast edges for both on and off switching.

author: mike_mike
author_rank: Super Contributor
timestamp: April 15, 2020, 09:17:17 am
content: 1. The +24V output waveform: DS0492 (without ferrite tor coil, without 2200uF capacitor and without 100nF capacitor).2,3. Using ferrite tor coil (a yellow one), 2200uF/63V capacitor, one 100nF capacitor, measured on the input of the soldering station: DS0525.4. I used thick wires - 1mm2stranded.5. Arduino was not connected to the PC during tests.6. When the mosfet goes off (the probe was connected to Drain): DS0166 (blue trace)and the probe connected at G of the mosfet: DS0160 (blue trace)Yellow - pin 11 (PWM) of Arduino.The mosfet does not heat too much. After a few tens of minutes, it is not hot, it is only a little bit warm. I mounted it on a 3x5 cm heatsink.7. Without ferrite tor coil, only with 2200uF capacitor in parallel with 100nF capacitor : DS0523

author: RoGeorge
author_rank: Super Contributor
timestamp: April 15, 2020, 10:43:03 am
content: Seems like you reduced the spikes 3 times, and the MOSFET doesn't heat much any more.Well done!If you insist to reduce the spikes even more, use even thicker stranded wires about 3mm2, thicken the PCB traces on the power path with a layer of solder over the traces, or reinforce those PCB paths with copper wires soldered along the PCB traces. Keep high current paths as short as possible, both in wires and in PCB, and avoid ground loops at all cost.Additionally, more 0.1uF in parallel (or similar values) might help, for example MLCC type or similar, and electrolytics with low ESR.Later edit:If you still want to make it even smoother, e.g. for a commercial product, you can put a coil in series with the heating element, and turn it into aBuck converterinstead of using PWM. That will have the advantage of smoothing the current through the heating element, which will now see (ideally) an adjustable DC current instead of pulsing PWM, thus lower parasitic EMI, and shorter paths for the switched high current (because the return diode, the coil of the Buck converter and the filtering capacitors for the returning paths of the switched currents can be placed right near the MOSFET, also, the pulses of current in a Buck converter will be much lower in amplitude than in a PWM).

author: mike_mike
author_rank: Super Contributor
timestamp: April 15, 2020, 05:23:37 pm
content: I made a small PCB for the filter, which contains the toroid ferrite coil, the capacitor (I used for the final project an 4700uF/35V) and a 100nF ceramic capacitor.I noticed that at the output of the filter (on the pcb connector) the spikes disappeared, but if I check on the input of the soldering station, then the spikes are back, with an peak to peak amplitude (Vpp) of about 1.6V. The distance between the small PCB and the input of the soldering station is about 5 cm and I used 1.5mm2wires, and for connecting the wires to the PCB's I used screw terminal blocks. I also soldered 1.5mm2wires on the tracks that conduct the current to the power mosfet on the PCB.I connected at the output of the LC filter the entire soldering station, including the mosfet and the soldering iron.I tired with different wires between the LC filter and the soldering station, and the results were the same.What I am doing wrong ?Output of the LC filter: 0526Input of the soldering station: 0539

author: RoGeorge
author_rank: Super Contributor
timestamp: April 15, 2020, 06:33:42 pm
content: DS 0523 has 0.8 Vpp spikes, while the current DS 0539 has 1.5V spikes. Something has changed, only you know what.Are you sure you don't have any ground loops? For example if you "chain" the wiring like that:- GND from power supply -> GND pin of the 7812 -> GND pin of the MOSFET, that would be a bad wiring.A better wiring will be a "star" topology, with a single GND point, and from there separate wires:- GND from power supply -> Unique GND on the solder station- Unique GND -> GND pin of the MOSFET- Unique GND -> GND pin of the 7812- Unique GND -> 24V filtering electrolytic GND, and so onCorrect wiring, correct decoupling, correct PCB design and minimal EMI interference with fast switching many amps is not trivial. What you see can as well be just a ringing in the wires, or some nasty reflection/resonance in a transmission line. Maybe a photo with the physical wiring might help to see if there is something obviously wrong.After all, why do you want to get rid of those spikes? Is the soldering station not working, or too noisy?

author: mike_mike
author_rank: Super Contributor
timestamp: April 15, 2020, 06:57:23 pm
content: Quote from: RoGeorge on April 15, 2020, 06:33:42 pmThe soldering station is working as expected. I don't see any problems for now.Should I leave the soldering station as it is, if it is working ?Are those spikes harmful ?

author: mike_mike
author_rank: Super Contributor
timestamp: April 16, 2020, 09:38:56 am
content: Please find attached my layout.

author: RoGeorge
author_rank: Super Contributor
timestamp: April 16, 2020, 11:01:57 am
content: Quote from: mike_mike on April 15, 2020, 06:57:23 pmEverything can be dangerous, life itself is dangerous, and safety is just an illusion.As a general rule, never let a solder station unattended, no matter it is built or bought. When you leave the room, turn off the soldering station.I don't think those spikes will do any damage. Maybe you are worrying too much, and even if the solder statiom will ever get broken (but it won't), you'll fix it!You did well, just use it and enjoy your work.

author: mike_mike
author_rank: Super Contributor
timestamp: April 27, 2020, 05:53:26 pm
content: Hello, I have the attached Arduino code and the attached schematic. The problem that I face is that when I rotate the pot nothing happens (the attached sine wave measured on the heating element does not modify). I checked the pot in serial monitor and it is working, giving values between 150 and 400. Also, the heating of the soldering iron does not stop, but the thermocouple amplifier is working (also checked in serial monitor).Can you please have a look at the code and schematic and tell me what you think ?This is the code:Code:#include <PID_v1.h>int firing_triac = 1; // OUTPUT TO CONTROL TRIACint zero_in = 2; // INPUT FROM ZERO DETECTIONint pot = A1; // POTENTIOMETER INPUTint adc0 = A0; // TERMOCOUPLE INPUTint value=0;int temperature = 0;//Define Variables we'll be connecting todouble Setpoint, Input, Output;double lastupdate;double consKp = 1, consKi = 0.05, consKd = 0.25;//Specify the links and initial tuning parametersPID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);void setup(){myPID.SetOutputLimits(0, 220);myPID.SetMode(AUTOMATIC);lastupdate = millis();Setpoint = 0;pinMode(firing_triac, OUTPUT); // Set the AC Load as outputpinMode(zero_in, INPUT);digitalWrite(zero_in, HIGH); // pull upattachInterrupt(0, zero_crosss_int, RISING);}void zero_crosss_int() // function to be fired at the zero crossing to dim the light{double newSetpoint = analogRead(A1);newSetpoint = map(newSetpoint, 0, 1023, 150, 400);value = map(newSetpoint,150,400,7200,10);int dimtime = (value);delayMicroseconds(dimtime); // Off cycledigitalWrite(firing_triac, HIGH); // triac firingdelayMicroseconds(10); // triac On propogation delaydigitalWrite(firing_triac, LOW); // triac Off}void loop(){Input = 0;for(int i=0;i<50;i++)Input += analogRead(A0);Input /= 50;Input = map(Input, 0, 550, 25, 400);temperature = Input;double newSetpoint = analogRead(A1);newSetpoint = map(newSetpoint, 0, 1023, 150, 400);//Display setpointif (abs(newSetpoint - Setpoint) > 3) {Setpoint = newSetpoint;temperature = newSetpoint;lastupdate = millis();}myPID.SetTunings(consKp, consKi, consKd);noInterrupts();myPID.Compute();interrupts();//delay(1000);}

author: floobydust
author_rank: Super Contributor
timestamp: April 28, 2020, 12:44:26 am
content: It's important to understand the difference between an integer and a floating point variable. You're still mixing variable types. The A/D analogread() routine does not return a float!Like I said before, "Why is variable 'Input' a float, going into analogRead(), which returns an int? "Returns int (0 to 1023)". Same for double 'newSetpoint'."Same for the map() routine"the map() function uses integer math."but you are expecting floats.