Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Clock output & FM transmitter

Fri Feb 14, 2014 6:01 pm

Has anybody used the VHF transmitter code from here
http://www.icrobotics.co.uk/wiki/index. ... ransmitter
I wanted to test my clock output and this code looked simple to use but running it under python I get an error.
AttributeError 'module' object has no attribute 'play_sound'
I don't really want to get in to python so I tried the C command
./p**** sound.wav 100.0
that runs without errors but nothing comes out of the pin. Do I have to do something else before the C command will work?

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Clock output & FM transmitter

Fri Feb 14, 2014 6:07 pm

You need to attach a wire to GPIO4 otherwise the range is pretty poor i.e. 3cm - http://elinux.org/RPi_Low-level_periphe ... .28GPIO.29

Richard S.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Fri Feb 14, 2014 6:28 pm

Yes but a wire makes no difference if the pin isn't moving so is there some software switch that this C routine doesn't set that is stopping the pin from working?

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Clock output & FM transmitter

Fri Feb 14, 2014 6:29 pm

Are you measuring the voltage output from the pin or using an FM radio??

Richard S.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Fri Feb 14, 2014 7:20 pm

Using a scope and the pin don't move. Is there any other software that tests this pin?

User avatar
jbeale
Posts: 3675
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Clock output & FM transmitter

Fri Feb 14, 2014 8:15 pm

It worked ok for me, I think I did exactly what you did so I'm not sure why it's not working for you. You are running this as root, right? Do you have any other processes that might be using the GPIO pins? Note, I'm using Raspbian, I haven't tried this with any other OS. I get some reception to at least 3 meters of range, even without any wire on the GPIO pin.

Code: Select all

wget http://omattos.com/pifm.tar.gz
tar xvfz pifm.tar.gz
sudo ./pifm sound.wav 100.1

<music soundtrack plays on nearby FM radio tuned to 100.1 MHz>

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Clock output & FM transmitter

Fri Feb 14, 2014 11:01 pm

Ruptor wrote:Using a scope and the pin don't move. Is there any other software that tests this pin?
What scope are you using, does it have at least 500MHz bandwidth??

Do you have an FM radio or a Frequency Counter (like in photo) to confirm radio emissions from GPIO 4??
Image

Richard S.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Sat Feb 15, 2014 12:03 am

Hi John
There are some weird things going on with my RPi. The p*** (sensored) software I was using was the second download of it that must also be corrupt so I was about to download it a third time when I saw your post so I did it your way. When I ran it the out put up a 100 MHz wave that was made of what looked like 3 steps and the prompt didn't return. On my previous software the prompt came back straight after hitting the enter key for the C command so clearly something was different with the new download especially since the output gave a wave out. I turned off the power and tried the p*** command again and hey presto an FM sine wave of about 2V appeared. The previous software obviously did something weird to the hardware that required a power down to clear. The output gives some very strange voltages if you change the frequency. At 60 mHz the voltage appeared to be 6V and at 30 MHz it dropped to 4V giving a lopsided sine wave more like a sawtooth with rounded edges. I was expecting to see square waves at lower frequencies and I don't think the scope is to blame because I have looked at 150 MHz clocks with it before and seen nice sine waves. Are these wave shapes what I should be getting or is there something wrong with my board given the amount of trouble I have had with corruption?

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Clock output & FM transmitter

Sat Feb 15, 2014 12:19 am

I don't have a scope it's one of them on my to buy list when I can afford one. :)

As far as I'm aware the Pi GPIO is 3.3v so the 6v maybe just the way the signal bounces around the cable causing erroneous readings, perhaps you need to use a dummy load or something??

One thing I have noticed is that at 100MHz the amount of harmonic distortion is pretty minimal but tune away to 106MHZ or 88MHz and the entire FM and (including Airband and beyond) gets trashed with multiple signals.
I'm guess that at 100MHz the duty cycle is probably 50% but using different frequencies the duty cycle shifts slightly from 50%.

I was wondering does your scope show any interesting distortion in waveforms when comparing 100MHz and say 106MHz??

Richard S.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Sat Feb 15, 2014 11:42 am

Hi Richard
Yes a scope is well worth having if messing around with signals since seeing is believing. I don't have lots of money so I bought one from China for £200 total including shipping on Ebay and it is fantastic. It has a wide screen and 1G/s with 100 MHz probes. The equivalent buy in Europe worked out at £800 after VAT & delivery and it only had a 4" screen not 6". I think it is difficult to get past customs now though since the financial problems they seem to be hot on the imports so I was lucky.
There are all sorts of harmonics at the lower frequencies like I said because of the funny shape of the wave. My probes are only 100 MHz so the levels will theoretically only be 60% of reality but if the shape isn't good that means it is even worse than shown by the scope because the scope will round things off. I will post some pictures later if it still works. :)

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Sat Feb 15, 2014 6:28 pm

I used a better scope connection so the waves are not so bad as my first view. The pictures are at 70, 88, and 100 MHz and it looks like waves below 70 MHz are all pretty good but the mechanism for generating waves does funny things the closer you get to it clocking frequency. This is the same with DDS chips so it might be the same problem.
Attachments
W100.jpeg
W100.jpeg (26.97 KiB) Viewed 5353 times
W88.jpeg
W88.jpeg (26.98 KiB) Viewed 5353 times
W70.jpeg
W70.jpeg (26.39 KiB) Viewed 5353 times

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Sat Feb 15, 2014 6:33 pm

This site only allows 3 files per post so here is the wave at 108 MHz. The uneven shape probably explains the rough radio reception at this frequency but there might be other frequencies in the VHF range that are equally bad because it depends on how good the generated wave is at a given frequency.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Sat Feb 15, 2014 6:35 pm

Oops! try again.
Attachments
W108.jpeg
W108.jpeg (26.37 KiB) Viewed 5352 times

User avatar
jbeale
Posts: 3675
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Clock output & FM transmitter

Sat Feb 15, 2014 6:56 pm

In case of interest, here are a few scope captures. Anything above 20 MHz looks like a sine wave, but that's expected as my TEK TDS-210 scope has only 60 MHz analog bandwidth. The signal is generated by dividing down an internal 500 MHz clock so frequencies that are not even divisors of that frequency (like 40 MHz = 500/12.5) do not have a perfectly regular waveform, as you see. I used the short scope probe adaptor wires shown in the second photo, although connected to GPIO-4 (Port 1 pin 7) for the p*** program, and not GPIO-18 (Port 1 pin 12) as shown, which is used by Joan's Pulse Generator.
IMG_3932.JPG
IMG_3932.JPG (25.99 KiB) Viewed 5331 times
IMG_3933.JPG
IMG_3933.JPG (36.07 KiB) Viewed 5331 times
IMG_3938.JPG
IMG_3938.JPG (45.58 KiB) Viewed 5331 times
Last edited by jbeale on Sat Feb 15, 2014 7:00 pm, edited 2 times in total.

User avatar
jbeale
Posts: 3675
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Clock output & FM transmitter

Sat Feb 15, 2014 6:58 pm

also 40 MHz and 100 MHz, again with my 60 MHz analog bandwidth scope.
IMG_3940.JPG
IMG_3940.JPG (52.49 KiB) Viewed 5331 times
IMG_3942.JPG
IMG_3942.JPG (54.97 KiB) Viewed 5331 times

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Mon Feb 17, 2014 12:48 pm

I wanted to play with the C source file, p***.c, to learn about the code and peripheral operation so I decided to compile it to make sure everything was in order but it gave errors. Man talk about irritating I can't even compile a working ready made program. When I looked at the errors in the code they were pointing to the Class statements and then the penny dropped. The blasted code is C++ not C so instead of using gcc I should have used g++. People just don't get the idea of standards or rules and that is why there is so much rubbish being produced these days in hardware and software. Why call C++ source .c when it should be .cpp it is completely different. That's another reason to use FreePascal where there is only .pas and it compiles on any platform Windows, Linux, Mac, Arm etc.

Ruptor
Posts: 74
Joined: Mon Jan 27, 2014 12:26 pm
Location: London

Re: Clock output & FM transmitter

Mon Feb 17, 2014 5:08 pm

Just realised from looking at the code that an empty wave file allows you to get a carrier only output. This is useful for frequency checking without modulation and as a settable high frequency source.

Return to “Bare metal, Assembly language”