11
\$\begingroup\$

I am asking this question primarily to learn.

I have learned that Hz is the number of cycles in one second.

Taking that into consideration I have tried the following examples.

Example 1

void loop() {     
  digitalWrite(3,HIGH); // make pin 3 have a voltage of ~ 5V
  delay(500); // wait 0.5 seconds
  digitalWrite(3,LOW); // make pin 3 have a voltage of ~ 0V
  delay(500); // wait 0.5 seconds
}

This code has a frequency of 1 Hz because voltage is .5 seconds up and .5 down. My voltmeter shows .99999 Hz

enter image description here

The duty cycle is 50% because the voltage is half of the time up and half of the time down.

Example 2

void loop() {     
  digitalWrite(3,HIGH); // make pin 3 have a voltage of ~ 5V
  delay(90); // wait 0.09 seconds
  digitalWrite(3,LOW); // make pin 3 have a voltage of ~ 0V
  delay(10); // wait 0.01 seconds
}

This code has a frequency of 10 Hz because every cycle is .1 seconds (90 ms + 10 ms). In 10 cycles you will reach 1 second. The duty cycle of this code is 10%.


The following examples are basically the question:


Example 3

void loop() {     
  digitalWrite(3,HIGH); // make pin 3 have a voltage of ~ 5V
  // Do not delay
  digitalWrite(3,LOW); // make pin 3 have a voltage of ~ 0V
  // Do not delay
}

If I run this code, my voltmeter shows a frequency of 112,000 Hz or 112 kHz:

enter image description here

I believe that is the highest frequency I can get. I am not delaying in between cycles. Why is it that when I google the frequency of Arduino Uno it says:

enter image description here

Example 4

Google is probably correct and the frequency is 16 MHz for Arduino. If that is true, then how can an Arduino send a 433 MHz frequency? I want to buy this:

enter image description here

When I now set delay as in Example 3, the highest frequency I could obtain was 112 kHz (with a k). How is it possible to send a 433 MHz frequency (with an M)?

\$\endgroup\$
7
  • 7
    \$\begingroup\$ Because the Arduino is not sending 433MHz. That module does that itself. \$\endgroup\$ Apr 16, 2020 at 20:15
  • \$\begingroup\$ en.wikipedia.org/wiki/Modulation \$\endgroup\$ Apr 16, 2020 at 20:19
  • \$\begingroup\$ BTW, if you want to achieve a higher frequency than 112kHz in example 3 without external stuff, you should use direct port manipulations (PORTx) \$\endgroup\$
    – Swedgin
    Apr 17, 2020 at 11:37
  • \$\begingroup\$ Short answer: the radio kit creates the 433MHz, not the arduino. \$\endgroup\$ Apr 17, 2020 at 11:38
  • \$\begingroup\$ I think you are MISREADING the Google results you posted above. It says "490.196 Hz" not MHz! You're off by 1,000,000 here. \$\endgroup\$
    – jwh20
    Apr 17, 2020 at 13:24

6 Answers 6

21
\$\begingroup\$

The short answer: It doesn't.
Arduino doesn't send anything close to that high. It can only send a lower frequency (lower bitrate) signal over a 433MHz CARRIER frequency (or any other frequency for that matter) by using another device/module which generates a very high frequency (radio frequency) in order to communicate via radio waves.
The 433MHz in this case is NOT THE RATE OF DATA/BITS, but a frequency of the radio signal over which the data is transmitted/received.
Your question shows a lack of knowledge about the meaning of, and the difference between, processor clock frequencies, speed of processing, data rate, and "carrier" frequencies as the means of radio communication, so you should read and learn more about basic computer processing and its related terms, and about the means and ways of transmitting information over radio waves.
Basically, the carrier/radio frequency is modulated/changed by the information/data you want to transmit, so it is those changes that represent the information.
Based on the type of change, there are 3 basic types of modulation.
Amplitude Modulation (AM), Frequency Modulation (FM), Phase Modulation (PM).
With AM, the carrier frequency is kept stable/same, while the amplitude/power of the carrier frequency is varied to transmit information.
FM keeps the carrier amplitude the same (at maximum) while the frequency changes up and down a certain amount represent information.
PM is similar to FM, and it carries information by phase-shifting the carrier frequency.

\$\endgroup\$
6
  • 13
    \$\begingroup\$ As an extreme example: if you use the arduino to light a red LED, that LED would be transmitting electromagnetic waves at a frequency of about 430 THz. But that has nothing to do with Arduino, the LED would also do that if you powered it directly from a battery. \$\endgroup\$
    – Åsmund
    Apr 17, 2020 at 7:42
  • \$\begingroup\$ @Åsmund - nice analogy \$\endgroup\$
    – SiHa
    Apr 17, 2020 at 8:05
  • 5
    \$\begingroup\$ And it you program that read LED to blink at 1 Hz, the effective signal would be 430 Thz multiplied with a 1 Hz block wave. \$\endgroup\$
    – MSalters
    Apr 17, 2020 at 10:04
  • 1
    \$\begingroup\$ Another example, your light flickers with a frequency of 120Hz because of the mains frequency, you can still use the light to communicate with some by just turning it off or on every second, the carrier frequency is 120Hz, but you are sending data at 1Hz \$\endgroup\$
    – Ferrybig
    Apr 17, 2020 at 10:50
  • \$\begingroup\$ @MSalters well, that would actually be a mess of a signal, given that a LED never emits anything even resembling a monochromatic wave... \$\endgroup\$
    – Ruslan
    Apr 17, 2020 at 12:42
12
\$\begingroup\$

Why is it that when I google the frequency of arduino uno it says:

16 MHz is the clock frequency of the processor, basically how fast the CPU core runs.

If that is true then how can an Arduino send a 433 MHz frequency?

You would buy a radio that transmits at 433 MHz center frequency. The speed of the CPU has no relationship to what frequency the radio transmits at. For example, in the extreme case of a fiber optic, the optical frequency is 300,000 GHz, but your CPU would still be 16 MHz.

When I set now delay on Example 3 the highest frequency I could obtain was 112 kHz (with a k). How is it possible to send a 433 MHz frequency (with an M)?

The radio datasheet should give you an idea of how to connect to it, but basically it would attach over some bus (e.g. USB) or provide you with some data signal that you would read in. What does the radio's datasheet say to do?

\$\endgroup\$
4
\$\begingroup\$

These "examples" seem to be questions that can be answered:

3) Toggling a pin in a loop with DigitalWrite function is slow. That is why you only get 112 kHz. The microcontroller still runs with 16 MHz clock.

4) The transmitter generates its own RF carrier wave. You can send slow data for the module to transmit.

\$\endgroup\$
1
\$\begingroup\$

The Arduino runs at 16MHz. This means that if you programmed it in assembly, each instruction would take \$\frac{1}{16\times10^{6}} = 62.5\mathrm{nS}\$. You probably don't want to do assembly. The compiler is efficient enough to convert your code into assembly and then into hex.

I believe that is the highest frequency I can get

The reason why you're getting a lower frequency than 8MHz (16/2 ; 1 instruction to turn on the pin 1, instruction to turn it off) is that Arduino has a lot of overhead which makes it easier for beginners to start coding but makes the program relatively slower.

Copy and paste the following code to replace your loop() function:

loop()
{
    PORTD ^= (1<<PD3);  
}

No delays, just that 1 line. When I last tried it, it got me a 3MHz square wave. This is still not the predicted 8MHz. Now lets try to bypassing the loop() function by adding an infinite while loop inside it.

loop()
{
    while(1)
    {
      PORTD ^= (1<<PD3);
    }
}

Tadaa!!! You should now get the 8MHz signal.

A lot of people have already explained the 433MHz question. I just thought I should add my spiel on frequency. I'd be happy to explain what's going on in the code if you'd like

\$\endgroup\$
2
  • \$\begingroup\$ You still probably wont get an 8MHz signal, because PORTD ^= (1<<PD3) probably takes more than 1 cycle. \$\endgroup\$
    – BeB00
    Jul 23, 2020 at 19:55
  • \$\begingroup\$ Ya you're probably right. But its close \$\endgroup\$ Jul 24, 2020 at 21:02
0
\$\begingroup\$

The radio module may simple implement on/off keying. For 433MHz, the rate of data has to be low, so the sidebands fit into the 1MHz allocation.

Garage door openers are of this type.

\$\endgroup\$
0
\$\begingroup\$

The 433 MHz is the frequency that is produced by the radio.

The data being transferred over the radio's side band will never be as fast as the carrier signal.

If you put an oscilloscope on the radio, you will get the 433MHz signal.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.