I am working on a project of a converter for Photovoltaic modules and
I am using an Arduino Uno board to generate a PWM to controll a IGBT.
I need at least 10khz frequency pwm and using analogWrite i get 490 hz.
Can you help me configuring the timers to have a 10khz frequency???

here is the code:
/*
* Two Stage Single Phase Inverter control
*
* JN. Barbosa - MERCEUS - DEE - FCT-UNL
*/
int Vpv0 = 0; // inicials conditions
int Ipv0 = 0;
int P0 = 0;
int Vpv1 = 0;
int Ipv1 = 0;
int P1 = 0;
int D = 0.500; // duty-cycle
int dD = 0.001; // perturbation
void setup()
{
pinMode(3, OUTPUT); // sets the pin as output
}
void loop()
{
Vpv0 = analogRead(A1); // read the pv voltage
Ipv0 = analogRead(A2); // read the pv current
P0 = Vpv0*Ipv0; // calculate instant power
delay(1);
Vpv1 = analogRead(A1);
Ipv1 = analogRead(A2);
P1 = Vpv1*Ipv1;
int dV = Vpv1-Vpv0;
int dP = P1-P0;
if (dP > 0){
if (dV > 0){
D = D+dD;
}else{
D = D-dD;
}
}else {
if (dV > 0){
D = D-dD;
}else{
D = D+dD;
}
}
analogWrite(pwmPin,D*255);
}
Thank you a lot!!!