Timer555 frequency issues

Thread Starter

MishaH

Joined Feb 14, 2016
9
Hi all

Background:
- I recently built the Sunfounder advised Timer555 circuit (I have attached the circuit diagram)
- I am inputting the output pulse from the Timer Circuit into my Raspberry Pi 2B
- The Timer and corresponding code works in terms of: 1. The timer outputs the pulses and the code reads them and I can manipulate the pulses into real time data.
- I have soldered (very amateur like) the circuit onto a breadboard. to bridge some of the connections i used short, straight pieces of solid core wires.

Problem:
1. The frequency of the pulses seems to change constantly by up to 0.05Hz. Now this is sufficient to induce a massive time change.
2. I try to calibrate the Timer555 circuit against several stopwatches and over an hour the time difference can vary up to 2 minutes.

Can anyone advise me how to eliminate changes in frequency? I have tried insulating the circuit with little success (perhaps temperature is the problem)(perhaps my insulating was not good enough)

Thank you
Misha

Timer555 circuit_800x450.jpg
 

DickCappels

Joined Aug 21, 2008
10,153
Interesting -that is 3%, a huge amount of drift unless you are taking it from the oven to the refrigerator, and it sounds like you are taking care of temperature changes.

The NE55's output frequency 5 has low sensitivity to power supply voltage. That brings us to the resistors and the capacitor.

Some capacitors make very good thermal sensors, and that's ok for some applications. What kind of capacitor are you using?
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
Interesting -that is 0.3% -a huge amount of drift unless you are taking it from the oven to the refrigerator, and it sounds like you are taking care of temperature changes.

The NE55's output frequency 5 has low sensitivity to power supply voltage. That brings us to the resistors and the capacitor.

Some capacitors make very good thermal sensors, and that's ok for some applications. What kind of capacitor are you using?
Two 100nF (common ceramic capacitors - the 104 that is)
 

DickCappels

Joined Aug 21, 2008
10,153
The capacitor connected to pins 2 and 6 is suspect - do you have any film capacitors near .1 uf?

Keep in mind the cause of the apparent drift might be something else; this is just the first thing to check.
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
I have insulated the circuit now completely. It has dramatically improved sensitivity, but not eliminated it. I can at least now iterate to some point whereas before it jumped around so much iterating to some point within 5% accuracy. now i have gotten it down to 0.2-0.5% accuracy, which is still really not great.

I am really new to electronics, picked up the project 3 weeks ago, so any help is appreciated. Why is the capacitor suspect?
 

dannyf

Joined Sep 13, 2015
2,197
An RC oscillator is inherently unstable, frequency and phase wise. People are known to use them as random number generators.

Your set up makes little sense to me, however. You have a mcu that can time far more accurately and stably than your 555 can ever do. Unless you are doing something else, what you are trying to do with the 555 can be done entirely in software.
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
An RC oscillator is inherently unstable, frequency and phase wise. People are known to use them as random number generators.

Your set up makes little sense to me, however. You have a mcu that can time far more accurately and stably than your 555 can ever do. Unless you are doing something else, what you are trying to do with the 555 can be done entirely in software.
The set up (circuit) I have built is according to the Sunfounder Manual that they sent together with the kit I bought.
 

GopherT

Joined Nov 23, 2012
8,009
1. The frequency of the pulses seems to change constantly by up to 0.05Hz. Now this is sufficient to induce a massive time change.
2. I try to calibrate the Timer555 circuit against several stopwatches and over an hour the time difference can vary up to 2 minutes.
So, your base frequency is about 480Hz ad you are
(A) concerned about 0.05Hz variation in the output and,
(B) if using it as a time base, you get zero to 2 minutes variation over a one-hour window.

For (A) what accuracy do you expect from an RC timer?

For (B) what precision do you expect from same circuit?

What does the datasheet say?

The TI datasheet for NE555 says interval error is 2.25% with error define as...
2) Timing interval error is defined as the difference between the measured value and the average value of a random sample from each process run​
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
So, your base frequency is about 480Hz ad you are
(A) concerned about 0.05Hz variation in the output and,
(B) if using it as a time base, you get zero to 2 minutes variation over a one-hour window.

For (A) what accuracy do you expect from an RC timer?

For (B) what precision do you expect from same circuit?

What does the datasheet say?

The TI datasheet for NE555 says interval error is 2.25% with error define as...
2) Timing interval error is defined as the difference between the measured value and the average value of a random sample from each process run​
hmmm ok. To be embarrassingly honest I haven't checked the DataSheet. I was kind of expecting a few seconds lost a day, not several minutes an hour.

Secondly, for some unknown reason to me, the system pulses at around 730Hz. Now I made sure that the resistors and circuit are correct. I checked it several times.

Do you mean to say then that the accuracy I am seeking is unrealistic? Do I have the wrong chip/circuit for that?

I am looking for seriously accurate data, I need it for the application I intend. As said, a few seconds a day would be acceptable.
 

GopherT

Joined Nov 23, 2012
8,009
hmmm ok. To be embarrassingly honest I haven't checked the DataSheet. I was kind of expecting a few seconds lost a day, not several minutes an hour.

Secondly, for some unknown reason to me, the system pulses at around 730Hz. Now I made sure that the resistors and circuit are correct. I checked it several times.

Do you mean to say then that the accuracy I am seeking is unrealistic? Do I have the wrong chip/circuit for that?

I am looking for seriously accurate data, I need it for the application I intend. As said, a few seconds a day would be acceptable.
You do have the wrong approach. A 555 is never used for an accurate real time clock for a watch or time of day clock. You need a crystal oscillator. A few seconds per day is easily achieved.

The problem with crystal oscillators, they are not available in an infinite adjustable range of frequencies. And, they are usually available only above 250k Hz.

If you need slower pulse trains that the oscillator can provide, add a counter chip to divide down - binary counters like CD4060, cd4040 or a decade counter. You will have to add a flip flop to make your decade counter's output into a square wave if that is needed (which divides by 2 itself). A CD4060 is an interesting solution because you can directly add a 32768Hz clock crystal and it will oscillate - AND it can divide that crystal oscillator frequency by 2 many times over for you. Just select a pin with a frequency you like.
 
Last edited:

GopherT

Joined Nov 23, 2012
8,009
If you go the route of a bare crystal on the CD4060, then you should order a crystal with a specific model number and accessible datasheet so you know what sized capacitors are needed. Don't order some random ebay crystal - Eventhough it will be listed as 32768 Hz, the capacitor sizes are specified for the crystal model and it is a pain to find the right ones without the datasheet.
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
You do have the wrong approach. A 555 is never used for an accurate real time clock for a watch or time of day clock. You need a crystal oscillator. A few seconds per day is easily achieved.

The problem with crystal oscillators, they are not available in an infinite adjustable range of frequencies. And, they are usually available only above 250k Hz.

If you need slower pulse trains that the oscillator can provide, add a counter chip to divide down - binary counters like CD4060, cd4040 or a decade counter. You will have to add a flip flop to make your decade counter's output into a square wave if that is needed (which divides by 2 itself). A CD4060 is an interesting solution because you can directly add a 32768Hz clock crystal and it will oscillate - AND it can divide that crystal oscillator frequency by 2 many times over for you. Just select a pin with a frequency you like.
Cool, thank you. I have narrowed down the timing error on the 555 to between 0.2 to 0.5%. You recon that is as good as it gets?

I am working with a Raspberry Pi 2B, which if I am not mistaking cannot read on frequency levels that high, so I will have to do some research and build a new RTC.

Thank you everyone!
 

GopherT

Joined Nov 23, 2012
8,009
Cool, thank you. I have narrowed down the timing error on the 555 to between 0.2 to 0.5%. You recon that is as good as it gets?

I am working with a Raspberry Pi 2B, which if I am not mistaking cannot read on frequency levels that high, so I will have to do some research and build a new RTC.

Thank you everyone!
As mentioned earlier, why not use the real time clock in the rasberry pi? Already a crystal on oard and there are standards commands that let you access the current time - in several formats.
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
As mentioned earlier, why not use the real time clock in the rasberry pi? Already a crystal on oard and there are standards commands that let you access the current time - in several formats.
Well I tried to do that, but all research I did said that the Pi does not have an on board RTC. It said something about cost implications and permanent battery requirements. I found this weird since the one can import "time" into any script.

All I need at the end of the day is a timer that can keep track of time passed since the program was executed. I dont need day/month/year RTC.

Is the time.sleep(...) what I am looking for? how much time will be lost in processing between each time.sleep()? I guess that depends on program complexity, but is it something to worry about?

My Pi will also not be connected to a network all the time and will operate autonomously. Please excuse the ignorance, Im seriously new to all this.
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
I have googled now for the last hour, and google is being frustratingly useless and all searched lead to building RTC's.

Can anyone help me with the code that would allow me to use the on board crystal on the pi? the time.slee(...) does not work. how would I go about it?
 

GopherT

Joined Nov 23, 2012
8,009
I have googled now for the last hour, and google is being frustratingly useless and all searched lead to building RTC's.

Can anyone help me with the code that would allow me to use the on board crystal on the pi? the time.slee(...) does not work. how would I go about it?
From a command line you can use command.
>> date

To see all options, use
>> date --help

You should be able to get a format with sub-microsecond accuracy output (if I remember correctly - if not with date, there is another command but I think it is date).

If using JAVA
You can try a time increment calculation using nanotime

Code:
long startTime = System.nanoTime();// ... the code being measured ...
long estimatedTime = System.nanoTime() -  startTime;
 

Thread Starter

MishaH

Joined Feb 14, 2016
9
From a command line you can use command.
>> date

To see all options, use
>> date --help

You should be able to get a format with sub-microsecond accuracy output (if I remember correctly - if not with date, there is another command but I think it is date).

If using JAVA
You can try a time increment calculation using nanotime

Code:
long startTime = System.nanoTime();// ... the code being measured ...
long estimatedTime = System.nanoTime() -  startTime;
Im using Python2.7 on Raspbian. But I will try Date.

Thanks mills again for all your help, honestly much appretiated
 

hrs

Joined Jun 13, 2014
394
time.time() gives the number of seconds that passed since 1970. If you store it at the beginning of your program and subtract it from time.time() at any moment you will have the wall clock time in seconds since the program started to execute.
 
Top