Open Harvie opened 6 years ago
Thanks for the comment, one of my colleague also mentioned that idea, but frankly I'm not sure how exactly to accomplish that. If you can modify the schematic and draw where the shunt resistor, the voltage divider resistor and the lead to ADC pin should be then I'm happy to do some more experiments and modify the code.
I'll try to transform these ideas to some rough schematics...
My device have not arrived yet. Do you think you can use multimeter to measure resistance of the tip when it's completely cold at room temperature and immediately after firing it for 5 minutes at full power? I think i will need these two measurements to make some usable simulation.
However this is first sketch:
Three points indicating voltage are possibilities of what you can measure to get enough data for closed loop control. In fact i think, that under some circumstances it might be possible to limit it to just 2 or 1 measuring points, to simplify the circuit. This is just initial sketch.
How to calculate tip resistance/temperature from measured data: (note this will work only with heater transistor turned on!)
input voltage = 2.5V 2 = 5V voltage after heater = 1.98V 2 = 3.96V voltage across heater = 5V - 3.96V = 1.04V current through heater = 0.01216V / 0.1ohm = 0.1216A resistance of heater = 8.5526ohm temperature of heater = you need to make lookup table, linear approximation or polynomial function based on measurements using multimeter and thermometer, so you can determine temperature of tip based on it's resistance.
Possible simplification ideas:
Another idea with less components using only 2 ADCs. This will work only with heater transistor turned off. Major drawback is, that it will consume 10mA in standby mode! Also this will probably need at least 10-bit ADC mode, which should be present on attiny13a.
How to calculate resistance: input voltage = 2.5V * 2 = 5V voltage acros heater = 5V - 4.94V = 0.06V current through shunt = 4.94V / 500ohm = 0.0098 mA resistance of heater = 0.06V / 0.0098 mA = 6.1224 ohm
I am not sure if attiny13a features differential ADC, that might be useful to improve precision of shunt reading. However it has analogue comparator, which might be similary useful in some designs, but not really sure right now.
Thanks for the explanation and the drawings. It now looks clear. I think that the 2.5V reference voltage may not be necessary as ATTiny13a can be set to either measure against Vcc or against internal 1.1V reference. If I understand it well the reference voltage is required in order to get consistent measurement results during different voltage situations (battery type and charge). But if the internal 1.1 V reference is stable across fluctuating Vcc it might be used for the same purpose as the 2.5V ref point . Am I right?
I'll do the resistance measurements of the heating element over the weekend and let you know the result.
I tried to measure the resistance of the heating element, but unfortunately I can not give a decisive result of the measurement. My multimeter is probably not sensitive enough for such data - I have just a regular cheap multimeter from China. What I observe is the resistance jumps to number like 50 Ohm and then in a split of a second it drops to 3, sometimes drops to 10 Ohms. Sometimes the initial value is slightly higher (like 80 or 150 Ohm, but inconsistent). I always measure when the tip is fully heated (~2 minutes of heating) and then I turn off the heat (MOSFET off) and quickly do the resistance measurement on the PCB on the solder points of the 2 thick brown wires which connect the heating element. I tested my multimeter with regular resistor and it works fine, measurement is correct. So I don't know what is going on, I'll try to borrow a Fluke multimeter next week, hopefully this might give some reasonable results.
Well i don't really thinked this 2.5V thing thru. It's there just, because we can't really be sure that there's 5V on input of soldering iron and that would make the measurements completely useless, since we use input voltage in calculations.
It would make more sense to use 1.1V Aref and use 1:4 resistor divider instead of 1:1. that way you will be able to reliably measure the Vcc even in case it drops below 5V. Such divider would give 1V when Vcc will be 5V, so we will always get accurate reading against 1.1V reference. Even in case of 10% overvoltage, which is AFAIK allowed by USB standard.
If resistance is too small to measure, you can still apply 5V to the tip and measure the current that it takes. Then it's easy to calculate the resistance using ohms law:
resistance = 5V / current
however it might be tricky to calculate cold resistance this way, since this kind of measuring would heat the tip.
Well, in that case my USB meter shows currents between 0.8 A on low temperature profile and in between 1.2 to 1.3A on max. temperature. So the resistance of the heating element should be in theory between 6.25 (5V/0.8) to 3.8 (5V/1.3) Ohms.
Voltage divider made by 1 Ohm resistor gives 690 mV (against 6.25 Ohm on the heating element) to 1042 mV (against 3.8 Ohms on the heating element) on the measuring output, that's a difference of 352 mV
1.1V / 256 values -> 4.3 mV per measured value (8 bit ADC)
So the measured values should be between 160 (690mV) to 255 (1042 mV), which is about 95 values per ~120 deg. C which is ~ 1.26 deg C per single measured value on ADC. The ADC might not give linear results or the values might have an offset, but if I made no mistake in calculations this should work. Is that correct?
Ah... There is a catch. I could not find a 1Ohm resistor power rated at 10-20W that is small enough to fit into the soldering iron body. Also, such circuit would draw way too much current when turned off (MOSFET off) as the current would pass through the voltage divider 1Ohm resistor. There would have to be some additional mechanism that would add some resistance to the voltage divider branch if the heat is off, to ensure small current passes through, therefore low power rated (small size) 1Ohm resistor could be used....
Well, there is an idea: the MOSFET itself has a resistance, which is low but that's what we need. According to a paper from ST (google 'MOSFET gate resistance') the resistance should/might be around 1.8 Ohm, so something like this might work.
I'll investigate later whether the voltage changes at that specific point in the circuit...
Edit: actually, just before the ADC pin there should be a resistor to prevent high current flowing into the MCU I guess...
Well, in that case my USB meter shows currents between 0.8 A on low temperature profile
This will not give you any useful data, as the current is artificialy limited by attiny and transistor, i thought this is obvious, since it switches the power in middle of measurement. Also this way you can't really calculate with 5V, since you have to subtract the voltage drop on transistor.
It would make more sense to put the iron on full throttle and watch it heating up to draw graph of current x temperature. The current should drop as it heats up.
There is a catch. I could not find a 1Ohm resistor power rated at 10-20W that is small enough to fit into the soldering iron body.
Why 10-20W ??? The soldering iron itself has 8W. 8W / 5V = 1.6A 1 ohm 1.6A = 1.6V across resistor 1.6A 1.6V = 2.56W power dissipation in resistor But hey, there may be some current peaks during warm up.
That's the reason why i suggested maximum of 0.1ohm resistor in this version (shunt mounted in series to transistor), that would need to dissipate only 0.256W !
Also, such circuit would draw way too much current when turned off That's why i suggested at least 500ohm in this version (shunt mounted parallel to transistor).
There would have to be some additional mechanism that would add some resistance to the voltage divider branch if the heat is off, to ensure small current passes through
That does not seem to make sense to me. Mechanism that adds resistance if the heat is off is already there. That is exactly what the transistor does.
Well, there is an idea: the MOSFET itself has a resistance, which is low but that's what we need.
Bingo! That's what i was suggesting since the day one. That's exactly what i meant by "We can even manage to calibrate the thing using that power transistor as a inprecise current sensing shunt."
google 'MOSFET gate resistance')
WRONG. gate resistance "Rg" is resistance of gate obviously. Gate is the control pin of mosfet and current from heater does not go thru it. This has to do with how fast you can switch the mosfet on and off, if you do high frequency switching. If you are looking into resistance of high current path that switches power to heater, you should look up "drain source resistance in on state, commonly known as "Rds(on)".
I don't know which transistor is used, but i checked datasheet of random FET (IRLZ44N) and it has much lower Rds(on) of 0.022Ω, which would make the shunt voltage vary from 0V to 0.03V (at 1.6A), which is not much. But if you enable the 10-bit ADC mode and internal 1.1V reference, that would make 1.1V / (2^10bit) = 0.001V resolution, so it might actualy be enough. Default 5V reference with 8 bit mode will surely not be enough, since it only has 5V / (2^8bit) = 0.0195V resolution.
just before the ADC pin there should be a resistor to prevent high current flowing into the MCU I guess...
Also wrong. There can't be high current into ADC, since it's high impedance input (kiloohms to megaohms). No need to worry about this, unless you accidentaly switch the pin to output mode. That way it might get shorted or something. If the pin is set up as ADC, you only need to prevent high voltage (AFAIK over 5.5V) to get there, which is hardly going to happen, since whole circuit runs on 5V.
It would make more sense to put the iron on full throttle and watch it heating up to draw graph of current x temperature. The current should drop as it heats up.
I've done that, unfortunately I was not able to detect any current drop when the iron heats up. The current was stable all the time. This may be again due to my poor test equipment. Anyway, the USB meter measurements are as follows: when connect to power bank it draws 1.16A, when connected to wall phone charger it draws 1.26A, when connected to my notebook (USB3 port) it draws 1.1A. When I measured the current by my multimeter I only got 0.7A, which was consistent with the USB meter. When both were measuring at the same time the current was 0.6A displayed both on the USB meter and the multimeter.
1.6A * 1.6V = 2.56W power dissipation in resistor...
In that case I could find 1 Ohm (1%), 2W high power resistor with reasonable size (5mm x 2.5 mm). Considering the current doesn't exceed 1.3A, the power rating should be just about enough.
WRONG. gate resistance "Rg" is resistance of gate obviously.
Thanks for pointing that out. The MOSFET used in the soldering iron is MX35N06 and the Rds(on) is 0.023 Ohm, the same as you mentioned.
Also wrong. There can't be high current into ADC, since it's high impedance input (kiloohms to megaohms). No need to worry about this,
Thanks for the clarification. One less thing to worry about :)
OK, I'll order the 1 Ohm resistor, fit it in the circuit and do the experiments with ADC. Thank you for the ideas and the math. Will let you know my progress.
Another option is to use MOSFET with Rds(ON) of 0.5 - 1 Ohm (maybe this one? https://uk.rs-online.com/web/p/mosfet-transistors/0362793/). It would require to replace (and desolder) the old MOSFET, but it would save some space compared to the option with an extra resistor.
Will let you know my progress.
I guess it will take some time, before my iron arrives from china (month or so). but i hope i will be able to give some more details once i'll do some initial tests. it would be cool if we manage to design something useful. we might just design custom replacement boards (eg. with small LED segment display or bargraph). it gets pretty cheap if you order 100 pieces or more. however not sure if that's worth it. this iron still has some major flaws. (it's not perfectly isolated from mains ac voltage if you power it from laptop or powerbrick. it kinda lacks power,...)
Another option is to use MOSFET with Rds(ON) of 0.5 - 1 Ohm
Not sure if that's practical. It would probably heat too much 0.7-2.6W, that can be approximately 10-30% of total power of iron. Also it misses the point of not having to buy and solder additional components :-)
I guess it will take some time, before my iron arrives from china (month or so).
It looks the iron can be bought locally as well (possibly less time to wait), for example here: http://www.elfax.cz/94%7C631%7C.d.S01327.mikropajka---8w-5v-zd20u-usb-.html or here: https://www.obchodvpraze.cz/Pajka-ZD-20U-USB-d10484.htm
we might just design custom replacement boards (eg. with small LED segment display or bargraph).
I've already started some work in that respect ... :) Edit: more hands and especially heads are of course welcome, the more the merrier! This time it uses ATTiny85, it has more flash and more pins. I thought I could use a thermistor (edited) and place the sensor at the end of the iron, or maybe even inside the iron as the shaft seems to be hollow I haven't done any programming yet, was distracted by other projects.
Also it misses the point of not having to buy and solder additional components :-)
True, but the other option - power resistor - also needs an extra component...
OK. I was thinking about another solution, to me so far without big flaws. Check the image bellow.
The original MOSFET (1) would stay, but another one would be added (MOSFET 2) - the one with 0.8 Ohm Rds(On). Normally during heating the MOSFET2 would be turned Off, that means the current would flow through MOSFET1 without losing power. Only during measurement the MOSFET2 would be turned On and MOSFET1 would be turned OFF to switch the flow of the current through the higher resistance (on MOSFET2). That would be a slight power loss, but only for a short while when the measurement is taking place. During measurement the MOSFET2 forms a reasonable voltage divider (expectation is the heating element resistance is between 3 - 8 Ohms) which should be detected by the ADC pin (ref 1.1V). As the MOSFET2 and MOSFET1 are controlled independently the measurement mechanism is more flexible (no massive power losses when the heating element is On or Off). Ideas?
This sounds bit overengineered. It might work. But there are some considerations.
1.) It would completely make sense to turn both transistors ON if you want to turn on the heater. It would only lower the overall resistance, while most of the current will go through the path of least resistance. it's not uncommon to use MOSFETs in parallel to increase current capability.
2.) MOSFETs are not resistors, they are made of semiconductors. That means they also have non-ohmic (non-linear) properties. I am not really sure how this will apply in our case. I just googled some IV plot of MOSFET. We'll have to make some tests on this topic, or get opinion of someone more experienced.
According to my tests it is not really possible to measure the resistance of heating element directly, since the changes are quite subtle. However it might be possible to use wheatstone bridge topology. This is usualy used to measure slight changes of resistance in strain gauges and it even seems to be well documented for thermometer usecases like the one we have here: https://en.wikipedia.org/wiki/Resistance_thermometer
More reading: https://en.wikipedia.org/wiki/Wheatstone_bridge https://en.wikipedia.org/wiki/Strain_gauge
Since this device does not have lots of power it would perform poorly if you try to turn the temperature down using open loop control. eg.: it would not turn the power on when tip gets cold due to fact that you are trying to solder big thermal mass.
I guess the tip of this cheap iron CHANGES RESISTANCE WITH TEMPERATURE… What about powering it off for fraction of second and using attiny to measure that resistance, so we can have real feedback for CLOSED LOOP pid temperature control. Maybe we can just use shunt to measure current thru tip, while measuring voltage, so we can calculate the resistance and therefore temperature of the tip. We can even manage to calibrate the thing using that power transistor as a inprecise current sensing shunt. I think i saw some battery protection circuits doing just that.