Author Topic: Select clock frequency digitally  (Read 5128 times)

0 Members and 1 Guest are viewing this topic.

Offline WJHildreth

  • Contributor
  • Posts: 8
Select clock frequency digitally
« on: May 26, 2015, 10:07:28 pm »
Hello all,

I am kinda a newbie and I have a problem I cannot figure out.

I have made a clock generator with a 555 timer in astable mode.  The input has a 5 different capacitors that can be selected by a rotary switch, by connecting the capacitor to ground.

What I would like to do is use a push button (that has been debounced) (done) to feed a 0 - 4 counter (done) as the input of a 3-8 decoder.  ( I am only using the first five outputs)

I would like to use the output of the decoder to switch the sleceted capacitor of the clock generator to ground.  I have tried the following without much success:

1) I tried using the low state of the decoder to attach the cap to ground, but the output of the clock is affected.

2) I used the output of the decoder to drive a NPN BJT as a switch to connect the cap to ground and still have a distorted clock output.

My next attempt is to use an op amp as a buffer to connect it to ground.  I have to order some op amps to try it, but before I do, will this work?

I know that I could use a BJT to switch on a relay, but it seems to me that I should be able to do it without mechanical switches.  Anyone have a suggestion?

Regards,

Joe
 

Offline hugo

  • Regular Contributor
  • *
  • Posts: 117
  • Country: ca
Re: Select clock frequency digitally
« Reply #1 on: May 26, 2015, 11:50:52 pm »
Hi,

You could also use a microcontroller for cap selection ... take a look at this EPE project with MAX038 here:

http://elektron.uw.hu/elektro/PIC/freq_gen/freqgen.pdf
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 1252
  • Country: us
Re: Select clock frequency digitally
« Reply #2 on: May 27, 2015, 12:18:08 am »
You could also use a ULN2003A which has open collector outputs to ground the capacitor(s) you want to select.  The ULN2003A is designed for TTL inputs and has 7 driving circuits.  You would connect it to the output of your 3-8 decoder and the lower side of each capacitor.

Alternately, you could use any open-collect logic chip to pull the selected capacitor low.  But, you would need to check the current capabilities of the outputs.
 

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 861
  • Country: ca
Re: Select clock frequency digitally
« Reply #3 on: May 27, 2015, 12:30:55 am »
What about a 4051 or 74HC4051?  That would do both your decoding and cap switching perhaps?

 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #4 on: May 27, 2015, 06:04:42 pm »
I just wanted to say thank you for the responses so far.

I think a micro-controller isn't doable for me because I don't have a programmer.  I did save the article though.  Maybe I can build one sometime.

The other two options may be more helpful to me.  But this brings a couple more questions to mind that maybe you can let me know if I am clear on.

The 555 timer circuit that I built has a 1K - 20K (pot) - 1K resistor in series from Vs (5v) to the positive side of 5 capacitors in parallel (0.01uF, 0.1uF, 1uF, 10uF and 100uF) the other end is switched to ground to select a range of frequencies for the output.  The 20K potentiometer gives a way to adjust the frequency band for a selected capacitor.

So am I right in the following statement:

Maximum current when a fully discharged capacitor is switched to ground will be 5V / 22k ohms = 0.000227273 A or roughly 227uA

Given that, I should be able to source the current with just about any TTL chip, correct?

When I tried that, looking at the output of the 555, (if I remember correctly) had some sort of sine wave embedded on the clock signal.  My test was using a 2-input NAND (7400) gate with one input wired high and the other input wired to a switch.  The output of the NAND was wired to the negative lead of the capacitor.  When I send a HI to the second input of the NAND and get a LOW on the output, I would expect the chip to sink the charge current of the capacitor.  I think the capacitor discharging is what was messing up my signal. (I really don't know).

My next try was to use a 2N3904 (or equivalent)  The output of the gate went to a resistor.  The other end of the resistor went to the base.  I also added a resistor from the base to ground.  Emitter was connected to ground and the capacitor was connected to the negative lead of the capacitor.  When the BJT was turned on, I had basically the same problem as just using the gate.

Isn't this last example an Open Collector out?  Would using a gate with an OC out be any different?

Perhaps I done something wrong in my experiments.  I will go to the proto-board and try again.  This time I will capture some of the waveforms with my scope of the outputs and attach them so you can see what I am seeing. 

Again, from your suggestions, it sounds like I should be able to switch the caps to ground pretty easily.

Thanks for your suggestions and patience with this old newbie!

Regards,

Joe
 

Offline bson

  • Supporter
  • ****
  • Posts: 1541
  • Country: us
Re: Select clock frequency digitally
« Reply #5 on: May 27, 2015, 07:38:48 pm »
What frequency range and stability, jitter bounds?  A PIC can make a perfectly acceptable single-chip clock source, or timing generator in general.  Costs a few dollars and comes in whatever package is convenient.  Interfaces with I2C, SPI, a 4-bit data bus, or even USB and can store settings in EEPROM for standalone operation.
 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #6 on: May 27, 2015, 10:22:20 pm »
bson,

Thanks for the info.  I have not touched a PIC in nearly 15 years.  I didn't realize they were still in use.  I dabbled in electronics then but I am amazed how much I forgot.  I may just have to get into micro-controllers again.  Where and how much are the programmers for the PIC?

On my current issue, I tried the OC 2N3904 again and it worked fine.  I must of had a bad connection or something.  I since relocated my desk that I do my experiments on, so maybe moving things around resolved a connection issue.  My breadboards are 15+ years old and have had a lot of use.  Maybe it's time to get some new ones.

Thanks everyone for your help and suggestions.

Joe
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 1252
  • Country: us
Re: Select clock frequency digitally
« Reply #7 on: May 28, 2015, 12:13:31 am »
Glad to hear you have it working Joe.

If you want to play with PIC microcontrollers, you can get a PICkit from Mouser or Digikey for a little under $50.  Dave did a video on them here: http://www.eevblog.com/2009/10/21/eevblog-39-pickit-3-programmerdebugger-review/.  I bought a PICkit 2 and it works very well but can't do the newest microcontrollers.  If I had to do it all over, it's a toss up which I would get.  I've been using MAPLAB X and the XC compilers from Microchip.  I don't think much of them but they get the job done so far.

You may want to consider the Arduino route too.  Especially with Visual Micro plugin available for MS Visual Studio and Atmel Studio.  I haven't had the time to explore any of the Arduinos.  Maybe some one else can help you there.

As far as generating a clock with a PIC, you might consider an AD9833 Programmable Waveform Generator with a SPI interface to a microcontroller.  It will give you much more flexibility in frequency selection.

 

Online Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4294
  • Country: us
  • KE7GKP
Re: Select clock frequency digitally
« Reply #8 on: May 28, 2015, 12:27:49 am »
Not to put too fine a point on it, but this is 2015 and digitally selecting capacitors for a 555 oscillator seems remarkably retro.
You can get Arduino clones for <$5, the development environment is free for the downloading, and it is very well supported.
You didn't state what your range of selected frequencies is, but you could either have the Arduino generate the frequency directly,
or you could use it to control something like the DS1077 ($3) which can generate frequencies from 16 KHz to 133 MHz.

https://www.sparkfun.com/products/9089
 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #9 on: May 28, 2015, 05:31:50 am »
Mr. Crowley,

I agree with you it is a bit retro.  But more modern than the relay full adder I made.  I am just goofing off with this project and it really isn't intended to be of any real practical use.  It is more of a see if if can do it.  I have coded and used my son's arduino and I will admit, a micro controller would make things easier.

This is just playing around refreshing my memory before I start a 6510 based homebrew computer project.  Which i will use diode roms as a Hex decoder.

Probably all has to do with my age (47) and clinging to the old days.  :-)

By the way, the frequencies range from 5Hz to 100 Khz more or less.

Laus Deo Semper,

Joe


 

Online Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4294
  • Country: us
  • KE7GKP
Re: Select clock frequency digitally
« Reply #10 on: May 28, 2015, 05:41:56 am »
Probably all has to do with my age (47) and clinging to the old days.  :-)

I've got 20 years on you and I am quite happy to put the bad old days behind me.  There is so much more exciting stuff we can do with modern technology, I don't have time to fool around in the past.  The transistor was invented less than 1 year before I was born and I am quite happy to have bypassed most of the "fire-bottle" era.  There are more transistors in your mouse than there were in the entire planet when I was born.

I work in a place where we are developing the next 3~5 generations of the most complex products ever produced by humans. Chances are you have one of our chips in the computer you are reading this on.
 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5549
  • Country: us
Re: Select clock frequency digitally
« Reply #11 on: May 28, 2015, 05:53:49 am »
I work in a place where we are developing the next 3~5 generations of the most complex products ever produced by humans. Chances are you have one of our chips in the computer you are reading this on.

I didn't know you moved to IBM ;)




I kid, I kid!
 

Online Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4294
  • Country: us
  • KE7GKP
Re: Select clock frequency digitally
« Reply #12 on: May 28, 2015, 06:07:58 am »
I didn't know you moved to IBM ;)
Quote
..., IBM and GlobalFoundries have inked a deal in which GF will take over IBM’s chip manufacturing facilities. IBM is paying GlobalFoundries around $1.5 billion in cash to take the loss-making unit off its hands.
http://www.extremetech.com/computing/192430-ibm-dumps-chip-unit-pays-globalfoundries-1-5-billion-to-take-the-business-off-its-hands
How the mighty have fallen.
 

Offline Paul Moir

  • Frequent Contributor
  • **
  • Posts: 861
  • Country: ca
Re: Select clock frequency digitally
« Reply #13 on: May 28, 2015, 06:17:30 am »
Just to make sure, you got that the CD4051/74HC4051 are analog muxes, not digital right?  So the outputs aren't TTL.  They're analog switches.  They are digitallly selectable however, so this works with your counter directly.

OTOH it's hilarious what you can buy these days.  My favorite is the ATTINY13A which comes in an 8 pin DIP package like the 555.  Amazingly useful little microcontroller for less than $2 each.  They can use an internal oscillator & reset so they work with just a bypass capacitor.

« Last Edit: May 28, 2015, 06:22:47 am by Paul Moir »
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 1252
  • Country: us
Re: Select clock frequency digitally
« Reply #14 on: May 28, 2015, 07:14:24 am »
Mr. Crowley,

I agree with you it is a bit retro.  But more modern than the relay full adder I made.  I am just goofing off with this project and it really isn't intended to be of any real practical use.  It is more of a see if if can do it.  I have coded and used my son's arduino and I will admit, a micro controller would make things easier.

This is just playing around refreshing my memory before I start a 6510 based homebrew computer project.  Which i will use diode roms as a Hex decoder.

Probably all has to do with my age (47) and clinging to the old days.  :-)

By the way, the frequencies range from 5Hz to 100 Khz more or less.

Laus Deo Semper,

Joe

Talking about the good old days...  I'm 59 and my first computer was the Apple II+.  My first experience was interfacing it to my HO Model Railroad.  I generated a PWM waveform to control the engine slow speed in assembly language.  It was a great learning experience since the Apple card slots provided a direct interface to the processor data and address buses.  Ultimately it was too slow with 5 Hz being the highest frequency I could generate.  The engines had the slow start response I wanted but they shook side to side.  I'm now using pic16f876 microcontrollers with 200 Hz waveforms which is much better.

 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1810
  • Country: us
Re: Select clock frequency digitally
« Reply #15 on: May 28, 2015, 09:45:52 am »
I'm an old guy and worked with the 555's when they first came out.  Maybe that's why I never want to work with them again.
 

Online Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4294
  • Country: us
  • KE7GKP
Re: Select clock frequency digitally
« Reply #16 on: May 29, 2015, 04:36:40 pm »
NCD2100: Non-Volatile Digital Programmable Capacitor
http://www.ixysic.com/products/progcap.htm

 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7198
  • Country: us
    • SiliconValleyGarage
Re: Select clock frequency digitally
« Reply #17 on: May 29, 2015, 05:26:43 pm »
Hi,

You could also use a microcontroller for cap selection ... take a look at this EPE project with MAX038 here:

http://elektron.uw.hu/elektro/PIC/freq_gen/freqgen.pdf
you could also toss the 555 and use a fractional-n synthesizer.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #18 on: June 01, 2015, 04:17:03 pm »
Just to make sure, you got that the CD4051/74HC4051 are analog muxes, not digital right?  So the outputs aren't TTL.  They're analog switches.  They are digitallly selectable however, so this works with your counter directly.

OTOH it's hilarious what you can buy these days.  My favorite is the ATTINY13A which comes in an 8 pin DIP package like the 555.  Amazingly useful little microcontroller for less than $2 each.  They can use an internal oscillator & reset so they work with just a bypass capacitor.

Sorry for the long delay, have been slammed with work and honey do's.

Yes I did understand that they were analog muxes.  I wrote that part down in my notebook. 

Additionally, I will look into getting into some micro-controllers.  Thanks for the pointers and part numbers!  I appreciate it.

Joe
 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #19 on: June 01, 2015, 04:24:44 pm »
MarkF

Quote
Talking about the good old days...  I'm 59 and my first computer was the Apple II+.  My first experience was interfacing it to my HO Model Railroad.  I generated a PWM waveform to control the engine slow speed in assembly language.  It was a great learning experience since the Apple card slots provided a direct interface to the processor data and address buses.  Ultimately it was too slow with 5 Hz being the highest frequency I could generate.  The engines had the slow start response I wanted but they shook side to side.  I'm now using pic16f876 microcontrollers with 200 Hz waveforms which is much better.

Funny you should mention that.  I remember making a pulse width modulator into a base of a power transitor with some RC circuit for inertia to run a train.  A little jerky but served the purpose.  At about the same time I started the interface with a C64 using a book from Bruce Chubbs.  That was a while ago.

These days, I do computer networking for a living and cast metal and do CNC woodwork for hobby.  I just had an itch to make a 6510 based computer for the heck of it.  I thought this little project would help to serve to dust off the grey matter before I started that project.

I think that doing this CPU project with my son, would give him some great insight to how computers work and how to interface without going more retro and building a CPU from TTL chips.

I appreciate all you folks being patient with me and offering the help.  Wish this was around when I was trying to learn in the first place.  But then again, it is here now so that's good too.

Joe
 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #20 on: June 01, 2015, 04:26:05 pm »
NCD2100: Non-Volatile Digital Programmable Capacitor
http://www.ixysic.com/products/progcap.htm



Thank you sir.

Joe
 

Offline WJHildreth

  • Contributor
  • Posts: 8
Re: Select clock frequency digitally
« Reply #21 on: June 01, 2015, 04:28:22 pm »
Hi,

You could also use a microcontroller for cap selection ... take a look at this EPE project with MAX038 here:

http://elektron.uw.hu/elektro/PIC/freq_gen/freqgen.pdf
you could also toss the 555 and use a fractional-n synthesizer.

Well, I will lay my ignorance in the line here.  I don't know what a fractional-n synthesizer is.  Looks like I will have to google that up!

Joe
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf