A FREE frequency generator if you have a Raspberry Pi

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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.








Re: A FREE frequency generator if you have a Raspberry Pi
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 ....

!







Re: A FREE frequency generator if you have a Raspberry Pi
On Thursday, July 25, 2013 3:18:15 AM UTC-7, Jan Panteltje wrote:
Quoted text here. Click to load it

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.

Re: A FREE frequency generator if you have a Raspberry Pi
On a sunny day (Tue, 9 Sep 2014 11:11:56 -0700 (PDT)) it happened
snipped-for-privacy@gmail.com wrote in

Quoted text here. Click to load it

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.

Re: A FREE frequency generator if you have a Raspberry Pi
hello sir .  
i need to generate a frequency of 14.318mhz  with an RPI , is that possible with your code ?

Re: A FREE frequency generator if you have a Raspberry Pi
On a sunny day (Fri, 12 Jun 2015 17:28:40 -0700 (PDT)) it happened
snipped-for-privacy@gmail.com wrote in

Quoted text here. Click to load it

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.

Re: A FREE frequency generator if you have a Raspberry Pi
On Wednesday, July 24, 2013 at 10:26:17 AM UTC-4, Jan Panteltje wrote:
Quoted text here. Click to load it

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.




Re: A FREE frequency generator if you have a Raspberry Pi
On Friday, June 12, 2015 at 10:12:15 PM UTC-4, George Herold wrote:
Quoted text here. Click to load it

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

Re: A FREE frequency generator if you have a Raspberry Pi
On a sunny day (Fri, 12 Jun 2015 19:12:10 -0700 (PDT)) it happened George

Quoted text here. Click to load it

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

Quoted text here. Click to load it

Absolutely
:-)



Quoted text here. Click to load it

Re: A FREE frequency generator if you have a Raspberry Pi
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.

Re: A FREE frequency generator if you have a Raspberry Pi
Quoted text here. Click to load it

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.

Re: A FREE frequency generator if you have a Raspberry Pi
Den onsdag den 27. juli 2016 kl. 22.09.33 UTC+2 skrev Rob:
Quoted text here. Click to load it

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

sudo or being logging an as root should be the answer

-Lasse

Site Timeline