Author Topic: switch between 2 oscillators?  (Read 9773 times)

0 Members and 1 Guest are viewing this topic.

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
switch between 2 oscillators?
« on: March 26, 2016, 09:50:30 am »

 Say you have 2 555 timers. One output at 50khz, the other at 100khz.
 How can one switch between these outputs every millisecond?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #1 on: March 26, 2016, 10:19:26 am »
A CMOS switch but why?

You could have one 555 timer and just change the value of the resistor/capacitor. There are other possibilities such as a voltage controlled oscillator or microcontroler.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: switch between 2 oscillators?
« Reply #2 on: March 26, 2016, 10:44:15 am »
There is also the issue of synchronous switching, so no fore shortened or expanded
period occurs. Each cycle is one or the optehr period. Do you care ? If not then switching
caps or timing components would be OK.

Regards, Dana.

Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #3 on: March 26, 2016, 02:41:12 pm »
Use a MOSFET to switch an additional capacitor into the RC circuit. When the MOSFET is on, C2 is switched into the circuit which roughly halves the frequency. C1 is slightly smaller than normally required because the MOSFET has some additional capacitance.

V2 represents the control signal which changes the frequency.

It works fine in LTSPICE but I haven't built it in real life.
 

Offline KM4FER

  • Regular Contributor
  • *
  • Posts: 81
  • Country: us
Re: switch between 2 oscillators?
« Reply #4 on: March 26, 2016, 03:40:28 pm »
If you want an exact 2:1 ratio I would run the 555 at the highest rate and follow it with a D flip-flop to divide by two.  Now you have both frequencies and you can switch between them with a couple of nand gates and a 1KHz square wave.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1282
  • Country: gb
    • bitdynamics
Re: switch between 2 oscillators?
« Reply #5 on: March 26, 2016, 05:48:14 pm »
Any small microcontroller (ATTINY etc) with a double buffered Timer Compare Counter would do this easily, although it depends on the accuracy and drift you need for your clock signals?
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #6 on: March 26, 2016, 06:10:35 pm »
Anything involving programing is much like sourcery to my archaic mind.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #7 on: March 26, 2016, 06:38:52 pm »
If you want an exact 2:1 ratio I would run the 555 at the highest rate and follow it with a D flip-flop to divide by two.  Now you have both frequencies and you can switch between them with a couple of nand gates and a 1KHz square wave.
I'd omit the 555 altogether and go for the HEF4060 or 74HC4060 and use a 12.8MHz crystal.
http://www.nxp.com/documents/data_sheet/HEF4060B.pdf
http://www.nxp.com/documents/data_sheet/74HC_HCT4060_Q100.pdf

Q7 will then give exactly 100kHz and Q8 50kHz.

I'll probably need 25khz and 38khz oscillations. Hopefully very square, and as near 50% duty as possible.
Have your requirements changed because that's totally different. A 555 and MOSFET to switch a capacitor in/out of the circuit would work but it isn't as accurate as a crystal. The divider method won't work for 25kHz &38kHz because they're not even multiples of one another.
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #8 on: March 26, 2016, 07:43:42 pm »
I'll probably need 25khz and 38khz oscillations. Hopefully very square, and as near 50% duty as possible.
Have your requirements changed because that's totally different. A 555 and MOSFET to switch a capacitor in/out of the circuit would work but it isn't as accurate as a crystal. The divider method won't work for 25kHz &38kHz because they're not even multiples of one another.

 Can't... That's the actual output I need!
 

Offline bson

  • Supporter
  • ****
  • Posts: 2270
  • Country: us
Re: switch between 2 oscillators?
« Reply #9 on: March 26, 2016, 08:26:08 pm »
If you need accuracy and stability better than what a 555 can offer, then because 25 and 38 don't have a common divisor, the easiest is to build two separate XOs and either switch between them using a mux, or design them to have tri-state outputs and complementary OE's so only one outputs at a time.  The XO's could produce say N*25kHz and N*38kHz, then you divide the selected output by N.  (Crystals and oscillators in the MHz are a lot more common than tens of kHz.)  Find an N that will work.  At these frequencies the oscillators can simply be based on a couple of inverters each from the same 'HC04 plus a pair of load caps per XO.
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3383
  • Country: us
Re: switch between 2 oscillators?
« Reply #10 on: March 26, 2016, 08:33:03 pm »
7.6MHz crystals are readily available...
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #11 on: March 26, 2016, 08:39:32 pm »
If you need accuracy and stability better than what a 555 can offer, then because 25 and 38 don't have a common divisor, the easiest is to build two separate XOs and either switch between them using a mux, or design them to have tri-state outputs and complementary OE's so only one outputs at a time.  The XO's could produce say N*25kHz and N*38kHz, then you divide the selected output by N.  (Crystals and oscillators in the MHz are a lot more common than tens of kHz.)  Find an N that will work.  At these frequencies the oscillators can simply be based on a couple of inverters each from the same 'HC04 plus a pair of load caps per XO.

 Been into electronics for a couple days! You speak mad science! My grasp lacks thoroughly!
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #12 on: March 26, 2016, 09:02:24 pm »
I'll probably need 25khz and 38khz oscillations. Hopefully very square, and as near 50% duty as possible.
Have your requirements changed because that's totally different. A 555 and MOSFET to switch a capacitor in/out of the circuit would work but it isn't as accurate as a crystal. The divider method won't work for 25kHz &38kHz because they're not even multiples of one another.

 Can't... That's the actual output I need!
But you haven't given any indication of the desired tolerance, accuracy or stability which is pretty important for selecting an oscillator.
7.6MHz crystals are readily available...

Yes, you're better off going higher and dividing down.

The CD4060 could be used with a 7.6MHz crystal would give 950kHz on the Q3 output, which could then be divided by 38 or 25, to get 25KHz or 38kHz respectively.
If you need accuracy and stability better than what a 555 can offer, then because 25 and 38 don't have a common divisor, the easiest is to build two separate XOs and either switch between them using a mux, or design them to have tri-state outputs and complementary OE's so only one outputs at a time.  The XO's could produce say N*25kHz and N*38kHz, then you divide the selected output by N.  (Crystals and oscillators in the MHz are a lot more common than tens of kHz.)  Find an N that will work.  At these frequencies the oscillators can simply be based on a couple of inverters each from the same 'HC04 plus a pair of load caps per XO.

 Been into electronics for a couple days! You speak mad science! My grasp lacks thoroughly!
The idea is to generate a higher frequency, then divider it by a fixed number, using a counter.

A counter can be used to divide the frequency of a train of pulses. For example, if a counter circuit is designed to be reset when the total reaches 25, then the it will go to zero every 25 pulses and the output will be 1/25 of the input frequency.
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #13 on: March 27, 2016, 07:36:00 am »
I'll look into all the options you guys mentioned. That ltc1799 is looking good!
At this point I can only guess my tolerances. From the few tests I was able to do, 3% out of spec seems to still work!
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #14 on: March 27, 2016, 10:45:17 pm »
I'll look into all the options you guys mentioned. That ltc1799 is looking good!
At this point I can only guess my tolerances. From the few tests I was able to do, 3% out of spec seems to still work!
Can we see the bigger picture? What are you trying to do with the 25kHz and 50kHz squarewaves?
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #15 on: March 28, 2016, 11:40:47 am »
I'll look into all the options you guys mentioned. That ltc1799 is looking good!
At this point I can only guess my tolerances. From the few tests I was able to do, 3% out of spec seems to still work!
Can we see the bigger picture? What are you trying to do with the 25kHz and 50kHz squarewaves?

 That would be 25khz and 38khz (possibly up to 56khz if it turns out to be required). I'd like to drive ir leds. If possible, high powered ones, with some sort of mosfet amp.
 Nonetheless, I'm very interested in learning different approaches!
Right now, the harware part feels very enticing. Brings me back 25 years, when legos where the best thing ever! So, I ordered most of the parts you guys mentioned, to try later on.
There's probably a simpler way to output these oscillations with arduino or something similar. But I can't even start to understand a thing about programming.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #16 on: March 29, 2016, 07:42:47 pm »
What do you want to do with the IR LEDs?
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19523
  • Country: gb
  • 0999
Re: switch between 2 oscillators?
« Reply #17 on: March 29, 2016, 09:49:47 pm »
Let me guess, TV remote jammer? lol
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #18 on: March 31, 2016, 01:46:56 am »
Not rly... A jammer, yes, but for a very different system, at a very different scale.
 

Offline grouchobyte

  • Regular Contributor
  • *
  • Posts: 244
  • Country: cn
Re: switch between 2 oscillators?
« Reply #19 on: March 31, 2016, 02:36:06 am »
Simplicity is the best solution

A 30 cent PIC, 10 lines of code,  no external parts. SOT23 5 pin smt package

@grouchobyte
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #20 on: March 31, 2016, 05:11:14 am »
Simplicity is the best solution

A 30 cent PIC, 10 lines of code,  no external parts. SOT23 5 pin smt package

@grouchobyte

 Absolutely. But I don't know how to program... Yet!
 I'm not just interested in making this specific device. This is a gateway for me into the electronics world. After I get this done the old fashioned way, learning some C++ is next on the list.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: switch between 2 oscillators?
« Reply #21 on: March 31, 2016, 07:23:45 pm »
Not rly... A jammer, yes, but for a very different system, at a very different scale.

Making a camera blanking hat then? To make surveillance cameras not show your image at all by swamping the video image with the light, and the switching to cover both IR lamp drive rates.
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #22 on: April 01, 2016, 08:48:18 pm »
Not rly... A jammer, yes, but for a very different system, at a very different scale.

Making a camera blanking hat then? To make surveillance cameras not show your image at all by swamping the video image with the light, and the switching to cover both IR lamp drive rates.

Now I am!

 It's a sort of jammer for an industrial site. But I must figure out a way to inject other codes in between jamming pulses. If I know how to switch between 2 oscillators, then I'll know how to switch between good, and corrupt data.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16284
  • Country: za
Re: switch between 2 oscillators?
« Reply #23 on: April 02, 2016, 07:11:53 am »
So a robustness test for an IR crane remote control then.
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #24 on: April 03, 2016, 10:48:57 am »
So a robustness test for an IR crane remote control then.

Something of the sort..
I can't say exactly what it is for. Trade secrets and whatnot...
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: switch between 2 oscillators?
« Reply #25 on: April 03, 2016, 01:49:02 pm »
Security Camera Jammer!  ;D  :-DD
(put out so much IR that the camera only see's a very bright spot and not your face)
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #26 on: April 10, 2016, 08:50:47 am »

This is the CY8CKIT-059 I mentioned (highly recommended for bench tinkering with MCU or simple digital / analog stuff)
http://www.cypress.com/documentation/development-kitsboards/cy8ckit-059-psoc-5lp-prototyping-kit-onboard-programmer-and

This week, I finally got myself into buying an arduino uno to introduce myself into the programming world... By day 2 my expectations took a dive, as I found it won't do 2 tasks at once. Well, at least not without some of that clever programming that everyone else, but me, can write. (the arduino also seems to bug out a bit even when running those default programs? What gives?)

These psoc boards look like they're more powerful. But, can I, an absolute beginner make anything out of them?

 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 988
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: switch between 2 oscillators?
« Reply #27 on: April 10, 2016, 10:12:37 am »
Stick with the Arduino if you're an absolute beginner. You will need to learn how to do this and Arduino is fine for that. That will take some time. If you're not willing to invest, get out now and do something you like better. If you're getting the hang on the Arduino, then go see PSoC - which is very nice indeed.

There is no intrinsic mechanism in the Arduino (AVR MCU) to perform multiple tasks at once (except interrupts - look into that) but it is possible to simulate that - but you have to code it. It involves keeping track of where you are with each task and executing small bits and pieces of the tasks than need to run at the same time.

There are libraries that will do this for you, but they usually introduce additional complexities of their own. I do not know any because I wrote my own (here usage example).

Hope it helps.
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #28 on: April 10, 2016, 10:47:25 am »
Ought to keep them options open, right?

Both platforms it is then. I'll keep tinkering with the arduino, as it seems like a nice device to learn some coding language.
But, if the psoc will turn schematics into reality with minimal coding involved, oh boy..... oh boy, oh boy...
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: switch between 2 oscillators?
« Reply #29 on: April 10, 2016, 11:04:31 pm »
If you really NEED to do 2 or more tasks at the SAME time, you aren't looking at an Arduino or a PSoC.  In fact, from a PC point of view, you would need a multi-core processor with a core per task.  OR...  You do the thing in parallel hardware.  The average CPLD (Complex Programmable Logic Device) can easily work on many concurrent tasks and the FPGA, well, they can do anything.  If you can imagine it, the FPGA will probably do it.  For a programmer, the most difficult thing about the transition to CPLDs or FPGA is the fact that EVERYTHING happens at the same time.  A task may be in a Do Nothing state but that condition is sampled (usually) on every clock and there can be a whole bunch of tasks.  All merrily doing their little bit or waiting for a wake up call.

What usually happens with a microcontroller is that we either write a 'super loop' that does bits and pieces of each task or we use an RTOS (Real Time Operating System) to divide up the processing power in some kind of priority scheme.  For the project, as described to date, a microcontroller with a timer that can connect to an output pin is probably all it takes.  Internally, this is hardware with the clock frequencies controlled by setting the timer register.  BTW, generate double the desired frequency so you can square it up with a flip-flop on the output.  For example, if you need to divide by 38, divide by 19 instead and divide by two with the external flop.

The problem with discussing this project is that only one small aspect has been described.  Create two carrier frequencies and switch between them.  An oscillator and some counter chips ought to do it.  But that isn't the project.   Now there is a discussion of modulating the carrier.  That's an entirely different question.  Regardless of the application, where does the modulating frequency come from?  Does the <solution> have to create it?  And so on...  It's pretty easy to underspecify the project, follow a path down a rat hole and then find out that you simply can't get there from here.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: switch between 2 oscillators?
« Reply #30 on: April 11, 2016, 02:37:48 am »
That is VERY cool!  Thanks for sharing
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #31 on: April 11, 2016, 09:16:13 am »
Fkin ace man!
 

Offline nandoanalogTopic starter

  • Contributor
  • Posts: 26
Re: switch between 2 oscillators?
« Reply #32 on: April 13, 2016, 05:22:43 pm »
While I'm waiting for more gear to arrive, I gave it a go with what I have here (555 stuff and a 4053 mux).
CanĀ“t lie, it felt pretty good seeing my first electronics project results on the oscilloscope!

 
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf