High frequency pulse generator using PWM

Hello guys, I need some help

I would like to test my sensors by generating definite amount of "high" frequency(up to 10kHz) pulses. I would like to use PWM, so I can modify duration of impulse, or the "analog" voltage.

I already have solution without using pwm libraries, but how to generate pulses using PWM?

input variables are: frequency, duty cycle and amount of pulses output is pulse on PWM pin

hardware: arduino uno

Thank you in advance!