Hello !
I need some help for circuit.
I designed circuit such below, but that is not general.
I'm curious about role of R4 resistor in this circuit.

---------------------------------------------------------------------------
The operation of circuit :
** R1 is pull-down resistor
case 1
@ PWM = high -> N ch mosfet : on
@ Input signal = High -> NPN Transistor ON -> P ch mosfet : on
=> OUTPUT = Ground (by N ch mosfet)
case 2
@ PWM = Low -> N ch mosfet : off
@ Input signal = High -> NPN Transistor ON -> P ch mosfet : on
=> OUTPUT = Vdc * {R3/(R2+R3)}
case 3
@ PWM = high -> N ch mosfet : on
@ Input signal = Low -> NPN Transistor off -> P ch mosfet : off
=> OUTPUT = Ground (by N ch mosfet)
case 4
@ PWM = Low -> N ch mosfet : off
@ Input signal = Low -> NPN Transistor off -> P ch mosfet : off
=> OUTPUT = Vdc
---------------------------------------------------------------------------
When I simulate the circuit in the image, it works as intended.

However, if i remove the R4 resistor, case3/4 behaves strangely.

And let me know if there's anything else I should consider in this circuit.
I need some help for circuit.
I designed circuit such below, but that is not general.
I'm curious about role of R4 resistor in this circuit.

---------------------------------------------------------------------------
The operation of circuit :
** R1 is pull-down resistor
case 1
@ PWM = high -> N ch mosfet : on
@ Input signal = High -> NPN Transistor ON -> P ch mosfet : on
=> OUTPUT = Ground (by N ch mosfet)
case 2
@ PWM = Low -> N ch mosfet : off
@ Input signal = High -> NPN Transistor ON -> P ch mosfet : on
=> OUTPUT = Vdc * {R3/(R2+R3)}
case 3
@ PWM = high -> N ch mosfet : on
@ Input signal = Low -> NPN Transistor off -> P ch mosfet : off
=> OUTPUT = Ground (by N ch mosfet)
case 4
@ PWM = Low -> N ch mosfet : off
@ Input signal = Low -> NPN Transistor off -> P ch mosfet : off
=> OUTPUT = Vdc
---------------------------------------------------------------------------
When I simulate the circuit in the image, it works as intended.

However, if i remove the R4 resistor, case3/4 behaves strangely.

And let me know if there's anything else I should consider in this circuit.