Adjustable Frequency and Duty PWM to tune transformer

My project uses a Duemilanove connected to an opto isolator and a FET.

What i would like to do is connect the output to various transformers and loads then tweak in the frequency and duty cycle to give me optimum performance. Some of the transformers i will be using a ferrite with various spacer’s and the cap and load on the output can change the resonant frequencey quite a bit so i would like to be able to compensate for this.

Has anyone got any suggestions as to how It would be best to do this? I had thought about using Tone but this would not allow me to adjust the duty cycle.


Maybe you could use the tone lib as a starting point …?

A similar question has been discussed here:

I put some code into that thread.

See also the my frequency generator (exhibition). Of course the display is not needed for your application:


Thanks for the quick response guys.
I will give it a try and see how things go.

Actually with some form of feedback in to one of the analogue inputs this could also make a pretty cool little grid dip meter.