Jump to content

Pulse Width Modulation to transmit FM radio waves? (make my own mini radio station?)

babadoctor
Go to solution Solved by babadoctor,

So to finish this thread, it is completely possible (AND HAS BEEN DONE) after a lot of research i found this application.

 

https://bk.gnarf.org/creativity/vgasig/

 

It works.

 

 

Thanks!

3 hours ago, babadoctor said:

I don't know what the difference between a square wave and a sine wave are

It is simply the shape of the waveform:

sinesquare.jpeg.bcd8eb702380b66bfd65261f45c6f072.jpeg

The sine wave is the only true representation of a signal of certain frequency. It can be visualized as the result of a rotation at a constant speed:

sine.gif.842404c803e4f406ef9d756104ce8709.gif

The arrow never speeds up or slows down, so it only contains 1 fundamental frequency. Any other, non-sinusoidal, signal shape would require the arrow speeding up and slowing down, illustrating that they in fact are made up out of a combination of several frequencies.

 

The square wave simply alternates between 2 voltage levels with very fast transitions. You can see it as a alternating combination of 0Hz DC during the horizontal parts of the wave and a extremely high frequency (infinite harmonics, in theory) during the vertical transitions.

 

4 hours ago, babadoctor said:

I thought that the PWM modulation worked by sending a signal through a piece of metal so rapidly that it created a 100mhz signal.

 

PWM stands for "pulse width modulation". It consists of a square wave that alternates at a fixed frequency, but the on vs off time, called "duty cycle" is varied:

pwm.png.0523033aa123740fe9049c16f12e152e.png

 

This can be used, for example, to efficiently control certain devices. A DC motor, for example, when run with a 50% duty cycle will rotate at about half speed. But since the switching device being used is either fully on or fully off it dissipates (wastes as heat) very little power when compared with linear voltage control.

 

As for how FM works. It's in the name: "Frequency modulation". The frequency of a carrier wave (A 100Mhz sine, in your example) is modulated, or changed, by the frequency of the audio wave to be transmitted:

FM.png.a3bd49fd79c7705ca089fbaebb7f543f.png

There's no way to achieve such modulation straight from a PC without extra hardware. As for how the arduino can do it, the page you linked mentions the arduino's PLL (phase locked loop). I'm guessing it somehow (ab)uses the Arduino's clock generator hardware to achieve the required modulation.

 

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, Unimportant said:

 

There's no way to achieve such modulation straight from a PC without extra hardware. As for how the arduino can do it, the page you linked mentions the arduino's PLL (phase locked loop). I'm guessing it somehow (ab)uses the Arduino's clock generator hardware to achieve the required modulation.

 

This was very informative, thank you.

 

Now about the clock generator...

 

Don't computers have clock generators? For timing of the circuits, on the motherboard, yes?

Is that clock generator just not allowed to be messed with, and hence why I can't produce the signal?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, Unimportant said:

There's no way to achieve such modulation straight from a PC without extra hardware. As for how the arduino can do it, the page you linked mentions the arduino's PLL (phase locked loop). I'm guessing it somehow (ab)uses the Arduino's clock generator hardware to achieve the required modulation.

That's exactly what it does actually. All of the libraries, including those for RPi, have a known problem and that is that the FM wave they output is actually a square wave and not a sine wave. I'm not sure what they are doing to get both the negative and positive parts of the wave, I haven't read the libraries enough yet.

I would just use them and see what the deal is, but it would take a week or two for the appropriate chip with the appropriate bootloader to get here so that I could breadboard it and run a debugger on it. Do you know a method of getting assembly out of the Arduino compiler?

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, babadoctor said:

Don't computers have clock generators? For timing of the circuits, on the motherboard, yes?

Is that clock generator just not allowed to be messed with, and hence why I can't produce the signal?

It's not that you can't adjust the clock speed of a processor. You can finely mess with it in BIOS, and you can roughly mess with it by running power level change instructions in permission ring 0 (read, from kernel space only, no user space program can directly change the clock speed of a modern processor).

But we get back to the difference between a microcontroller and a microprocessor. A microcontroller is a microprocessor with a bunch of components connected to it so that it can do all of this stuff. A microprocessor is just the math and logic part of a microcontroller. There is no way to get this functionality out of a modern computer without first designing a system bus board (like a PCIe board) that contains the functionality that you want.

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, straight_stewie said:

It's not that you can't adjust the clock speed of a processor. You can finely mess with it in BIOS, and you can roughly mess with it by running power level change instructions in permission ring 0 (read, from kernel space only, no user space program can directly change the clock speed of a modern processor).

But we get back to the difference between a microcontroller and a microprocessor. A microcontroller is a microprocessor with a bunch of components connected to it so that it can do all of this stuff. A microprocessor is just the math and logic part of a microcontroller. There is no way to get this functionality out of a modern computer without first designing a system bus board (like a PCIe board) that contains the functionality that you want.

Oh I see.

 

So there are certain components on the raspberry pi bus that just aren't there in a pc.

 

hmm...

 

21 minutes ago, straight_stewie said:


I would just use them and see what the deal is, but it would take a week or two for the appropriate chip with the appropriate bootloader to get here so that I could breadboard it and run a debugger on it. Do you know a method of getting assembly out of the Arduino compiler?

Why do you need to get assembly out of the arduino compiler? If this is for understanding how the code works, it's on github. right?

https://github.com/Miegl/PiFmAdv

 

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, babadoctor said:

Why do you need to get assembly out of the arduino compiler? If this is for understanding how the code works, it's on github. right?

There is a level of understanding that you can get by looking at assembly (or even lower than that) that you can't get by looking at C or C++ code.

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, straight_stewie said:

There is a level of understanding that you can get by looking at assembly (or even lower than that) that you can't get by looking at C or C++ code.

That's very interesting

 

But what information about the program could you possibly gain by looking at the compiler code on the arduino?

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, babadoctor said:

That's very interesting

 

But what information about the program could you possibly gain by looking at the compiler code on the arduino?

If we're talking about looking at assembly in general, you can see what sort of optimizations are being made or how certain constructs and aspects of a higher level language get compiled into a lower level one. So if high performance is your goal, you can make smarter decisions about which construct of a higher level language to use.

 

But I dunno. I haven't used assembly in a long time. I didn't even really use it much where I worked at my last company and we had MCUs that were more primitive than what's on a RasPi or Arduino. The only time I had to seriously touch assembly language was to perform a check on startup before the C initialization routines started because the MCU needed to know whether or not actually start up or go back to deep sleep.

 

It's nice to know, but depending on what you want to do with your career or project, I don't think it's imperative.

Link to comment
Share on other sites

Link to post
Share on other sites

31 minutes ago, M.Yurizaki said:

If we're talking about looking at assembly in general, you can see what sort of optimizations are being made or how certain constructs and aspects of a higher level language get compiled into a lower level one. So if high performance is your goal, you can make smarter decisions about which construct of a higher level language to use.

 

But I dunno. I haven't used assembly in a long time. I didn't even really use it much where I worked at my last company and we had MCUs that were more primitive than what's on a RasPi or Arduino. The only time I had to seriously touch assembly language was to perform a check on startup before the C initialization routines started because the MCU needed to know whether or not actually start up or go back to deep sleep.

 

It's nice to know, but depending on what you want to do with your career or project, I don't think it's imperative.

I see, that's really cool. 

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, straight_stewie said:

Square wave, and it would be possible to convert from one to the other by specifying that the frequency is defined as, say "the duty cycle, adjusted to fit into the output band". Be aware that this method requires special external hardware.

I specifically didn't say square wave because they are only used in theory.

[Out-of-date] Want to learn how to make your own custom Windows 10 image?

 

Desktop: AMD R9 3900X | ASUS ROG Strix X570-F | Radeon RX 5700 XT | EVGA GTX 1080 SC | 32GB Trident Z Neo 3600MHz | 1TB 970 EVO | 256GB 840 EVO | 960GB Corsair Force LE | EVGA G2 850W | Phanteks P400S

Laptop: Intel M-5Y10c | Intel HD Graphics | 8GB RAM | 250GB Micron SSD | Asus UX305FA

Server 01: Intel Xeon D 1541 | ASRock Rack D1541D4I-2L2T | 32GB Hynix ECC DDR4 | 4x8TB Western Digital HDDs | 32TB Raw 16TB Usable

Server 02: Intel i7 7700K | Gigabye Z170N Gaming5 | 16GB Trident Z 3200MHz

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

So to finish this thread, it is completely possible (AND HAS BEEN DONE) after a lot of research i found this application.

 

https://bk.gnarf.org/creativity/vgasig/

 

It works.

 

 

Thanks!

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×