Voltage sensing/adjusting with MOSFET and Arduino  - Page 1
Forum section: electronics / general

author: 3dgeo
author_rank: Frequent Contributor
timestamp: March 13, 2018, 02:17:09 pm
content: Hi,I have transformer which provides up to 50V, I want to step it down to ~28V with N channel mosfet and arduino based board.Will it work if I make in parallel of my main load (2 DC motors) a voltage divider and feed low voltage to arduino and adjust mosfet accordingly?If not what is a good practice to make this work?Thank You.

author: Inverted18650
author_rank: Frequent Contributor
timestamp: March 13, 2018, 02:27:21 pm
content: Can you add the schematic, mosfet and motor details?

author: 3dgeo
author_rank: Frequent Contributor
timestamp: March 13, 2018, 03:23:03 pm
content: Quote from: Inverted18650 on March 13, 2018, 02:27:21 pmWill be using appropriate components, no worries here, all I need is to know if thisconceptwill work and if it's good idea to do this:I don't like that I need to connect microcontroller and mosfet grounds together, but I can live with that...

author: David Chamberlain
author_rank: Frequent Contributor
timestamp: March 14, 2018, 09:52:18 am
content: Given we know nothing about the arduino board, the mosfet, the resistors, the motor, the power supply.. the concept looks fine.A little more technical detail would go a long way.

author: 3dgeo
author_rank: Frequent Contributor
timestamp: March 14, 2018, 10:43:59 am
content: Thank You for Your reply, Mr David,I'm remaking old sit/stand desk circuit and reusing most of the main power supply components (I can't find data sheets for motors and mosfets (ON5247), but they were used before and worked fine). Resistors 180K and 20K to reduce voltage 10 times for microcontroller (I'm good at coding).Problem I found so far is that I will be checking "RAW" voltages, not "PWM'ed", I would like to check final voltages and adjust it accordingly, but that's not easily achievable, isn't it?If I connect voltage divider ground to motor ground then when mosfet is off controller will get full raw voltage... Any ideas?

author: Abbas
author_rank: Contributor
timestamp: March 20, 2018, 08:56:10 am
content: From what I understand, well you could throw in another MOSFET(2nd one) between the motor and the main MOSFET, so when the motor is switched on, then you would check the voltage that is being feeded back to the controller via the second switch mosfet.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 20, 2018, 02:17:13 pm
content: The diagram lacks the freewheeling (synchronous) diode to the motor. It's extremely important.Otherwise, given usual things such as layout and proper power bypass capacitors, no problem in concept.So it seems you are just measuring the DC link voltage. Either a buffer opamp, or a 100n ceramic cap right next to the MCU input pin is needed to provide the ADC low AC impedance it needs.Edit: since the picture doesn't match the first post description at all, it's hard to say. I based my answer on the picture, but where's the second motor, transformer, etc?

author: 3dgeo
author_rank: Frequent Contributor
timestamp: March 20, 2018, 07:45:15 pm
content: Thank You for Your replies.After 2 dead mosfets I realised that I do not have flyback diodes (hope it's correct name), I added them and for few seconds I was able to control voltage via PWM, but then mosfet died again, I don't know why it did this time, I will add additional diode next to mosfet. Is there a specific frequency?I'm out of mosfets for now (IRFZ44N and STP80NF70 incoming).Motors specs are: 24V/2,5A/1000N/2Ohm, same transformer (~50V) for both motors.Motors work with 50V, but I doubt they will for a long time...In old board voltage regulation was atchieved (I think) by this part of the circuit (image below).Can someone explain how it works and what are those unknown components? BJTs?I think I should just replicate it to save headache."RAWIN" is rectified tranformer output (no smoothing cap)

author: 0xfede
author_rank: Regular Contributor
timestamp: March 22, 2018, 07:09:06 pm
content: Hi 3dgeo,the SOT23 markings seems 3B. These are likely to be the good old BC856B (PNP transistor). Unfortunately I cannot read the marking on the leftmost, maybe you can provide another picture.Do not use IRFZ44N for switching an high inductive load such a motor powered with 50V. These MOSFET are 55V and even with a diode paralleled with the motor they will die fast.Best,0xfede

author: Inverted18650
author_rank: Frequent Contributor
timestamp: March 23, 2018, 07:07:33 pm
content: http://www.marsport.org.uk/smd/mainframe.htm

author: 3dgeo
author_rank: Frequent Contributor
timestamp: March 24, 2018, 08:15:14 pm
content: Quote from: 0xfede on March 22, 2018, 07:09:06 pmThan You for Your reply, 0xfede,sorry for being dummy– I should attach marking on them too, I don't know why I did not do that, here it is:I had a feeling that IRFZ44N would be "too weak" so I ordered IRF3710PbF, they look great on paper, I hope 100V will be enough. I would like to drive IRF3710PbF with simple PC817 optocoupler. I already tested PC817 with 31kHz, it seems to work just fine. The main question now is what PWM frequency is ideal for STP80NF70 particularly in this circuit?IRF3710PbF datasheet:https://www.infineon.com/dgdl/irf3710pbf.pdf?fileId=5546d462533600a4015355df95df1947Finally made more detailed blueprint (MOSFET should be IRF3710PbF, 100V/57A/23m?):Diode next to capacitor is B350B (Surface Mount Schottky Rectifier)https://www.vishay.com/docs/89122/b360b.pdfWhile I was making it I realized few potential issues:If I connect optocoupler voltage divider as is (cyan to ground "after" mosfet) voltage should be stable despite mosfet duty cycle but will there be a ripple due to rectification and lack of capacitor directly between + and - after rectifier (gray)?If I connect cyan "before" mosfet voltage will change according to mosfets duty cycle, thats not good as well, any suggestions?

author: Beamin
author_rank: Super Contributor
timestamp: March 24, 2018, 11:10:00 pm
content: Quote from: Siwastaja on March 20, 2018, 02:17:13 pm2nd the diode across inductive loads. That spike can kill the arduno or even fets...

author: 0xfede
author_rank: Regular Contributor
timestamp: March 25, 2018, 02:32:16 pm
content: Hi 3dgeo,let's try to make some order.Quote from: 3dgeo on March 24, 2018, 08:15:14 pmIf the marking is 1BW you are dealing with another common transitor, this time a NPN BC846B. 18W doesn't ring any bell to me.Quote from: 3dgeo on March 24, 2018, 08:15:14 pmIt is not easy to estimate the ideal frequency without knowing important data from the motors. But I can roughly say that the lower frequency you will choose, the lesser problem you willl have. Tipically you would set it higher than 16KHZ (to avoid motor to make any audible high pitched noise) and lower than 30KHZ (to maintain low both the switching losses and the radiated emissions).Is a 100V MOSFET enough? Typically a brushed DC motors without a proper snubber can even exceed twice as the input voltage in some circustances. The clamping diode will help but not solve all the situations the system will encounter (like heavy variations in the mechanical load). So as per design guidelines choose a MOSFET that has at least the double of the voltage you want to switch (and IRF3710PbF is fine) and then ensure that you design a proper snubber.Quote from: 3dgeo on March 24, 2018, 08:15:14 pmThe schematic attached does not drive the MOSFET gate properly since the gate is never pulled low level.The B350 is a 50V schottky diode and like the MOSFET it will not have a long and happy life.The 2200u 50V paralleled with clamping diode may cause a series of unwanted effects and I recommend to start without it.The lack of smoothing cap may cause a series of unwanted effects and I recommend to start with it.Best,0xfede

author: 3dgeo
author_rank: Frequent Contributor
timestamp: March 25, 2018, 05:04:53 pm
content: Hello again, Mr 0xfede,thank You for Your help, I really appreciate it.Yes, actually it's 1BW, sorry for misleading – it's very hard to see it.Already ordered thru-hole variance of these transistors (BC556 and BC546), will try to replicate that circuit and see what will happen, all I need to find out now is those caps capacities, is there an easy way to do that without special equipment?To be honest most problems I encounter I can't solve is because I don't have proper equipment, lack of knowledge doesn't help as wellWhat other information about motors I should provide? They're rated at 24V, 2,5A (guessing on "free run"), 2Ohms, 1000N.According to rated voltage and measured resistance they should be able to handle up to 12A (288W)Did I mentioned this is for sit stand desk? Motors will be running very rarely, at most few times a day for like 30s max.I would like to continue logic part of the circuit till I get new mosfets and I was wondering if shortly (5-10s while testing code) running these motors at 50V with practically no load will damage them? I don't know if my assumptions is correct but I think motor should take ~6A while running on 50V with no load, it's still less than 12A I calculated so I should be ok, am I right?What comes to running mosfet, yes, I forget pulldown resistor, thats not a biggie...I can't understand why optocoupler shouldn't be safe in this situation – voltage divider should protect it by reducing voltage to 10 V. At this point I'm ok with the idea that I have to kill few components to figure this outWhat comes to CAP - ok, I will move it in to "gray" position.Well, I ordered this cheep DSO138 oscilloscope, with it I hope to monitor what happens in circuit.

author: Seekonk
author_rank: Super Contributor
timestamp: March 25, 2018, 06:55:28 pm
content: If it hasn't been mentioned you need a resistor from gate to source. More likely, the opto feeds the voltage divider to the fet.

author: 0xfede
author_rank: Regular Contributor
timestamp: March 25, 2018, 07:54:39 pm
content: Quote from: Seekonk on March 25, 2018, 06:55:28 pmThe PC817 transistor, depending on production variant and production year may withstand only 35V so it is not recommended to place the divider after the optocoupler.Quote from: 3dgeo on March 25, 2018, 05:04:53 pmLuckily you don't need any special equipment to calulate the main smoothing cap but you are just required to do some simple math: Vripple = Iload / (2 F C)Where Vripple is the maximum voltage swing you want tolerate, Iload is the nominal current flow thru the load, F the line frequency and C the capacitor in Farad (note that the above formula is for full wave rectification). Now let's say that your load draw 5A, that you have 50HZ mains frequency, that your smoothing cap is 10000uf: the resulting ripple is around 5 volts. For the voltage bear in mind that a capacitor should work at a lower voltage for reliability and, since you have 50V you should use at least a 63V rated cap.By the way, a nice calculator, that makes even neat graphs is here:https://www.changpuak.ch/electronics/power_supply_design.phpQuote from: 3dgeo on March 25, 2018, 05:04:53 pmI was starting being curious....Quote from: 3dgeo on March 25, 2018, 05:04:53 pmYou should not exceed device ratings at any time, for whatever reason.Quote from: 3dgeo on March 25, 2018, 05:04:53 pmWell, the circuit can work with an optocupler, but is just not needed. As a rule of thumb in electronics you shouldn't add unneeded component. Any extra device in the circuit will add a pletora of new potential problems that will come back to bite.Best,0xfede

author: Seekonk
author_rank: Super Contributor
timestamp: March 27, 2018, 09:20:31 pm
content: Quote from: 0xfede on March 25, 2018, 07:54:39 pmSure it is 35V. I buy PC817 500 at a time. Who knows what this was or what you are designing. I just know this circuit is wrong as shown and the FET will turn on and probably never turn off as you have shown it. The gate has to have a resistor to the source. Just trying to give you a heads up on your mistake which you appear to be oblivious to.

author: 0xfede
author_rank: Regular Contributor
timestamp: March 28, 2018, 03:17:30 pm
content: Quote from: Seekonk on March 27, 2018, 09:20:31 pmI'm not designing anything. It is not my project and I'm not the OP.Quote from: Seekonk on March 27, 2018, 09:20:31 pmI've already pointed out that to the OP before your message.Quote from: Seekonk on March 27, 2018, 09:20:31 pmThere is no gate in a bipolar transistor so you mean base. Even with a resistor on the base when cut off it will see the full differential voltage on Vce (in the OP project 50V) and it will have an hard day.Best,0xfede