Author Topic: Simple cheap 1Hz Oscillator - low accuracy fine  (Read 15068 times)

0 Members and 1 Guest are viewing this topic.

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Simple cheap 1Hz Oscillator - low accuracy fine
« on: September 01, 2017, 10:52:54 pm »
I've been struggling implementing a roughly 1Hz (ie. one pulse per second) oscillator as input to a CPLD for general use as a timeout function, and it's driving me crazy. The function is non-critical but would be a nice addition. Accuracy isn't important. 2MHz instead is fine, for example. An accuracy as awful as +/- 50% is tolerable. I need to keep the cost low. I have made multiple attempts at getting this working. I am on the edge of just cutting this functionality entirely due to the low value and the disproportionately large number of hours spent trying to solve it thus far. I could use some guidance and input.

I have a couple of pins and very limited resources from an existing MAX V CPLD available. It is being used to implement a timeout period for a reset function that resets a malfunctioning MCU, with the timeout being measured in seconds. As such, I can't rely on the MCU, which would make this a ten minute problem.

The CPLD has an internal oscillator in the order of 4MHz or so. I cannot spare the CPLD resources for a 22-bit counter to convert this into a 1Hz signal.

My first major attempt was to use a Schmitt Trigger Oscillator.

http://en.wikipedia.org/wiki/Schmitt_trigger#Use_as_an_oscillator

For the Schmitt Trigger, I used two CPLD pins. The input pin was configured as a Schmitt Trigger Input, and the output pin was simply the inverted value of the input. It kind-of worked, but for some reason was susceptible to other signals going through the board/CPLD. Basically, I could press a button in an unrelated part of the circuit and it would sometimes cause multiple additional pulses to be emitted. I tried several things on the CPLD to work around it, including buffering the last seen input via the internal oscillator, but it did not help.

My second major attempt was to use the output of an Astable multivibrator

https://en.wikipedia.org/wiki/Multivibrator#Astable_multivibrator

This is in place at the moment. I am using C1=C2=10uF ceramic caps and R1=R4=100k R2=R3=470k resistors. When hooked up to a buffer and a LED I am able to observe what looks like a perfect signal- on for about 3/8 second, off for 3/8 second. Unfortunately, when I try to use it in the CPLD to increment a counter (via Schmitt Trigger input, rising edge), and send that counter to external pins, the result is disastrous. Depending on the pin, I see either a steady LED, or a mostly-off LED with occasional dim pulses. I can only guess at the meaning (no oscilloscope) but if I had to guess, at least one bit of the oscillator counter is cycling rapidly and unevenly, which would suggest a very unstable oscillator input. Simulation of the VHDL code used gives perfect results, simulation of the circuit gives perfect results, but it is not behaving on real hardware. The slow rise time of the pulse should be handled by the Schmitt Trigger input, but perhaps my understanding is flawed? Perhaps my code only works in the sim? Here are the relevant bits:

Code: [Select]
  sosc: in std_logic; -- This is the input.

  ...
 
  signal soscc: unsigned(2 downto 0) := (others => '0');
  signal soscr : std_logic;
  signal soscx : std_logic;

  soscx <= (to_x01(sosc));
  soscr <= (something that will be '1')

  ...
 
  uxo(0) <= std_logic(soscc(0)); -- Lit LED
  uxo(1) <= std_logic(soscc(1)); -- Dim light pulsing LED
  uxo(2) <= std_logic(soscc(2)); -- Dim light pulsing LED
  uxo(3) <= soscc(0); -- Lit LED
  uxo(4) <= soscc(1); -- Dim light pulsing LED
  uxo(5) <= soscc(2); -- Dim light pulsing LED
  uxo(6) <= soscx; -- Visually fine. 3/4 second blinking.
  uxo(7) <= sosc; -- Visually fine. 3/4 second blinking.
 
  ...
 
  process(soscx, soscr) is
  begin
   if soscr = '0' then
      soscc <= (others => '0');
    elsif rising_edge(soscx) then
      soscc <= soscc + 1;
    end if;
  end process;

My fallbacks are: (i) remove all functionality relying on it from the CPLD and put it on the MCU, and drop the emergency reset functionality; or (ii) use a 555 timer for the sole purpose of producing a 1Hz output (I haven't done this before, but it sounds easy).

Input welcome and really needed.
« Last Edit: September 02, 2017, 09:18:34 pm by GarthyD »
 

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #1 on: September 02, 2017, 01:11:45 am »

Thankyou for your thoughts. Firstly, a quick note: I'm quite fine with the software side of things but only an electronics novice, so I do struggle with some electronic concepts. Even finding potential oscillators was a struggle.

On the signal integrity front: I'm prototyping on a breadboard with wires so the quick answer to that is that it is probably riddled with signal integrity issues. Still, we're looking at 1Hz not 1MHz+. But then again I'm using up to 470k resistors to get the required timing, so perhaps that is going to limit me here. EDIT: On breadboard only until it becomes a real PCB, this is the next iteration of an existing design.

Thankyou for the various ideas you have given to further diagnose the problem. Some I am having trouble following due to my inexperience, but it has also given me a few ideas. Thankyou.

No oscilloscope?   How many hours did you spend debugging JUST THIS PROBLEM?  Several?  You know you can get new scopes for like $200 and used ones more like free for hauling away.  What is your time worth?

I understand and agree with your point. Point me toward a DeLorean and I'll pick up an oscilloscope and other kit on my way back. Had I known in advance the time I'd waste on diagnosing this problem I'd have come out ahead if I'd purchased a new oscilloscope first.

I don't know enough about oscilloscopes to not get ripped off when purchasing one secondhand, but I'd love a dirt-cheap secondhand low-end one. Unfortunately the ability to make an informed purchase on a low-end secondhand oscilloscope is probably held mostly by those who no longer need one.

Of course availability and economic feasibility do depend on your region and personal circumstances. 

Indeed it does. My present finances dictate that I need to prioritise purchases carefully. The problem however has annoyed me enough that I'm considering getting one anyway. It's not the first time one would have helped, but it is the first time I've wasted so much time on a problem that I may have been able to avoid with an oscilloscope.

But you say the solution has to be low cost which implies a commercial volume production interest so in such a case, again, what is your engineering time worth such that you can't have a simple oscilloscope? 

Re low cost: Development of a low volume prototype which is a second iteration of a design that might be produced in larger volumes in the future, and I'd like the fundamentals of the design to be similar. The result is beneficial and a nice feature but ultimately of low importance and on the edge of getting cut. This leads to the low cost goal. That's the short version.

74HC4060

Seems to be pricier than a 555 but could be a good backup in case I'm wrong about the 555.

74LVCU04

Approaching 555 costs but needs more board space. :(

32kHz

Considered that approach. Would still need about 15-bits to get this to down to 1Hz. There just aren't enough bits left. :(

...

One thing I am wondering is if there is perhaps a design that would fit my problem better than the two I have been experimenting with? Or am I headed in the right direction, I just need to find and eliminate the issues I am encountering?

Update: I hooked the CPLD oscillator input pin up to a button instead of the oscillator and manually inserted some pulses by just pressing and releasing the button. The counter outputs started working perfectly. It's down to whatever is happening at the output of the oscillator and the input to the CPLD. I'm guessing if I could see this on an oscilloscope it'd be a complete mess.

« Last Edit: September 02, 2017, 01:46:07 am by GarthyD »
 

Offline Old Don

  • Regular Contributor
  • *
  • Posts: 163
  • Country: us
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #2 on: September 02, 2017, 01:35:06 am »
How about a cheap as chips Chinese watch module - one pulse per second/1Hz for the second hand?
Retired - Formerly: Navy ET, University of Buffalo Electronic Tech, Field Engineer and former laptop repair business owner
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12297
  • Country: au
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #3 on: September 02, 2017, 01:52:42 am »
Personally, if deriving the 1Hz from the existing circuitry is in any way problematic, I would have gone for the 555 timer option.

The 555 is ubiquitous.  It is used in all manner of equipment and has been found on some pretty significant boards - not just a beginners breadboard.  You only need the 555, 2 resistors and a capacitor to get it working - plus another capacitor on the "control" pin, just to bypass any spurious signals.

Yes, they are easy to use, are very flexible and do a great job.  It is probably the first IC many beginners start playing with.  There is even a publication called the 555 Timer Cookbook ... which is all about that little chip.
« Last Edit: September 02, 2017, 01:56:18 am by Brumby »
 
The following users thanked this post: GarthyD

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #4 on: September 02, 2017, 01:55:20 am »
How about a cheap as chips Chinese watch module - one pulse per second/1Hz for the second hand?

An interesting idea. If there was a part from a reputable manufacturer that I could purchase, yes. Otherwise, definitely not. Low accuracy is fine, low reliability is not.


 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12297
  • Country: au
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #5 on: September 02, 2017, 02:00:25 am »
To show you how easy they are to use - I came across this short video.

Be prepared, though.  If you have any respect for an analogue multimeter, this is cringeworthy....



If he can do that to a meter, his skills aren't refined.
 

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #6 on: September 02, 2017, 08:04:01 am »

Personally, if deriving the 1Hz from the existing circuitry is in any way problematic, I would have gone for the 555 timer option.

The 555 is ubiquitous.  It is used in all manner of equipment and has been found on some pretty significant boards - not just a beginners breadboard.  You only need the 555, 2 resistors and a capacitor to get it working - plus another capacitor on the "control" pin, just to bypass any spurious signals.

Whilst I've never used a 555 myself (I jumped straight to microcontrollers), I have read a fair bit about them, and they seem very versatile, and quite applicable to this sort of problem.

Yes, they are easy to use, are very flexible and do a great job.  It is probably the first IC many beginners start playing with.  There is even a publication called the 555 Timer Cookbook ... which is all about that little chip.

They do sound very interesting. If higher accuracy were my priority, or if this was feeding into something more substantial, I would probably have started with one.

Be prepared, though.  If you have any respect for an analogue multimeter, this is cringeworthy....

That poor multimeter. :(

...

Now, some news:

Bad news: I've just discovered that the cheaper 555 ICs I've seen run on 5V. I should have mentioned in my original post that the part of the circuit I'm hooking this up to runs on 3.3V I/O. Sorry for not mentioning this before. It seems that 555s that are fine with 3.3V cost at least twice as much. :(

Good news: I hooked the emitter of the right transistor to the base of another transistor instead of ground, emitter to ground, and collector to: (i) the oscillator input pin, (ii) a strong (1k) pullup to VCC, and (iii) a 100nF cap. The idea is that the clock input drives a transistor that pulls the input pin down to ground, and otherwise lets it be pulled up to VCC. The cap slows transitions. Being behind a transistor stops it messing with the main circuit. The counter is now functioning reasonably reliably. Sans oscilliscope, I'm doing this blindly and just guessing values, but it seems to be working. It is also probably very wasteful, but I haven't measured it.

I'll have to weigh up my options re this functionality. I'm having some serious second thoughts re the unexpected difficulty in getting something cheap and simple going. I am uncertain as to the best way to proceed.

 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #7 on: September 02, 2017, 11:13:29 am »
Have you considered a Schmitt Trigger oscillator based on a single gate chip?
Something as this: SN74AHC1G14, 2-5.5V, SOT23 so not incredibly small to hand solder.

At about 10 cent apiece even in smallish quantities (in EU e.g. on RS, don't know in AU), you just need to add a couple of passives (possibly three, if we include a decoupling cap)..

Any 555 will be more expensive, require more PCB real estate and more passives.

Of course, if the problem is signal integrity, this might not be the right cure.
Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: GarthyD

Offline Ash

  • Regular Contributor
  • *
  • Posts: 161
  • Country: au
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #8 on: September 02, 2017, 01:25:11 pm »
Hi,

Have you considered any of the microprocessor supervisor ICs, commonly called watchdogs? you don't describe the timeout you're trying to detect, but you might be able to directly apply a watchdog chip. They are the classic implementation for detecting wonky micros...

A very quick search found STWD100 from ST - this comes in a few (fixed) timing varieties, but more interestingly has a mode where you can have it constantly re-triggering which could give you a single part low frequency oscillator. Just an idea and probably not fully baked..

Not the cheapest solution probably though at about $1, but I'm sure there are many other options..

Ash.
 
The following users thanked this post: GarthyD

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #9 on: September 02, 2017, 01:48:02 pm »
Another idea: If your design needs a real time clock, many RTC chips have a 1Hz output option.
 
The following users thanked this post: GarthyD

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #10 on: September 02, 2017, 03:10:59 pm »
Have you considered a Schmitt Trigger oscillator based on a single gate chip?
Something as this: SN74AHC1G14, 2-5.5V, SOT23 so not incredibly small to hand solder.

At about 10 cent apiece even in smallish quantities (in EU e.g. on RS, don't know in AU), you just need to add a couple of passives (possibly three, if we include a decoupling cap)..

Any 555 will be more expensive, require more PCB real estate and more passives.

Of course, if the problem is signal integrity, this might not be the right cure.
I agree. That would be what I would have suggested too. If a buffered output is required, then there's a two gate variant, which doesn't take up much more room and only costs a little more.

https://assets.nexperia.com/documents/data-sheet/74HC_HCT2G14.pdf
« Last Edit: September 03, 2017, 08:15:22 am by Hero999 »
 
The following users thanked this post: GarthyD

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19470
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #11 on: September 02, 2017, 03:38:41 pm »
Still, we're looking at 1Hz not 1MHz+.

I will assume you have good quality decoupling. If you are using solderless breadboards, then it is traditional that you will spend more time debugging the breadboard than your circuit.

The period (1s) is almost irrelevant from a signal integrity PoV. What does matter is the rise/fall time, which is probably 1ns or so. Realise that a traditional rule-of-thumb is BW=0.35/tr, and you will start to understand.

Back of envelope calculations...

Work out the capacitance, C, that an output is driving through voltage V. Work out the transition time, t. The current required to charge/discharge the capacitor is i = CV/t (from C V = Q = i t, ignoring exponential voltage rise)

Wires are inductors; assume 1nH/mm and work out the inductance in a ground or Vcc lead, L.

The voltage induced by the current spike charging/discharging the capacitor is v = Li/t (from v= Ldi/dt). That voltage appears in series with the signals on inputs.

Don't forget that you will probably be having several outputs changing simultaneously, which increases i and v :)
« Last Edit: September 02, 2017, 03:42:05 pm by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: GarthyD

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #12 on: September 02, 2017, 11:14:52 pm »
Have you considered a Schmitt Trigger oscillator based on a single gate chip?
Something as this: SN74AHC1G14, 2-5.5V, SOT23 so not incredibly small to hand solder.

Yes. I did consider using a separate IC for the Schmitt Trigger for my first attempt, but I didn't have one on hand. :} I thought I'd start out using a couple of CPLD pins due to the integrated optional Schmitt Triggers on inputs. That really didn't turn out well, so going back to a single-gate Schmitt trigger could make it more workable. I could pop a SN74AHC1G14 on a small breakout, solder the resistor and cap directly on top, and probably avoid most of the breadboard-related issues I'm running into. The big plus is that I can control the layout of a separate IC, as opposed to in the CPLD where I can't help that there are either going to be wires (when breadboarding) or traces (when on a PCB) that are going to be positioned fairly close to what I imagine to be a very low current signal coming in. Thanks for the suggestion.

At about 10 cent apiece even in smallish quantities (in EU e.g. on RS, don't know in AU), you just need to add a couple of passives (possibly three, if we include a decoupling cap)..

Mostly around 30c or so in smallish quantities, which seems to be the price point of a lot of the simpler ICs.

Of course, if the problem is signal integrity, this might not be the right cure.

I could well run into similar problems as my first attempt, and I'd be diagnosing them blind until I can get my hands on an oscilloscope. Or it could work perfectly. I'll likely get one to experiment with.

you don't describe the timeout you're trying to detect,

Sorry about that.

The driving need is an emergency reset, which is for when the attached components (including MCU) get into an unrecoverable state. The idea is that you hold down all of the buttons for a few seconds, and it forces a reset. The "few seconds" bit is driving the need. My thinking was that it would also be useful for controlling anything else that requires long presses, timeouts, or similar.

On the other hand, when the MCU is working fine, which it will be most of the time, all of this logic except the emergency reset can be done far more easily on the MCU. So on the other side of the equation is me questioning how essential this functionality even is, and if I should drop it, and just say that if things are so bad and the MCU is so messed up that it is stuck and even the watchdog isn't kicking in, then it's time to open the case and short reset to ground or plug in the debug cable.

Have you considered any of the microprocessor supervisor ICs, commonly called watchdogs? ... but you might be able to directly apply a watchdog chip. They are the classic implementation for detecting wonky micros...

A very quick search found STWD100 from ST - this comes in a few (fixed) timing varieties, but more interestingly has a mode where you can have it constantly re-triggering which could give you a single part low frequency oscillator. Just an idea and probably not fully baked..

Not the cheapest solution probably though at about $1, but I'm sure there are many other options..

It's an interesting idea with additional benefits. I like the idea of cheating and using the reset signal as a clock source, that is very clever. :) Thanks for that.

Another idea: If your design needs a real time clock, many RTC chips have a 1Hz output option.

That's something I was considering as well, but the price was an issue. Unfortunately I would have no use for an RTC chip in this case as the MCU I am using has one included. On the other hand, if the MCU did not include one, this would be a superb addition as an RTC clock is a neat thing to include and such an IC would give me that plus a 1Hz signal. Thanks for that. :)

I agree. That would be, what I would have suggested too. If a buffered output is required, then there's a two gate variant, which doesn't take up much more room and only costs a little more.

I agree. That would be, what I would have suggested too. If a buffered output is required, then there's a two gate variant, which doesn't take up much more room and only costs a little more.

https://assets.nexperia.com/documents/data-sheet/74HC_HCT2G14.pdf

Neat. :)

I will assume you have good quality decoupling.

I believe so. The CPLD and MCU in my design are on breakouts, but every power input has a cap soldered directly onto the board and attached to the closest ground. Every IC in the breadboard itself has a cap physically adjacent to the power in and a wire cut to the right length to go over the top and end adjacent to the ground.

If you are using solderless breadboards, then it is traditional that you will spend more time debugging the breadboard than your circuit.

That seems to be the general rule. :(

The period (1s) is almost irrelevant from a signal integrity PoV. What does matter is the rise/fall time, which is probably 1ns or so.

To get a 1s period I'm using some fairly large resistors (470k+), and I've tended to associate them with pending trouble when using them with breadboards, even if I don't completely understand the cause.

If I'm understanding correctly, the rise and fall time for the first solution I used should be very slow and for the second, at least when simulated, it has a slightly weird but slowish rise time (a very rounded corner), but a very fast fall time.

Realise that a traditional rule-of-thumb is BW=0.35/tr, and you will start to understand.

Back of envelope calculations...

Work out the capacitance, C, that an output is driving through voltage V. Work out the transition time, t. The current required to charge/discharge the capacitor is i = CV/t (from C V = Q = i t, ignoring exponential voltage rise)

Wires are inductors; assume 1nH/mm and work out the inductance in a ground or Vcc lead, L.

The voltage induced by the current spike charging/discharging the capacitor is v = Li/t (from v= Ldi/dt). That voltage appears in series with the signals on inputs.

Don't forget that you will probably be having several outputs changing simultaneously, which increases i and v :)

Much of this is beyond my current understanding, but I'll do some reading and try to gain enough knowledge to put this to use. Many thanks for your thoughts on this one.

...

Now, a few additional comments.

Firstly, I was somewhat tired yesterday and not firing on all cylinders, so I just wanted to add a few things to previous comments:

evb149: Thanks for all of the detail in your post, it has given me many leads to follow. I may have written off some of your chip suggestions a bit quickly as I had thought I could get a 555 for about the same price, but it turned out I was basing this on the 4.5V+ 555, which I can't use.

Old Don: Thanks for the interesting suggestion. Whilst it might not I cannot use in this case, sometimes these sorts of suggestions can lead to creative solutions.

Brumby: Thanks for all of the information on the 555 IC. I do have one buried away somewhere, and whilst I can't use it directly for this problem, I can set up a 5V playground and experiment with it, and get a 3.3V variant if I do decide I want to add it :)

I also ran into some interesting low-cost ICs while looking around:

TI CD4151B: An low-cost oscillator IC that uses two resistors and a capacitor to produce a basic signal, and then feeds that into a configurable on-chip counter (up to 16-bit) to produce the output signal. Downside is the large voltage range, size, weird startup conditions, and it's not really designed for lower voltages specifically, even if it supports them.

Micrel PL611-01: A low-cost programmable clock generator that can use a crystal or other input signal and from the looks of it *effectively* has a 13-bit counter. With a 32.768KHz crystal I could get a very accurate 4Hz signal, which is really close to what I'm after. Downside is combined cost of parts, I'm not sure it actually supports a 32.768KHz crystal, and I can't seem to find any information as to how you perform its initial programming.

This discussion has given me a lot of leads to follow and a whole bunch of information that I can use in the future, which I greatly appreciate. Thankyou to everyone who has shared their thoughts. I think the problem was a little harder and expensive (resources, parts, time) than I realised. When held up against the benefit it provides, it is hard to justify including, at least in the short-term. In the medium-term, and especially when I get some proper tools (ie. an oscilloscope), I'd like to experiment with some of the parts mentioned here, and perhaps there will be a way to integrate the results into my design.




 

Offline Beamin

  • Super Contributor
  • ***
  • Posts: 1567
  • Country: us
  • If you think my Boobs are big you should see my ba
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #13 on: September 02, 2017, 11:49:37 pm »
Would a simple multi vibrator circuit with some big electrolytics work? Like 470 or 47uf?
Max characters: 300; characters remaining: 191
Images in your signature must be no greater than 500x25 pixels
 

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #14 on: September 03, 2017, 12:10:02 am »
Would a simple multi vibrator circuit with some big electrolytics work? Like 470 or 47uf?

Thanks for the suggestion. I experimented with lower resistances and higher capacitance with electrolytics while I was setting up the multivibrator circuit, mostly so that it would oscillate slow enough for me to observe the charge/discharge cycle on a multimeter. At that point I didn't have the CPLD counter set up, but I imagine with the lower resistance the problems I encountered might be reduced. Still, sans oscilloscope I'd be running blind.
 

Offline mathsquid

  • Regular Contributor
  • *
  • Posts: 247
  • Country: us
  • I like math.
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #15 on: September 03, 2017, 12:15:44 am »
What about using a flashing LED as the signal source?
 

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #16 on: September 03, 2017, 03:05:37 am »
What about using a flashing LED as the signal source?

I can't tell if you're making a joke or if I'm missing the point. If the latter, could you elaborate?

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12852
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #17 on: September 03, 2017, 06:21:33 am »
Why not get away from all the mess of sensitive high impedance circuits and large passives and program a PIC10F200 to produce the desired signal, either from its own internal oscillator, or by dividing down whatever faster clock you have available. You cant get much smaller than a single SOT23-6 or DFN package to do the job, and they are under $0.50 each in reel quantities, even after you add in the cost of factory programming with your code, so are fairly good on the cheapness as well.
« Last Edit: September 03, 2017, 06:25:09 am by Ian.M »
 
The following users thanked this post: GarthyD, woody

Offline IanMacdonald

  • Frequent Contributor
  • **
  • Posts: 943
  • Country: gb
    • IWR Consultancy
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #18 on: September 03, 2017, 06:40:15 am »
If component count is critical, 555 with resistor from pin 3 to pins 2&6 joined, cap from there to -ve. 3 components. Gives nearly equal mark/space, which is hard to achieve with standard circuit using pin 7. Limitation (of all 555 arrangements) is that it starts on an offbeat since the cap takes extra time to charge from 0v into the working range. If it's going to run continuously not an issue though.

The astable didn't work because the component values aren't very suitable. You need much lower collector resistors. It will work with base resistors in the range 10 to 100 times higher value than the collector resistors. Also, the Vcc must be less than 6v unless you have base protection diodes.
 
The following users thanked this post: GarthyD

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19491
  • Country: gb
  • 0999
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #19 on: September 03, 2017, 08:50:54 am »
If component count is critical, 555 with resistor from pin 3 to pins 2&6 joined, cap from there to -ve. 3 components. Gives nearly equal mark/space, which is hard to achieve with standard circuit using pin 7. Limitation (of all 555 arrangements) is that it starts on an offbeat since the cap takes extra time to charge from 0v into the working range. If it's going to run continuously not an issue though.
The 74HC14 circuit also has that issue too. The solution is to use two capacitors, to both supply rails.


LTSpice simulation
 
The following users thanked this post: GarthyD, IanMacdonald

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #20 on: September 03, 2017, 09:18:31 am »
The driving need is an emergency reset, which is for when the attached components (including MCU) get into an unrecoverable state. The idea is that you hold down all of the buttons for a few seconds, and it forces a reset. The "few seconds" bit is driving the need. My thinking was that it would also be useful for controlling anything else that requires long presses, timeouts, or similar.

Are the buttons connected to the CPLD?  Can you spare enough gates for a N-input AND-gate? (N being the number of buttons)

If so, and output-pin from the CPLD, via an RC filter, back into the CPLD should do the trick, no?
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19470
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #21 on: September 03, 2017, 09:49:22 am »
Realise that a traditional rule-of-thumb is BW=0.35/tr, and you will start to understand.

Back of envelope calculations...

Work out the capacitance, C, that an output is driving through voltage V. Work out the transition time, t. The current required to charge/discharge the capacitor is i = CV/t (from C V = Q = i t, ignoring exponential voltage rise)

Wires are inductors; assume 1nH/mm and work out the inductance in a ground or Vcc lead, L.

The voltage induced by the current spike charging/discharging the capacitor is v = Li/t (from v= Ldi/dt). That voltage appears in series with the signals on inputs.

Don't forget that you will probably be having several outputs changing simultaneously, which increases i and v :)

Much of this is beyond my current understanding, but I'll do some reading and try to gain enough knowledge to put this to use. Many thanks for your thoughts on this one.

Assume C=5pF (one gate load, quite probably an underestimate), V=3V (might be 5), t = dt = 1ns (reasonable for a tp=7.5ns), L=50nH (2" of wire) in the ground lead.

Then the current spike from switching one output is around 3*5e-12/1e-9 = 15mA.
Then the voltage induced in the ground lead is 50e-9*15e-3/1e-9 = 0.75V.
So, can your circuit tolerate 0.75V spikes on the inputs, or will they cause internal logic to change state?

Don't forget that if you have more than one output changing in the same direction simultaneously, the spikes will be proportionately larger.

W.r.t. decoupling, ensure you have the right kinds of capacitor and that the leads are short and wide. Failure here will reduce the CPLD's PSU voltage, possibly causing internal state corruption.

There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: GarthyD

Offline GarthyDTopic starter

  • Regular Contributor
  • *
  • Posts: 85
  • Country: au
    • Adventures in Electronics
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #22 on: September 03, 2017, 01:22:53 pm »
Why not get away from all the mess of sensitive high impedance circuits and large passives and program a PIC10F200 to produce the desired signal, either from its own internal oscillator, or by dividing down whatever faster clock you have available. You cant get much smaller than a single SOT23-6 or DFN package to do the job, and they are under $0.50 each in reel quantities, even after you add in the cost of factory programming with your code, so are fairly good on the cheapness as well.

Thanks for the suggestion. Going the low-cost secondary MCU route is tempting, and something I have weighed up and still constantly debate with myself. I was considering an ATTINY instead both for the price and the fact that I am familiar with AVRs, but the basic idea is the same. There are pros and cons for the overall design and I would have to talk at considerable length to go through them all. If I did use one, it probably wouldn't be to generate the clock signal any more. I'd move the functionality to manage the reset process over to it instead. It might be able to absorb a number of other components on the board and support some interesting reset- and flash-time functionality. The burden would be greater on the software side, especially as there is a support library involved, but that is precisely where my experience lies. I don't want this one issue to drive this change, but it is something that if driven for the right reason, would make handling this functionality considerably easier. I've got a fair bit to think about here.

If component count is critical, 555 with resistor from pin 3 to pins 2&6 joined, cap from there to -ve. 3 components. Gives nearly equal mark/space, which is hard to achieve with standard circuit using pin 7.

Excellent, thankyou.

Limitation (of all 555 arrangements) is that it starts on an offbeat since the cap takes extra time to charge from 0v into the working range. If it's going to run continuously not an issue though.

Thanks for the heads-up. Startup glitches or weirdness shouldn't cause any issues for this particular application.

The astable didn't work because the component values aren't very suitable. You need much lower collector resistors. It will work with base resistors in the range 10 to 100 times higher value than the collector resistors. Also, the Vcc must be less than 6v unless you have base protection diodes.

Thankyou. :) Finding this sort of solid information has been difficult. I've disassembled the astable multivibrator at present so I can't try it out immediately. I quickly ran some values through the sim I'm using and it gave messy results, but after decreasing the simulation timestep it started producing a sensible output again. In any case I can't fully trust the sim here. When I next assemble it I will be using your guidance here to select more appropriate resistors. VCC will be 3.3V so I should be safe here.

...

Many thanks all for your input everyone, much appreciated. Sorry that I haven't been able to reply to it all yet, I am still working my way through it.

EDIT: stmdude: All buttons connected to CPLD, enough LEs for an AND-gate.
« Last Edit: September 03, 2017, 01:28:07 pm by GarthyD »
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #23 on: September 03, 2017, 03:24:36 pm »
EDIT: stmdude: All buttons connected to CPLD, enough LEs for an AND-gate.

Ok, cool.
So, the MAX V (in 3.3V LVTTL) needs at least 1.7V to register an IO pin as high. If you can get a pin on the CPLD to go high when all buttons are pressed, all we need is some external analog circuitry that takes (about) a second to rise from 0 to 1.7V.
This sounds a lot like an RC filter to me, and would be _a lot_ cheaper than using 555s or other chips.

I've attached a basic LTspice simulation of what I'm talking about. I have a voltage source that rises from 0V to 3.3V, an RC filter, and a graph on the output (the point between the resistor and capacitor) that you would feed back into the CPLD.

Now, there is a slight downside to this approach. There's no "reset" of the charge in the capacitor, so if the user presses the keys for 0.5s, lets go of them for a very short time, and then press them again for 0.5s, it would count as a "1"/reset.
( It does discharge/reset though, but it takes a second or two before all the energy in the capacitor has drained )

( This is also typically how you delay a reset-signal to an MCU, so that the voltage-rails can stabilize before you start executing code )
 
The following users thanked this post: GarthyD

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5869
  • Country: de
Re: Simple cheap 1Hz Oscillator - low accuracy fine
« Reply #24 on: September 03, 2017, 08:49:33 pm »
74HC4060 oscillator/divider. The RC oscillator is two resistors and a cap. Set the oscillator frequency to 16 kHz and you'll have manageable (and cheap) component values. Runs fine at 3.3 V, consumes almost no current and costs a few cents.
I challenge you to find a cheaper and easier solution.

« Last Edit: September 03, 2017, 08:57:24 pm by Benta »
 
The following users thanked this post: GarthyD


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf