variable voltage using mosfet and PWM

dear world,

due to some issues i cant interface my VSD(variable speed drive) with PC. So now i cant control the speed. I tested Anolog input to control the speed, using potentiometer and 24 volts. this was succesfull

Now i want to control the VSD with a mosfet and PWM arduino. i've made a schematics for this, see attachments.

But i have no clue how to start the coding.
has anyone made something similar or any help at all would be helpfull

thank you...

Does the VSD require an analog signal (continuously variable) or a PWM (digital pulse train)? If it requires an analog signal (like the output from a pot) then you need to filter the PWM to get an analog signal.

use analogWrite on a pwm pin. on AVR (Uno, Mega, Nano) the values are from 0 to 255.

groundFungus:
Does the VSD require an analog signal (continuously variable) or a PWM (digital pulse train)?

it requires an analog signal, like that of a trimpot