A FREE frequency generator if you have a Raspberry Pi

J

Jan Panteltje

Guest
The Raspberry Pi as a frequency generator



I was experimenting with the Pifm code,
and wanted to know what sort of frequencies I could get from the GIPO_4 pin 7.

So I wrote some test code, the program is very simple, and only outputs a square wave.
No extra things needed...
BUT the frequency range is from 130 kHz to 250 MHz.
I have only tested to 250 MHz, I think this is the limit.
Some defines in the code for the PLL frequency are likely wrong.
Missing a factor 2, anyways the calculation of the fractional divider is really close.

A free signal generator from 130 kHz to 250 MHz when you have a Pi is nice thing to have.
http://panteltje.com/pub/freq_pi.c

Compile that code with:
gcc -Wall -O4 -o freq_pi freq_pi.c -std=gnu99 -lm

Install it with:
sudo cp freq_pi /usr/local/sbin/

Connect your frequency counter to GPIO header pin 7.

Run it like this for 130 kHz:
freq_pi -f 130000
error on my frequency counter 3 Hz.

Run it like this for 107.2 MHz:
freq_pi -f 107200000
dunno the error, but it wipes out my FM station at 107.2

Run it like this for 250 MHz:
freq_pi -f 25000000

Error is a few kHz on xpsa spectrum analyzer,
but that could as well be the 30 kHz LO offset from the Elonics 4000 tuner..

Nice to test LC circuits, filters, and the 3.3V amplitude is more than enough for most things,
will even drive 3.3V and 5 V logic.
 
On Wednesday, July 24, 2013 at 10:26:17 AM UTC-4, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



I was experimenting with the Pifm code,
and wanted to know what sort of frequencies I could get from the GIPO_4 pin 7.

So I wrote some test code, the program is very simple, and only outputs a square wave.
No extra things needed...
BUT the frequency range is from 130 kHz to 250 MHz.
I have only tested to 250 MHz, I think this is the limit.
Some defines in the code for the PLL frequency are likely wrong.
Missing a factor 2, anyways the calculation of the fractional divider is really close.

A free signal generator from 130 kHz to 250 MHz when you have a Pi is nice thing to have.
http://panteltje.com/pub/freq_pi.c

Compile that code with:
gcc -Wall -O4 -o freq_pi freq_pi.c -std=gnu99 -lm

Install it with:
sudo cp freq_pi /usr/local/sbin/

Connect your frequency counter to GPIO header pin 7.

Run it like this for 130 kHz:
freq_pi -f 130000
error on my frequency counter 3 Hz.

Run it like this for 107.2 MHz:
freq_pi -f 107200000
dunno the error, but it wipes out my FM station at 107.2

Run it like this for 250 MHz:
freq_pi -f 25000000

Error is a few kHz on xpsa spectrum analyzer,
but that could as well be the 30 kHz LO offset from the Elonics 4000 tuner..

Nice to test LC circuits, filters, and the 3.3V amplitude is more than enough for most things,
will even drive 3.3V and 5 V logic.

OMG, I totally want a ~200 MHz sig gen.
(Well really 1/2 of 385 MHz.
If I frequency mod our diode laser there,
the side bands, as imaged in our Fabry-Perot cavity,
will overlap. It would be a nice way to measure the length.)

Am I going to have to learn linux to run the
Raspberry Pi?

George H.
 
On Friday, June 12, 2015 at 10:12:15 PM UTC-4, George Herold wrote:
On Wednesday, July 24, 2013 at 10:26:17 AM UTC-4, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



I was experimenting with the Pifm code,
and wanted to know what sort of frequencies I could get from the GIPO_4 pin 7.

So I wrote some test code, the program is very simple, and only outputs a square wave.
No extra things needed...
BUT the frequency range is from 130 kHz to 250 MHz.
I have only tested to 250 MHz, I think this is the limit.
Some defines in the code for the PLL frequency are likely wrong.
Missing a factor 2, anyways the calculation of the fractional divider is really close.

A free signal generator from 130 kHz to 250 MHz when you have a Pi is nice thing to have.
http://panteltje.com/pub/freq_pi.c

Compile that code with:
gcc -Wall -O4 -o freq_pi freq_pi.c -std=gnu99 -lm

Install it with:
sudo cp freq_pi /usr/local/sbin/

Connect your frequency counter to GPIO header pin 7.

Run it like this for 130 kHz:
freq_pi -f 130000
error on my frequency counter 3 Hz.

Run it like this for 107.2 MHz:
freq_pi -f 107200000
dunno the error, but it wipes out my FM station at 107.2

Run it like this for 250 MHz:
freq_pi -f 25000000

Error is a few kHz on xpsa spectrum analyzer,
but that could as well be the 30 kHz LO offset from the Elonics 4000 tuner..

Nice to test LC circuits, filters, and the 3.3V amplitude is more than enough for most things,
will even drive 3.3V and 5 V logic.

OMG, I totally want a ~200 MHz sig gen.
(Well really 1/2 of 385 MHz.
If I frequency mod our diode laser there,
the side bands, as imaged in our Fabry-Perot cavity,
will overlap. It would be a nice way to measure the length.)

Am I going to have to learn linux to run the
Raspberry Pi?

George H.

The length of the FP cavity.
The cavity is 20 cm. It's confocal.
a tutorial link...
http://www.thorlabs.us/tutorials.cfm?tabID=e9d2d96f-1efd-4ef0-bb17-fa2ca60f8a8d

Geo
 
On a sunny day (Fri, 12 Jun 2015 19:12:10 -0700 (PDT)) it happened George
Herold <gherold@teachspin.com> wrote in
<8ec94527-9654-46a6-a949-b17764cc71be@googlegroups.com>:

On Wednesday, July 24, 2013 at 10:26:17 AM UTC-4, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



I was experimenting with the Pifm code,
and wanted to know what sort of frequencies I could get from the GIPO_4 pin 7.

So I wrote some test code, the program is very simple, and only outputs a square wave.
No extra things needed...
BUT the frequency range is from 130 kHz to 250 MHz.
I have only tested to 250 MHz, I think this is the limit.
Some defines in the code for the PLL frequency are likely wrong.
Missing a factor 2, anyways the calculation of the fractional divider is really close.

A free signal generator from 130 kHz to 250 MHz when you have a Pi is nice thing to have.
http://panteltje.com/pub/freq_pi.c

Compile that code with:
gcc -Wall -O4 -o freq_pi freq_pi.c -std=gnu99 -lm

Install it with:
sudo cp freq_pi /usr/local/sbin/

Connect your frequency counter to GPIO header pin 7.

Run it like this for 130 kHz:
freq_pi -f 130000
error on my frequency counter 3 Hz.

Run it like this for 107.2 MHz:
freq_pi -f 107200000
dunno the error, but it wipes out my FM station at 107.2

Run it like this for 250 MHz:
freq_pi -f 25000000

Error is a few kHz on xpsa spectrum analyzer,
but that could as well be the 30 kHz LO offset from the Elonics 4000 tuner..

Nice to test LC circuits, filters, and the 3.3V amplitude is more than enough for most things,
will even drive 3.3V and 5 V logic.

OMG, I totally want a ~200 MHz sig gen.
(Well really 1/2 of 385 MHz.
If I frequency mod our diode laser there,
the side bands, as imaged in our Fabry-Perot cavity,
will overlap. It would be a nice way to measure the length.)

See my reply to other poster about the DDS wobble around the specified frequency.

Am I going to have to learn linux to run the
Raspberry Pi?

Absolutely
:)



>George H.
 
Ok, have compiled this, but when I try to run it I get can't open dev/mem

I'm assuming it's a permission thing. but did you have this problem and what did you do to workaround.
Thanks in advance.
 
Den onsdag den 27. juli 2016 kl. 22.09.33 UTC+2 skrev Rob:
bcasey@protoconnect.com <bcasey@protoconnect.com> wrote:
Ok, have compiled this, but when I try to run it I get can't open dev/mem

I'm assuming it's a permission thing. but did you have this problem and what did you do to workaround.
Thanks in advance.

I don't see the article you are referring to, but the usual solution
to permission problems on the Raspberry Pi is to type "sudo" in front
of the command. You should be familiar with this if you have done some
little admin things on the Pi.

for obvious security reasons only root can open /dev/mem

sudo or being logging an as root should be the answer

-Lasse
 
bcasey@protoconnect.com <bcasey@protoconnect.com> wrote:
Ok, have compiled this, but when I try to run it I get can't open dev/mem

I'm assuming it's a permission thing. but did you have this problem and what did you do to workaround.
Thanks in advance.

I don't see the article you are referring to, but the usual solution
to permission problems on the Raspberry Pi is to type "sudo" in front
of the command. You should be familiar with this if you have done some
little admin things on the Pi.
 
On Saturday, 13 June 2015 03:12:15 UTC+1, George Herold wrote:
On Wednesday, July 24, 2013 at 10:26:17 AM UTC-4, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



I was experimenting with the Pifm code,
and wanted to know what sort of frequencies I could get from the GIPO_4 pin 7.

So I wrote some test code, the program is very simple, and only outputs a square wave.
No extra things needed...
BUT the frequency range is from 130 kHz to 250 MHz.
I have only tested to 250 MHz, I think this is the limit.
Some defines in the code for the PLL frequency are likely wrong.
Missing a factor 2, anyways the calculation of the fractional divider is really close.

A free signal generator from 130 kHz to 250 MHz when you have a Pi is nice thing to have.
http://panteltje.com/pub/freq_pi.c

Compile that code with:
gcc -Wall -O4 -o freq_pi freq_pi.c -std=gnu99 -lm

Install it with:
sudo cp freq_pi /usr/local/sbin/

Connect your frequency counter to GPIO header pin 7.

Run it like this for 130 kHz:
freq_pi -f 130000
error on my frequency counter 3 Hz.

Run it like this for 107.2 MHz:
freq_pi -f 107200000
dunno the error, but it wipes out my FM station at 107.2

Run it like this for 250 MHz:
freq_pi -f 25000000

Error is a few kHz on xpsa spectrum analyzer,
but that could as well be the 30 kHz LO offset from the Elonics 4000 tuner..

Nice to test LC circuits, filters, and the 3.3V amplitude is more than enough for most things,
will even drive 3.3V and 5 V logic.

OMG, I totally want a ~200 MHz sig gen.
(Well really 1/2 of 385 MHz.
If I frequency mod our diode laser there,
the side bands, as imaged in our Fabry-Perot cavity,
will overlap. It would be a nice way to measure the length.)

Am I going to have to learn linux to run the
Raspberry Pi?

George H.

They have Windows 10 on the Raspberry Pi, but if you are going to do this sort of stuff I would DEFINATELY learn linux...you can make a USB with a "live linux" that you can run from your normal computer with windows or whatever you use. And run it off the USB to test it - it's called Live Linux

The RPi uses Raspbian...a variant of Linux Debian

If you want to get Linux Debian onto a USB to try out for free on any computer let me know I will instruct you fully
 
On Wednesday, July 24, 2013 at 9:26:17 AM UTC-5, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator



I was experimenting with the Pifm code,
and wanted to know what sort of frequencies I could get from the GIPO_4 pin 7.

So I wrote some test code, the program is very simple, and only outputs a square wave.
No extra things needed...
BUT the frequency range is from 130 kHz to 250 MHz.
I have only tested to 250 MHz, I think this is the limit.
Some defines in the code for the PLL frequency are likely wrong.
Missing a factor 2, anyways the calculation of the fractional divider is really close.

A free signal generator from 130 kHz to 250 MHz when you have a Pi is nice thing to have.
http://panteltje.com/pub/freq_pi.c

Compile that code with:
gcc -Wall -O4 -o freq_pi freq_pi.c -std=gnu99 -lm

Install it with:
sudo cp freq_pi /usr/local/sbin/

Connect your frequency counter to GPIO header pin 7.

Run it like this for 130 kHz:
freq_pi -f 130000
error on my frequency counter 3 Hz.

Run it like this for 107.2 MHz:
freq_pi -f 107200000
dunno the error, but it wipes out my FM station at 107.2

Run it like this for 250 MHz:
freq_pi -f 25000000

Error is a few kHz on xpsa spectrum analyzer,
but that could as well be the 30 kHz LO offset from the Elonics 4000 tuner..

Nice to test LC circuits, filters, and the 3.3V amplitude is more than enough for most things,
will even drive 3.3V and 5 V logic.

What does the flowchart for this code look like?
 
On Wednesday, July 24, 2013 at 10:26:17 AM UTC-4, Jan Panteltje wrote:
The Raspberry Pi as a frequency generator
Jan, does v0.7 work on an RPi 3B+?
Per your instructions I have compiled it getting the warning and installed it and it is running, but there is no activity on GPIO4 (pin 7).
sudo freq -f 200000 ==> I changed the name to freq

I am running Raspbian over Noobs whatever the latest builds are - I just loaded them.
I am also a noobs so take that into consideration.

I originally loaded 0.2 but I don't know how to remove it (diff filename than 0.7). apt-get remove can't find the package.
thanks
 
On Wed, 24 Apr 2019 18:39:32 -0700, bill.ruggirello wrote:

I am running Raspbian over Noobs whatever the latest builds are - I just
loaded them.
I am also a noobs so take that into consideration.

I originally loaded 0.2 but I don't know how to remove it (diff filename
than 0.7). apt-get remove can't find the package.
thanks

That message you're replying to is 6 years old! :-D



--
This message may be freely reproduced without limit or charge only via
the Usenet protocol. Reproduction in whole or part through other
protocols, whether for profit or not, is conditional upon a charge of
GBP10.00 per reproduction. Publication in this manner via non-Usenet
protocols constitutes acceptance of this condition.
 
Cursitor Doom wrote...
On Wed, 24 Apr 2019 18:39:32 -0700, bill.ruggirello wrote:

I am running Raspbian over Noobs whatever the latest builds
are - I just loaded them.
I am also a noobs so take that into consideration.

I originally loaded 0.2 but I don't know how to remove it
(diff filename than 0.7). apt-get remove can't find the package.
thanks

That message you're replying to is 6 years old! :-D

Y'all should go out and purchase a cheap Chinese dual-channel
Function Generator, like an MHS-5225A, or a FeelTech FY2224,
or Adoner FY6600. Or better yet, FeelTech FY6600, it goes
to 60MHz, Arbitrary Functions to 10MHz, to 20Vp-p, and has a
10-line color programming display, plus USB link. $99 and up.


--
Thanks,
- Win
 
On Thu, 25 Apr 2019 10:49:16 -0700, Winfield Hill wrote:

Cursitor Doom wrote...

On Wed, 24 Apr 2019 18:39:32 -0700, bill.ruggirello wrote:

I am running Raspbian over Noobs whatever the latest builds are - I
just loaded them.
I am also a noobs so take that into consideration.

I originally loaded 0.2 but I don't know how to remove it (diff
filename than 0.7). apt-get remove can't find the package.
thanks

That message you're replying to is 6 years old! :-D

Y'all should go out and purchase a cheap Chinese dual-channel Function
Generator, like an MHS-5225A, or a FeelTech FY2224, or Adoner FY6600.
Or better yet, FeelTech FY6600, it goes to 60MHz, Arbitrary Functions
to 10MHz, to 20Vp-p, and has a 10-line color programming display, plus
USB link. $99 and up.

Good advice! Even if it happens to be six years too late. :)

BTW, I think you probably meant to write "FY6800" for that last
recommendation (although it's essentially just a slightly revised FY6600
with improved "haptics" and an "earth loop hazard" thrown in for free -
this free gift can be refused by connecting a 10 or even a 1 kR resistor
in series with the stolen from the PSU to main board ribbon cable ground
return wire and the PE tag on the IEC C13/14 mains socket).

There's a whole load of useful info on the FY6600 (and the FY6800) here:

<https://www.eevblog.com/forum/testgear/feeltech-fy6600-60mhz-2-ch-vco-
function-arbitrary-waveform-signal-generator/1825/>

--
Johnny B Good
 

Welcome to EDABoard.com

Sponsor

Back
Top