Select clock frequency digitally - Page 1
Forum section: electronics / beginners

author: WJHildreth
author_rank: Newbie
timestamp: May 26, 2015, 10:07:28 pm
content: 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

author: hugo
author_rank: Regular Contributor
timestamp: May 26, 2015, 11:50:52 pm
content: 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

author: MarkF
author_rank: Super Contributor
timestamp: May 27, 2015, 12:18:08 am
content: 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.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: May 27, 2015, 12:30:55 am
content: What about a 4051 or 74HC4051? That would do both your decoding and cap switching perhaps?

author: WJHildreth
author_rank: Newbie
timestamp: May 27, 2015, 06:04:42 pm
content: 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 227uAGiven 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

author: bson
author_rank: Unknown
timestamp: May 27, 2015, 07:38:48 pm
content: 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.

author: WJHildreth
author_rank: Newbie
timestamp: May 27, 2015, 10:22:20 pm
content: 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

author: MarkF
author_rank: Super Contributor
timestamp: May 28, 2015, 12:13:31 am
content: 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.

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 28, 2015, 12:27:49 am
content: 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

author: WJHildreth
author_rank: Newbie
timestamp: May 28, 2015, 05:31:50 am
content: 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

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 28, 2015, 05:41:56 am
content: Quote from: WJHildreth on May 28, 2015, 05:31:50 amI'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.

author: miguelvp
author_rank: Super Contributor
timestamp: May 28, 2015, 05:53:49 am
content: Quote from: Richard Crowley on May 28, 2015, 05:41:56 amI didn't know you moved to IBMI kid, I kid!

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 28, 2015, 06:07:58 am
content: Quote from: miguelvp on May 28, 2015, 05:53:49 amQuoteHow the mighty have fallen.

author: Paul Moir
author_rank: Frequent Contributor
timestamp: May 28, 2015, 06:17:30 am
content: 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.

author: MarkF
author_rank: Super Contributor
timestamp: May 28, 2015, 07:14:24 am
content: Quote from: WJHildreth on May 28, 2015, 05:31:50 amTalking 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.

author: Seekonk
author_rank: Super Contributor
timestamp: May 28, 2015, 09:45:52 am
content: 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.

author: Richard Crowley
author_rank: Super Contributor
timestamp: May 29, 2015, 04:36:40 pm
content: NCD2100: Non-Volatile Digital Programmable Capacitorhttp://www.ixysic.com/products/progcap.htm

author: free_electron
author_rank: Super Contributor
timestamp: May 29, 2015, 05:26:43 pm
content: Quote from: hugo on May 26, 2015, 11:50:52 pmyou could also toss the 555 and use a fractional-n synthesizer.

author: WJHildreth
author_rank: Newbie
timestamp: June 01, 2015, 04:17:03 pm
content: Quote from: Paul Moir on May 28, 2015, 06:17:30 amSorry 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

author: WJHildreth
author_rank: Newbie
timestamp: June 01, 2015, 04:24:44 pm
content: MarkFQuoteFunny 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

author: WJHildreth
author_rank: Newbie
timestamp: June 01, 2015, 04:26:05 pm
content: Quote from: Richard Crowley on May 29, 2015, 04:36:40 pmThank you sir.Joe

author: WJHildreth
author_rank: Newbie
timestamp: June 01, 2015, 04:28:22 pm
content: Quote from: free_electron on May 29, 2015, 05:26:43 pmWell, 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