High Frequency Output

RNovember

Well-known member
Hello, I am building a project, and for it to run properly, it needs a 20 megahertz signal, of any wave form.

I was wondering if there was a picaxe chip/command that would do that. I looked through the list of picaxe commands, and couldn't find anything.

Thank you.
 

inglewoodpete

Senior Member
You could run the PICAXE with 20MHz resonator or crystal. However, this may bring its own problems, since the PICAXE has its x4 PLL engaged for all external clock settings and will need to run at 80MHz: a little out of spec.

A better solution may be to use a resonator/crystal with an external Schmitt inverter/driver. If necessary, the PICAXE could gate the output of this oscillator.
 

RNovember

Well-known member
Okay, maybe I will do that.

I wanted to use the picaxe because it could sense conditions in the circuit, and turn on and off the signal.

What I was wondering is whether there was something like: freqout (pseudo command) c.3 (pin number), m20 (frequency).
 
Last edited:

inglewoodpete

Senior Member
What I was wondering is whether there was something like: freqout (pseudo command) c.3 (pin number), m20 (frequency).
I'm afraid not.

As far as I'm aware the only command that can output pulses anywhere near what you want is PWMOut: 4MHz (for an M2-family chip running at 32MHz) or 8MHz (using an X2-family chip running at 64MHz).
 

Pongo

Senior Member
You can buy metal can 20 MHz crystal oscillators for a few $ (if looking on ebay the 4 pin ones, not the 2 pin ones, those are only crystals). I would take one of those and use the picaxe to either switch the power to the oscillator (if it starts/stops nicely at power up/down) or to switch the output on and off with a gate.
 

AllyCat

Senior Member
Hi,

No, there is no command to do it, because the commands are "tokenised" and there is no token for 40 MHz. You can check what is possible in the Simulator, for example try simulating and editing the following. It will "fail" on the m40, but should accept m64 instead and print the token byte values. Change the #picaxe to 20M2 and it will fail again (M2s don't support 64 MHz).

Code:
#picaxe 20X2
sertxd (#m4," ",#m8," ",#m16," ",#m32," ",#m40)
I'm not an X2 user but what you might be able to do is:
Use an external 10MHz resonator/crystal (only with an X2 PICaxe) which should give a 40 MHz internal clock.
Set up one of the (hardware) PWM outputs to a Period of just two cycles and a Duty Cycle of 50% (1 in 2). If you're lucky, that may give a 20 MHz square wave output.

EDIT: But you'd also need to switch in or exchange a "standard" 8 / 16 MHz resonator/crystal to give the correct serial comms frequency for programming. :(

Cheers, Alan.
 
Last edited:

RNovember

Well-known member
I'll see if a crystal will work.

For some reason, I couldn't get my PWM to work. If I set it at 1 megahertz, the fastest I could get my chip to go, I couldn't find a signal with my oscilloscope, but I could when it was set at 1 kilohertz. I don't know why it did that, or maybe my oscilloscope is not working.

Thank you for your ideas everyone.
RNovember.
 

hippy

Technical Support
Staff member
Set up one of the (hardware) PWM outputs to a Period of just two cycles and a Duty Cycle of 50% (1 in 2). If you're lucky, that may give a 20 MHz square wave output.
Things get a little icky at the high speed end of things because of the way PWM actually works internally, period being 8-bit and duty being 10-bit.

For the fastest PWMOUT 1,3 setting; the internal PWM 'timer' counts 0 to 7 and the duty is 3 which makes the output high when the count is 3 or less -
Code:
              0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
              _______         _______ 
PWMOUT 1,3   |       |_______|       |_______
To double that one needs to go to PWMOUT 0,1 - Count 0 to 3, high when 1 or less -
Code:
              0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3
              ___     ___     ___     ___
PWMOUT 0,1   |   |___|   |___|   |___|   |___
Unfortunately period being zero tells the firmware to turn the PWMOUT off so you need to set the PWM registers using POKESFR.

But that won't do much good because the maximum PWMOUT frequency is a quarter of the operating speed; 16MHz when running at 64MHz.

To get above that one would need to use a 28X2 or 40X2 with an external 20MHz crystal while keeping your fingers crossed that over-clocking works.

Best option IMO is, as suggested, an external crystal oscillator module with gating if needed, or a gate configured around a crystal.

Edited: Corrected internal counting scheme. I said it's a bit complicated!
 
Last edited:

Phil bee

Member
You could use a DDS board and program it via the i2c port. like the 'Raduino Board' as used with the Bitx40 tranciever.
 

mortifyu

New Member
You could always use something like this coupled a PICAXE 50% DUTY CYCLE PWM output signal.

https://www.idt.com/document/dst/512-datasheet

As a bonus, you would of course be able to effectively produce and broadly variable output frequency dependent on the multiplier you select with it's S0 & S1 pins and of course the frequency of your PWM signal.


Hope this helps.
 

RNovember

Well-known member
Hey, great idea. This looks like it just takes input, and multiplies it by a factor that you specify. I think this would work well for what I am doing. I could turn it off just by setting the chip PWMout pin low and turn it on by turning on the pwm.

Maybe I could hook multiple ones together to get a very high frequency output. The circuit does need to run at 8 megahertz, and the maximum pwmout at this frequency is 1 megahertz.

Thanks for the idea.
 

mortifyu

New Member
Hey, great idea. This looks like it just takes input, and multiplies it by a factor that you specify. I think this would work well for what I am doing. I could turn it off just by setting the chip PWMout pin low and turn it on by turning on the pwm.

Maybe I could hook multiple ones together to get a very high frequency output. The circuit does need to run at 8 megahertz, and the maximum pwmout at this frequency is 1 megahertz.

Thanks for the idea.

You are welcome!

You could indeed cascade a few to achieve higher frequency output, but I am sure there would be other readily available IC's that have a similar functionality with higher multiplication factors. Which ever way you go, always be sure to put a 100nF decoupling capacitor across VCC and GND of ALL individual IC's you use.

None the less, here is where you could purchase ICS512's rather cheap... https://www.utsource.net/sch/ICS512


Personally I am more of a build it component by component then design a dedicated circuit board for it kinda bloke. More fun, more challenge ;)
 

hippy

Technical Support
Staff member
If looking for just a 20MHz signal, then I would have thought a fixed oscillator solution, powered module or gated circuit, would be the most accurate, easiest and cheapest to create and use.
 

RNovember

Well-known member
If looking for just a 20MHz signal
Sorry, I didn't realize I had made it sound like I needed only a 20MHz signal. All I need is something over 10MHz. The exact frequency doesn't matter. The project that this is for is an upgrade to my combination lock, https://picaxeforum.co.uk/threads/combination-lock.31329/.

I want to be able to brute force it, which means to go through all the combinations one at a time until you get the right one. This takes about 3 years (an exaggeration, but you get my point) at 20KHz (the fastest clock speed I have achieved so far). I wanted something in the MHz to speed it up.
 

premelec

Senior Member
If you just need any old frequency above 20 MHz - use a simple canned oscillator usually a rectangular package with 4 terminals for power and output.... plug and play... ;-0 Note lots of old computer PCBs have these oscillators so you can salvage one from an old computer board...
 
Last edited:

hippy

Technical Support
Staff member
Sorry, I didn't realize I had made it sound like I needed only a 20MHz signal. All I need is something over 10MHz. The exact frequency doesn't matter. The project that this is for is an upgrade to my combination lock, https://picaxeforum.co.uk/threads/combination-lock.31329/.
Sounds like a 20X2 at 64MHz running PWM at 16MHz would do the job. Or just one of those oscillator modules which go to 100MHz and beyond. You could go up to 2GHz if the rest of your circuitry could handle that.
 

RNovember

Well-known member
use a simple canned oscillator
I need to do some experimenting with the frequency, so something variable would be nice. I would have to get multiple can oscillators if the first one I got was a frequency that didn't work.
Sounds like a 20X2 at 64MHz running PWM at 16MHz would do the job.
It would. Only problem is I don't have an extra 20X2.
if the rest of your circuitry could handle that.
That is why I need to experiment. I don't know what it can handle. Also, how fast can a picaxe respond to an input?
 
Last edited:

mortifyu

New Member
Do they have any DIP packages? I am using a breadboard, so those would be nice.

A quick Google search... It appears pretty much any similar IC's are all SOIC-8.

For breadboard adaption, just solder some resistor legs to each pin. I have had to test SMD circuitry with breadboards in the past quite successfully doing this. Try soldering resistor legs to a SuperSOT-3 package. Doable, but it's like soldering resistor legs to a fly's turd. :p
 

nekomatic

Member
Have you tried a simple relaxation oscillator with a couple of gates or inverters? For example this circuit. I think you should be able to reach the kind of speed you want as long as you use a 74HC132 instead of the 4093. Instead of the RUN/STOP switch you can use a PICAXE output to gate the oscillator on or off.

Similarly you should be able to make a crystal oscillator with a couple of gates like this - again if you go for 74HC rather than 4000 series parts then I think you should manage the speed you want on a 5 V supply. You can probably get away with a fixed capacitor for C2 in that circuit and possibly omit R2, just try it and see what works. Crystals are pretty cheap.

The other thing you could try would be a ring oscillator, again using a NAND gate input to run or stop it. I don't know how fast this will go but it's easy to try out, at least as long as you've got some means of measuring the output!
 

RNovember

Well-known member
Have you tried a simple relaxation oscillator with a couple of gates or inverters?
Yes. But there were some reasons that I switched to the 555 timer. One is that the circuit I used was hard to turn off. Also it took a lot of room on the bread board (if you look at the project, you will see that I don't have a lot of extra room). Also it was slower than what I wanted.
as long as you use a 74HC132 instead of the 4093.
That might be the reason. I was using 4000 series NAND gates with the inputs all tied together to make my inverters.
 
Top