Hello, I am wondering what would be the best route for creating a high frequency signal to switch mosfets/transistors....I want to use the high frequency signal to pulse a coil at various frequencies, possibly making a resonant frequency graphing program. However this would be heavily reliant on the maximum frequency that can be achieved by the pwm or any of its other ports.
Thanks for any help
PWM Max Frequency?
8 posts
- Posts: 4
- Joined: Thu Feb 14, 2013 5:32 am
warrensk wrote:Hello, I am wondering what would be the best route for creating a high frequency signal to switch mosfets/transistors....I want to use the high frequency signal to pulse a coil at various frequencies, possibly making a resonant frequency graphing program. However this would be heavily reliant on the maximum frequency that can be achieved by the pwm or any of its other ports.
Thanks for any help
How high?
You might want to look at using a GPIO clock output - I put some support into the latest wiringPi for this, so you can feed a signal from 4600Hz to 19.2MHz using it. I'm wondering if that's too high for you though....
For PWM, the Pi's PWM output is by default not a typical mark:space waveform, but a balanced waveform, so it may not be what you're after - certianly the "frequency" becomes somewhat interesting to calculate, however you can put it into mark:space ratio mode then its more predictable, but it's still driven off the same 19.2MHz clock as above.
In the KHz and lower range, then you can generate reasonably accurate frequencies in software - look at the softTone module in wiringPi - it can generate a frequency from 0 to 5KHz - there is some jitter, but it's "good enough for jazz" ...
You can get more accurate in you dive into kernel land but the programming complexity goes up... But if you want to go there, then look for he servoblaster module - that would work as a good basis.
-Gordon
Thanks gordon,
I want to go up to 15Mhz tops. Im after harmonics and the higher the frequency the better. If it can go up to 19.2 Mhz that will be plenty....I just know the arduino can only go to 500 hz or so...This was my decision of which one I should get depending on top frequency... Raspberry PI wins
Thanks again,
Warrensk
I want to go up to 15Mhz tops. Im after harmonics and the higher the frequency the better. If it can go up to 19.2 Mhz that will be plenty....I just know the arduino can only go to 500 hz or so...This was my decision of which one I should get depending on top frequency... Raspberry PI wins
Thanks again,
Warrensk
- Posts: 4
- Joined: Thu Feb 14, 2013 5:32 am
warrensk wrote:Thanks gordon,
I want to go up to 15Mhz tops. Im after harmonics and the higher the frequency the better. If it can go up to 19.2 Mhz that will be plenty....I just know the arduino can only go to 500 hz or so...This was my decision of which one I should get depending on top frequency... Raspberry PI wins
Thanks again,
Warrensk
Not sure why you think the Arduino can only go to 500Hz - it can generate outputs much faster than that...
However Pi will be OK here - I only checked that my division sums were right to about 2.4MHz as that's the best my scope can go to though, but I think it'll be fine.

that's 2.4MHz but do let me know if you can generate a 15MHz signal accurately - the clock has a 12-bit integer divider and a 12-bit fractional divider from the 19.2MHz clock to the output pin.
-Gordon
@ gordon you are the man!
I tried searching for the same answer with the arduino and heard it may use most of its CPU while it does this, Also only a couple outputs are capable of faster frequencies... Im not sure how high it can go but its sounding like the R-Pi will be my best bet. Keep me updated if you have any more input. Ive got a little vortex coil Id love to pulse with this running my circuit and show some beautiful purple radiant energy. With the high frequencies and programming capable with up to 7-8 different outputs....talk about wave mixing!
Also, you said from 4600hz to 19.2mhz.....is the bottom frequency 4600 or can it go lower into the 10-100 hz range? I am looking for a full spectrum from 10 hz all the way up to 13-15Mhz. Ive got a spectrum analyzer that will be able to show how well it does in these high frequencies while it pulses a coil...finding the spacial resonant frequency will be a walk in the park with something of this capability.
-Warrensk
I tried searching for the same answer with the arduino and heard it may use most of its CPU while it does this, Also only a couple outputs are capable of faster frequencies... Im not sure how high it can go but its sounding like the R-Pi will be my best bet. Keep me updated if you have any more input. Ive got a little vortex coil Id love to pulse with this running my circuit and show some beautiful purple radiant energy. With the high frequencies and programming capable with up to 7-8 different outputs....talk about wave mixing!
Also, you said from 4600hz to 19.2mhz.....is the bottom frequency 4600 or can it go lower into the 10-100 hz range? I am looking for a full spectrum from 10 hz all the way up to 13-15Mhz. Ive got a spectrum analyzer that will be able to show how well it does in these high frequencies while it pulses a coil...finding the spacial resonant frequency will be a walk in the park with something of this capability.
-Warrensk
- Posts: 4
- Joined: Thu Feb 14, 2013 5:32 am
warrensk wrote:@ gordon you are the man!
I tried searching for the same answer with the arduino and heard it may use most of its CPU while it does this, Also only a couple outputs are capable of faster frequencies... Im not sure how high it can go but its sounding like the R-Pi will be my best bet. Keep me updated if you have any more input. Ive got a little vortex coil Id love to pulse with this running my circuit and show some beautiful purple radiant energy. With the high frequencies and programming capable with up to 7-8 different outputs....talk about wave mixing!
Also, you said from 4600hz to 19.2mhz.....is the bottom frequency 4600 or can it go lower into the 10-100 hz range? I am looking for a full spectrum from 10 hz all the way up to 13-15Mhz. Ive got a spectrum analyzer that will be able to show how well it does in these high frequencies while it pulses a coil...finding the spacial resonant frequency will be a walk in the park with something of this capability.
-Warrensk
The bottom frequency is 19.2 / 4095 = ~4688.
You could use my softTone library to go from 0 to 5000, then the hardware above that - that may be adequate for your testing... But there is only one hardware clock generator avalable on the Pi. (Although the softTone library can control all the GPIO pins at once, if needed)
-Gordon
@ gordon,
So to clarify, A written code could provide a program that could go all the way from 1hz-15mhz? or will it get pretty messy with separate programs?
Warrensk
So to clarify, A written code could provide a program that could go all the way from 1hz-15mhz? or will it get pretty messy with separate programs?
Warrensk
- Posts: 4
- Joined: Thu Feb 14, 2013 5:32 am
warrensk wrote:@ gordon,
So to clarify, A written code could provide a program that could go all the way from 1hz-15mhz? or will it get pretty messy with separate programs?
Warrensk
One program could do it, but it would need to use 2 technologys.
Actually if you use sofTone then you'll have to stop the program and re-start it - there is currently no proper way to turn it off (until you stop the program)- although you could set it to zero, then re-purpose the output pin to gpio clock mode.
-Gordon