B4R Question How to read voltage using an irfz44 "N" fet

Cesar_Morisco

Active Member
Licensed User
Longtime User
Hello everyone
I need technical help on how I can measure the voltage using the ESP8266 ADC and using a FET N. In this way, the ADC is reading 12V directly. I think there is another solution, but I'm stuck on this. If anyone has a tip on how to read the voltage correctly, I'll be happy.
 

Attachments

  • CONTROLE PWM.png
    CONTROLE PWM.png
    14.9 KB · Views: 45

peacemaker

Expert
Licensed User
Longtime User
FET is a controllable resistor by the voltage. When any of them is "on" (by high voltage from MCU) - the bottom lamp's end is connected to the GND via a FET's low resistance, and lamp is on.
So, R5 and R6 are connected between GND and +12V.

K = R6/(R5 + R6) = 10/43 = 0.23
So, MCU ADC can measure max voltage V = 0.23 * 12V ~ 2.8V.

But maybe here ADC is not needed, as 2.8V for 3.3V MCU is just the logical "1", high level that can be just "digitally read" in B4R.
When FET is closed (high resistance), lamp is off as both lamp's contacts are near 12V, so Vlamp ~0 V = low digital level (to be read by MCU).
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
All is explained, IMHO. I was explaining the circuit diagram you posted.
Strange that 2 FETs for one lamp... maybe the lamp is super powerful so 2 low-power FETs are used in parallel...

If unclear, i guess, better to prepare more detailed task description and find the commercial developer. Or try AI-chats to learn electronics and Arduino programming.
 
Upvote 0

Cesar_Morisco

Active Member
Licensed User
Longtime User
This way of the scheme I don't have a low reading, it only has 12v in the reading of the adcin of the esp8266. This is my doubt and I need some alternative ideas, ok?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
You even do not show the code.

Ahhh, it's PWM control of the lamp brightness, i see now. And it needs to measure some average voltage at the lamp.
If you always measure some high voltage, it looks like you switch the lamp on ... too often. I guess.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Note the chart of your incandescent lamp Brightness-voltage characteristic.

Nonlinear Behavior:

  • At low voltages, the lamp emits almost no light (filament is too cool).
  • At rated voltage, it produces the specified luminous flux.
  • Above rated voltage, brightness increases sharply, but the bulb burns out quickly.

1742995819272.png


I mean, the incandescent lamp brightness will be the more the higher voltage, so your ADC measurements are always in the one edge of this chart...
 
Last edited:
Upvote 0

Cesar_Morisco

Active Member
Licensed User
Longtime User
Thank you for your time
I have more questions about where to use the attention divider to read the output voltage.
 

Attachments

  • z2eWY.jpg
    z2eWY.jpg
    98.8 KB · Views: 15
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Hello everyone
I need technical help on how I can measure the voltage using the ESP8266 ADC and using a FET N. In this way, the ADC is reading 12V directly. I think there is another solution, but I'm stuck on this. If anyone has a tip on how to read the voltage correctly, I'll be happy.

Hi, what do you define as PWM+ and PWM- ? Do you define the duration of the PWM pulse by these two buttons?

When both Q1 and Q2 are off then there is no ground anywhere in the loop of the lamp. Thus, all pins of all the components are in 12V. This way there is no voltage divider and you feed the 12V to ADC which you may already have burnt and what you measure has no meaning.

Please also note that when they are conducting, your current from the 12V Vcc goes by (R5+R6 + (RQ1 | | RQ2) )/(R5+R6+R lamp + (RQ1 | | RQ2)) in the lamp path and by (R lamp + (RQ1 | | RQ2) )/(R5+R6+R lamp + (RQ1 | | RQ2) )in the R5,R6 path. The same pattern is followed when you calculate the voltage drops. So please note that with two mosfets you only get the parallel resistance close to the lower FET's resistance.
 
Last edited:
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Hi, what do you define as PWM+ and PWM- ? Do you define the duration of the PWM pulse by these two buttons?

When both Q1 and Q2 are off then there is no ground anywhere in the loop of the lamp. Thus, all pins of all the components are in 12V. This way there is no voltage divider and you feed the 12V to ADC which you may already have burnt and what you measure has no meaning.

Please also note that when they are conducting, your current from the 12V Vcc goes by (R1+R2 + (RQ1 | | RQ2) )/(R1+R2+R lamp + (RQ1 | | RQ2)) in the lamp path and by (R lamp + (RQ1 | | RQ2) )/(R1+R2+R lamp + (RQ1 | | RQ2) )in the R1,R2 path. The same pattern is followed when you calculate the voltage drops. So please note that with two mosfets you only get the parallel resistance close to the lower FET's resistance.

Ignore the calculation of the current divider, I will calculate it again. It might be wrong.

It might be like this: "Your current from the 12V Vcc goes by (R5+R6 + (RQ1 | | RQ2) )/(R5+R6+R lamp + 2*(RQ1 | | RQ2) ) in the lamp path and by (R lamp + (RQ1 | | RQ2) )/(R5+R6+R lamp + 2*(RQ1 | | RQ2) ) in the R5,R6 path".

In order to understand this write in gemini the following prompt:

"Show me a calculation of a current divider with 3 resistors (R1,R2, R3) in the first path and two resistors (R4, R5) on the second path."
 
Last edited:
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Use something like this (you will have to calculate the voltage dividers to count always something between 0 and 3,3V) (R4=Lamp) :

1743061299867.png
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
IMHO, initial sch was OK, if really 12V lamp and power supply, the resistor divider R5-R6 exists, i tried to describe it.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
IMHO, initial sch was OK, if really 12V lamp and power supply, the resistor divider R5-R6 exists, i tried to describe it.

If I am wrong, at this time I am not able to see it. In the beggining I though the same thing as you but then I noticed that this is valid when the FETs are contacting. If the FETs are not contacting then there is no low voltage side and thus no current and no voltage drop.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
If I am wrong, at this time I am not able to see it. In the beggining I though the same thing as you but then I noticed that this is valid when the FETs are contacting. If the FETs are not contacting then there is no low voltage side and thus no current and no voltage drop.

I was able to see a misunderstanding. The path that goes to ADC becomes the low voltage side and there is a (R6+R lamp) || R5 resistance between the 12V and this. Thus the current sees only a resistance around ~ R5 because I suspect that the lamp has a high resistance.
 
Upvote 0

Cesar_Morisco

Active Member
Licensed User
Longtime User
Hello, good morning.
I'm very happy for helping me with this.
A great calculation.
Regarding the drawing, the bulb will go in place of R4, right?
I'll test this later, very happy.
 

Attachments

  • 1743061299867.png
    1743061299867.png
    22 KB · Views: 14
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Hello, good morning.
I'm very happy for helping me with this.
A great calculation.
Regarding the drawing, the bulb will go in place of R4, right?
I'll test this later, very happy.

Yes, the lamp has a resistance with value R4.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Hello, good morning.
I'm very happy for helping me with this.
A great calculation.
Regarding the drawing, the bulb will go in place of R4, right?
I'll test this later, very happy.

Please also note that you will have to calculate both voltage dividers. That is R1 in relation to the voltage controlled Resistance of the FET and R5 in relation to the R4 which will divide aproprietely the already divided voltage as calculated from the first voltage divider, in order to brink it in the range between 0 and 3,3V. Then map the value you measure to the range you wish.
 
Upvote 0

Cesar_Morisco

Active Member
Licensed User
Longtime User
Olá a todos
Tive que fazer algumas alterações no meu projeto para usar o TIP122 como driver para que o IRF5305 FET funcionasse corretamente e calculasse o divisor de tensão de 0 a 20v
Agora tudo está funcionando muito bem
Obrigado pelo seu tempo
Vou postar o vídeo em breve

https://youtube.com/shorts/Pi5bUB1cw2I?si=zlaC5Jsr7H-P8zSd
 

Attachments

  • Pwm.png
    Pwm.png
    33.5 KB · Views: 13
Last edited:
Upvote 0
Top