I have a ham radio project where I need to generate a signal variable between 3.5 to 3.6 MHz out from a pin of an Arduino.
I don't want to use external generators like Si5351a, crystal oscillators or like, just minimalistic usage of external components like a bandpass filter for those nasty overtones is planed.
I have tried out the FastPwmPin library that generates 4MHz but I can't seem to be able to lower the frequency, it's stuck on 4MHz.
Is there any other library or way to get a MHz signal from a Arduino?
(I use a standard UNO with a 16MHz crystal for this project.)
Yes, Timer1 in CTC mode can generate a very few frequencies roughly in that range: for example, the CPU clock 16 MHz divided by integer factors of 2,3,4,5, etc.
Some Arduino clones do use a reasonably accurate 16 MHz crystal, and you can replace that crystal with any other frequency crystal. If you do that, you will need a ISP programmer to reprogram the Arduino, or possibly, generate a custom entry for the boards library specifying the clock frequency.
I understood the intent. Hence my comment "a very few frequencies", and then, even enumerated them.
A reasonably intelligent person will have no trouble following through my post and understanding the consequences. Furthermore, others reading this thread may find the information useful.
@bigstone
To accurately generate a 3.5 MHz signal with a microcontroller, you need to find one whose clock frequency is an integer multiple of 3.5 MHz.
For example, the blackpill STM32F401 board has a frequency of 84 MHz - that is, 24 * 3.5
Or Raspberry Pico RP2040 with a base frequency of 133 MHz = 38 * 3.5
To elaborate it due to the questions asked, yes correct, it is meant to be used on the 80m band in the CW portion, it is to be a "fox" (CW beacon) for fox hunting or ARDF ( Amateur Radio Direction Finding) hence the frequencies. (And yes, I'm a licensed ham radio operator. )
If it where possible to be free to change the frequency in steps of 100Hz or at least 1Khz it would be great but I start to realize that the only way is to use a base crystal which frequency is to be divided with given dividers as 2, 4, 8 or 16 etc. and that will make it unnecessarily complicated.
I thought it could be possible to generate a frequency free of choice, this is possible to do with a Rpi Zero for instance but is way more powerhungry, costly and overkill than necessary for a project like this which is to be outdoors in various weather, risk of stealing etc. and should be cheap to replace, thereof the use of few components.
(Easiest way otherwise is of course to use a external oscillator with a color burst crystal at 3.5795 MHz that one turn on and off to send the characters only that tweaking the frequency is a bit tricky. Setting it based on a digital command would have been way easier, choice to make that happen is to use the Si5351a chip but now we are getting into more complicated and expensive solutions which will call for even more external components like amplifiers etc. .)
There is another way. You can buy colour burst times 4 crystals, 14.31818 MHz. Just replace the Arduino 16 MHz crystal with that, and use a divide by four of some kind. If the AVR is too slow, you can do the same thing with a different processor.
True, also a way to solve it... but still, I would be stuck with a single frequency.
Unfortunately sometimes there might be a local interference on a specific frequency or even other strong stations that could override the "Foxes" frequency and then a simple way to change it is a must.
If I was to use a separate oscillator each had to be carefully trimmed by hand using a small screwdriver and a radio or a frequency reader instrument..... There could be 6 or more foxes to deal with and if it happens 15min before the start of the race....sweaty run for the operator to fix'em all.
Thing is - any synthesis that works only by division is going to have huge frequency steps. You can buy RF synth modules really cheap, I have one and it works great for testing. I think it was in the $5-8 range.
A really old school way (but that is often where you have to dig if you don't want to do things the modern way), is to synthesize a much lower frequency so you can obtain the desired small frequency steps and then multiply that using harmonic overtone multiplier stages. You could use a PLL instead but then you'd be starting to duplicate what the tiny, cheap synth IC already does. Does much better.
You have to clarify your design targets. If you want to simplify the requirements so that a dumb simple device like an Ard can do it, great. But if you want to come after and start insisting on features that defeat or complicate it, then you are trying to go in two directions at once, it won't work.
It's similar to the old, "fast, good, and cheap" idea. Pick any two.
100% correct there aarg.
I had some hope that it was possible to generate a variable signal without to much effort but I have had no experience using uC's before in this manner so this has enlightened me to say the least.
Yepp, I think a RF synth is the way to go but I will try out b707's Pi Pico suggestion as well.
"All in one" seems like a good deal but might have flaws not thought of, we'll se (3.3v output probably has to be amplified etc.).
I will report back my knowledge about my progress in case someone else searches for the same answer.
Ok, I finally I got some spare time to get on with some tests but I doesn't seem to get any signal out. Using Arduino's IDE, shouldn't make any difference I guess?
(Added a pin number since the compiler complained that "pin_OE" was undeclared and set the LED on to verify that the code is up and running.)