A FREE frequency generator if you have a Raspberry Pi

J

Jan Panteltje

Guest
The Raspberry Pi as a frequency generator

Version 0.2 is on my site:
http://panteltje.com/pub/freq_pi-0.2.c

130 kHz to 250 MHz output

Functionality is basically the same, but added some info on phase noise.
When using a fractional divider and when the fractional part is not zero,
then the frequency will wobble around the requested one.
freq_pi -v -f 1000001 will show the fractional part,
so you are warned.
For simple testing this is probably not important,
but gets very important if you drive some modulator or something.

Next project :)

No it is not a V3.
Did the Aliens take my precision screwdriver ???
More in the NEXT issue of ....

!
 
On Thursday, July 25, 2013 3:18:15 AM UTC-7, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



Version 0.2 is on my site:

http://panteltje.com/pub/freq_pi-0.2.c



130 kHz to 250 MHz output



Functionality is basically the same, but added some info on phase noise.

When using a fractional divider and when the fractional part is not zero,

then the frequency will wobble around the requested one.

freq_pi -v -f 1000001 will show the fractional part,

so you are warned.

For simple testing this is probably not important,

but gets very important if you drive some modulator or something.



Next project :)



No it is not a V3.

Did the Aliens take my precision screwdriver ???

More in the NEXT issue of ....



!

In freq_pi.c I see struct GPCTL defined in a way that doesn't look right. Why aren't all structure fields on unsigned int instead of char? I guess you know this works. I'll have to experiment some to prove what gcc does on RPi.
 
On a sunny day (Tue, 9 Sep 2014 11:11:56 -0700 (PDT)) it happened
mscottbarnes@gmail.com wrote in
<824e78f7-8d99-464b-9de4-7469ca605e2b@googlegroups.com>:

On Thursday, July 25, 2013 3:18:15 AM UTC-7, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



Version 0.2 is on my site:

http://panteltje.com/pub/freq_pi-0.2.c



130 kHz to 250 MHz output



Functionality is basically the same, but added some info on phase noise.

When using a fractional divider and when the fractional part is not zero,

then the frequency will wobble around the requested one.

freq_pi -v -f 1000001 will show the fractional part,

so you are warned.

For simple testing this is probably not important,

but gets very important if you drive some modulator or something.



Next project :)



No it is not a V3.

Did the Aliens take my precision screwdriver ???

More in the NEXT issue of ....



!

In freq_pi.c I see struct GPCTL defined in a way that doesn't look right. Why aren't all structure fields on unsigned int
instead of char? I guess you know this works. I'll have to experiment some to prove what gcc does on RPi.

That structure definition is part of Pifm.c,
I did not write it.
But it works,
Look at the Broadcom chip I/O document, can't remember what is is called,
on my system
BCM2835-ARM-Peripherals.pdf
IIRC I checked that and it matches the registers.
If you find something peculiar let me know.
 
hello sir .
i need to generate a frequency of 14.318mhz with an RPI , is that possible with your code ?
 
On a sunny day (Fri, 12 Jun 2015 17:28:40 -0700 (PDT)) it happened
abir.bayoudh@gmail.com wrote in
<8a96c7a0-4588-44b1-8e89-b8b8f347b936@googlegroups.com>:

hello sir .
i need to generate a frequency of 14.318mhz with an RPI , is that possible with your code ?

milli Hertz, I think not.

MHz (Mega) yes, but there is a wobble around that frequency caused by the changing
division factor.
So it depends on what you want to do with it.
Also the output is a square wave, so without further filtering you get a lot of harmonics.

If you download the source code this is explained there.
It refers to
BCM2835-ARM-Peripherals.pdf
that you can find with google, and should read.
 
Please help me get this running

I compiled it as instructed and it brought up a few errors - little things in the source code.

I'm not efficient in the art of C and have tried to sort the little things - I am thinking it is dependancies on my Pi - maybe Im using a different something or other
 
On Monday, October 10, 2016 at 6:01:42 PM UTC-6, raserpps...@gmail.com wrote:
Please help me get this running

I compiled it as instructed and it brought up a few errors - little things in the source code.

I'm not efficient in the art of C and have tried to sort the little things - I am thinking it is dependancies on my Pi - maybe Im using a different something or other

You will need to provide more information. What errors are you getting?
 
On Thursday, 25 July 2013 13:18:15 UTC+3, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator

Version 0.2 is on my site:
http://panteltje.com/pub/freq_pi-0.2.c

130 kHz to 250 MHz output

Functionality is basically the same, but added some info on phase noise.
When using a fractional divider and when the fractional part is not zero,
then the frequency will wobble around the requested one.
freq_pi -v -f 1000001 will show the fractional part,
so you are warned.
For simple testing this is probably not important,
but gets very important if you drive some modulator or something.

Next project :)

No it is not a V3.
Did the Aliens take my precision screwdriver ???
More in the NEXT issue of ....

!

sir i have really impressed with the code..can we change the minimum frequency to 12khz to maximum frequency to 2mhz..let me know if it is possible...
 
!

sir i have really impressed with the code..can we change the minimum frequency to 12khz to maximum frequency to 2mhz..let me know if it is possible...

From the software... So in short, No unless you change the clock source
in the Pye...

clock sources are 650 MHz, 400 MHz, and 200 MHz

So the lowest frequency we can make is 200,000,000 / 4095.4095 =
48,835.165323516 Hz

But I get 61,043 Hz

4095.4095 * 61043 = 249,996,082.108499999 Hz....

But for MASH 1,
MASH min DIVI min output freq average output freq
max output freq
0 (int divide) 1 source / ( DIVI ) source / ( DIVI )
source / ( DIVI )
* 1 2 source / ( DIVI ) source / ( DIVI + DIVF /
1024 ) source / ( DIVI + 1 )
2 3 source / ( DIVI - 1 ) source / ( DIVI + DIVF /
1024 ) source / ( DIVI + 2 )
3 5 source / ( DIVI - 3 ) source / ( DIVI + DIVF /
1024 ) source / ( DIVI + 4 )

200,000,000 / (4095 = 48840.048840048
200,000,000 / (4095 + (4095/1024) ) = 48792.400011912

So
61043 * (4095 + .3999023437) = 249995496.238766479 Hz, looks liike we
have a 250 MHz clock.

Lowest frequency then is 61,043 Hz,
highest frequency then is 250,000,000 / 1 = 250,000,000 Hz

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
 
On a sunny day (Thu, 6 Jun 2019 03:36:02 -0700 (PDT)) it happened
murali.acelogysystems@gmail.com wrote in
<79c40d2b-468e-45ca-890a-7876a177bd35@googlegroups.com>:

On Thursday, 25 July 2013 13:18:15 UTC+3, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator

Version 0.2 is on my site:
http://panteltje.com/pub/freq_pi-0.2.c

130 kHz to 250 MHz output

Functionality is basically the same, but added some info on phase noise.
When using a fractional divider and when the fractional part is not zero,
then the frequency will wobble around the requested one.
freq_pi -v -f 1000001 will show the fractional part,
so you are warned.
For simple testing this is probably not important,
but gets very important if you drive some modulator or something.

Next project :)

No it is not a V3.
Did the Aliens take my precision screwdriver ???
More in the NEXT issue of ....

!

sir i have really impressed with the code..can we change the minimum frequency to 12khz to maximum frequency to 2mhz..let me
know if it is possible...

Simpe software loop, not hardware

set pin high
usleep X or nops for pulse width
set pin low
usleep Y or nops for delay between pulses.

Command line option for frequency and pulse width

delay Y is 1/f seconds - pulse-width X
or something along those lines.

You'd have to make sure the task switch never happens..

Simpler to use a PIC for those low frequencies.
Program it in asm. serial interface or up-down buttons whatever.

Even simpler 555 timer?

Even more simple UJT transistor? (not sure if those go op to 2 MHz,
2 mHz ? sure with a big enough capacitor.

Or use the 74HC4046, it easily does 1 Hz to 2 MHz and more.
 
On Thu, 06 Jun 2019 14:14:38 GMT, Jan Panteltje
<pNaOnStPeAlMtje@yahoo.com> wrote:

On a sunny day (Thu, 6 Jun 2019 03:36:02 -0700 (PDT)) it happened
murali.acelogysystems@gmail.com wrote in
79c40d2b-468e-45ca-890a-7876a177bd35@googlegroups.com>:

On Thursday, 25 July 2013 13:18:15 UTC+3, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator

Version 0.2 is on my site:
http://panteltje.com/pub/freq_pi-0.2.c

130 kHz to 250 MHz output

Functionality is basically the same, but added some info on phase noise.
When using a fractional divider and when the fractional part is not zero,
then the frequency will wobble around the requested one.
freq_pi -v -f 1000001 will show the fractional part,
so you are warned.
For simple testing this is probably not important,
but gets very important if you drive some modulator or something.

Next project :)

No it is not a V3.
Did the Aliens take my precision screwdriver ???
More in the NEXT issue of ....

!

sir i have really impressed with the code..can we change the minimum frequency to 12khz to maximum frequency to 2mhz..let me
know if it is possible...

Simpe software loop, not hardware

set pin high
usleep X or nops for pulse width
set pin low
usleep Y or nops for delay between pulses.

Command line option for frequency and pulse width

delay Y is 1/f seconds - pulse-width X
or something along those lines.

You'd have to make sure the task switch never happens..

Simpler to use a PIC for those low frequencies.
Program it in asm. serial interface or up-down buttons whatever.

Even simpler 555 timer?

Even more simple UJT transistor? (not sure if those go op to 2 MHz,
2 mHz ? sure with a big enough capacitor.

Or use the 74HC4046, it easily does 1 Hz to 2 MHz and more.

We've made nice sine waves, using software DDS and the DAC on a small
ARM chip. Frequency range is limited to basically audio, but we can
control amplitude and frequency nicely.

We just ran some code in a periodic interrupt, but some DMA thing
could be done too, I guess.

My benchtop B+K analog function generator is handy. It has knobs.


--

John Larkin Highland Technology, Inc

lunatic fringe electronics
 

Welcome to EDABoard.com

Sponsor

Back
Top