crystal frequency deviation, making a clock

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello :-)

I have 2 systems that needs to be "synchronous" as possible, but, without wires or wireless - system must be cheap.

The user press one switch on each system at same time at begin of the time.

We are using a 11.0592MHz crystal of 20ppm and capacitors of 5%. I made some measures and after some time we get undesirable values of deviation from each system time.

Can anyone tell me if the oscillator on ATmega8 can be calibrated (we did that before on other systems with internal RC oscillator)? Does anyone have some good ideas for we get the best "synchronous" as possible systems?

Thanks in advance.

Jorge Pinto
http://www.rockbox.org/twiki/bin...

JPCasainho,
www.Casainho.net
.Portugal

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

System clock "synchronization" really isn't possible in software. There is no practical way to soft-ware only adjust a crystal oscillator. If it is really critical, you might be able to put a varicap diode as part of the oscillator capacitance at the oscillator input and control that with a PWM, but that seems like a lot of work for very little gain and not software only.

You CAN adjust the rollover (TOP) values of timer/counters so that they are very close (one processor compared to the other). But, because these values are integers, you may not be able get them exactly equal.

You CAN run both processors off the same oscillator if they are close to each other (same board). Use one as the oscillator and feed the output signal to the second processor with its clock option fuses set to "external oscillator".

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you replace the capacitors by trimmers, you
can adjust the frequency of the XTAL a tiny bit.
How much depends on the XTAL.

Or you may use TCXOs as clock sources, depending on
the price, you can get a much better accuracy than a
normal XTAL.

Or you may use an atomic clock for each AVR
(remember: You said: as good as possible) :shock:

So: The more you invest, the more you get.

Last Edited: Tue. Mar 24, 2009 - 04:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The user press one switch on each system at same time

Quote:
after some time we get undesirable values

So what sort of synchronicity can you achieve with simultaneous button presses starting them, and how bad is "undesirable?" Is a half second close enough? A tenth? Twenty parts in 11 million?

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

20ppm - my maths may be off but I make that 1.7 seconds a day. If one had a +error and the other a -error then I guess they could go out of sync by 3 seconds a day? Is that a problem? Is there no connection between them where they could re-sync from time to time?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where I was headed, although I was soliciting more info first, was that it might be possible to monitor the mains AC and keep them within 1/50th - 1/60th of a second over the long haul. There are minor fluctuations in the cycle length, but they're adjusted (in the US, and I assume elsewhere) daily.

But the idea of two humans simultaneously pressing buttons to start synchronized processes is what has me intrigued. If they're in the same room it's crude, and if they're talking on the phone or something then it gets even better (read that as worse). Of course, if they're in the same room, why not just put that forbidden wire/wireless in there and do it right?

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Devices will run from battery, is a semaphores for cars, for constructions on roads.

Would I get better results with an 32,2768 kHz?

We were getting about 3 seconds for day. After we got a crystal of 20ppm and capacitors of 5% and we got that 2nd graph. On first graph we didn't know the tolerances of components.

On 2nd graph we are getting about 1,1 seconds a day.

Attachment(s): 

JPCasainho,
www.Casainho.net
.Portugal

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I suppose the budget excludes using GPS as a timebase. Although I did get GPS receivers for $5 each off of eBay (excluding antenna, unfortunately).

Anyway, lots of things come to mind - laser, having the guys come together every few hours and resynching, wireless...

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Whether a crystal is 20ppm 11MHz or 20ppm 32.768kHz makes no difference. 1 ppm gets you 30 seconds per year.
You have a number of options, rising in cost and performance:
-Calibrate the clock at room temperature. Basically apply a known frequency to an input on the gadget, and have the gadget measure it and store it. The gadget now knows the offset from your reference, and can compensate in software. A DS3231 or similar is suitable as reference. This will get your devices down to ~2ppm, 0.3 seconds mismatch, provided the temperature stays reasonably the same as at calibration. Otherwise it's going to get worse, as in a second or so.
-Add a DS3231 to each device. DS3231 is a TXCO, and will stay within 2ppm over reasonably wide temperature if you do the above calibration. This gets you 0.3 seconds over -10 - 50. For calibration you need a long term stable reference, such as an OCXO.
-Build your own TCXO by calibrating your gadget at multiple temperatures, and have it compensate both the offset and drift of the crystal oscillator. This gets you to 2ppm or 0.17 seconds per day, at the cost of a rather long calibration. If calibration time is cheap, this is a good approach.
-Build your own OCXO. The performance you'll get is about the same as the TCXO, it's seriously power hungry, but calibration is faster.
-Build a good OCXO. Not cheap. Buy a good ocxo, far from cheap.

Decide what you would like, and what you can live with. Then we'll make you sad. Accuracy and precision don't come cheap.

/Kasper

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are relatively low-cost (under $20US) VLF time-signal receiver modules out there. They will keep you within a few seconds total error over a long term. I would be strongly tempted to used those in an application like this. Don't know what signal coverage there is in South America, however.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks to me like what he wants is relative synchronicity, not absolute. As long as the two devices agree, it doesn't matter whether they know the "real" time terribly accurately. He's making sure traffic flow is coordinated between two endpoints of a construction zone (or something along those lines).

If this is a correct assumption, then the temperature effects should be lessened somewhat, since both devices will be subject to approximately the same temperatures. Obviously each will respond uniquely, but probably similarly.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you have line of sight, just have the master send his time to the slave on an IR laser or something.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unlike a "normal" intersection, the distance across the construction zone could be significant. This means that you need a "Both Red" interval long enough to allow all of the traffic to pass through the zone in one direction before turning the other direction Green.

It seems, therefore, that adding a few seconds to this required delay to allow for whatever margin you have decided is appropriate would be reasonable.

The real question is how often does someone re-synch them? If daily you are already done.

Since I view traffic control as "Mission Critical", and have worked with both Opticon and GPS pre-emption systems, I'd link the two units via RF, (Xbee), or put a GPS receiver on each unit.

This increases the per unit cost, but improves reliability, and decreases the chances for a significant system error, if implemented correctly.

With a wireless link the "Remote Unit" does not even need to keep time itself. All of the timing and overall control is done in the "Master Unit". The Remote Unit acknowledges each command, or Both Units go to RED until the problem is resolved.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see the OP is in Portugal, rather than South America. VLF time signals should be good, there. I mention VLF modules, not for absolute accuracy but for low cost.

Due to the requirement for traffic from one end to pass through to the other (DocJC's "both red"), the user would need to be able to set this interval. That implies some user accessibility of settings. Will suggest an idea in a moment. But, the both-red condition must be very "loose" because you can have fast or slow vehicles though the construction which means more than a few seconds, allowance. Nobody will notice an extra 5 seconds, or even 20 seconds.

Here is the idea. At construction sites, at least in the US, there are often a fair number of two way radios. Why not set up a master with a cheap piezo beeper. With a "reset" button pushed, make it beep every minute (or maybe two). Have one person put two-way radio up next to the beeper in transmit. Have a little microphone at the slaves. Person with two-way radio in receive by that module. When it hears a beep (with ITS reset button on), it resets to the nearest minute (or two or whatever). Since the accumulated error should be no more than a few seconds per day, one would only need to do this weekly. Cheap! This could also be done by just placing several units close to each other and hold down the reset buttons on all units. If you make the beep coincide with the start of one traffic cycle, that might be even better.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If this is for real cars, on real construction sites with real traffic lights I would approach this from a completely different angle:

What are the legal requirements?

What are the safety requirements? Reliability requirements?

What are the liabilities for the supplier of such a system? What for the operator of such a system? Insurance?

Do national and international standards exist for such a system? (I bet they do) Are there standardized communication protocols? Are there reserved frequencies for wireless communication between such systems?

And in the end I'd probably chicken out and use a big fat wire between them and run a heartbeat on them to detect a broken wire.

Stealing Proteus doesn't make you an engineer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tend to agree with Arnold.

This has to be a fail-safe system. Consider YOUR liabilities if this fails and vehicles are damaged and people are hurt.

They have such systems here in the US. One I went through, recently, has a classic stop light at each end. There appears to be a cable in between. It is in a remote area with one way traffic even when construction is not active (bridge being rebuilt). During the day, there are flaggers who manage the mix of traffic and construction activity. I'd be really cautious about designing such a setup.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used to have a mental list of Bad Areas for Design [tm], and this should probably be added to it. My top two were anything medical, and anything inside the cockpit of an airplane. You don't want their high priced lawyers wanting to know your phone number.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many thanks to everyone.

For now I just wanted to know the possibilities VS estimated price. My boss didn't gave much details of what is really needed, so, I just need to justify the actual values I am getting and what we can do to get better times, however, the client can be happy with actual values... who knows? :-)

I hope to report later the solution.

Thank you all.

JPCasainho,
www.Casainho.net
.Portugal

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If they don't run on the same oscillator, then they are asyncronous.

If you turn on the units at the same time, and select a long enough dead band where both ends show red, you can propably live weeks with few seconds difference per week. You do need a settable dead band anyway, as the traffic needs to go through the single lane completely before it turns green. Therefore it is the responsibility of the operator of the device to make sure the dead band is long enough that the devices shows 15-30 seconds even after the lane is empty.

I'd consider putting RTC module with built-in watch timebase, and battery. As long as both units know the time to some degree, they can propably run for quite a time before the time needs to be resynced. I guess a second is good enough minimum timebase, who needs faster traffic lights? Also make sure the units know which one is which, so they don't show green at the same time. Do not put a "syncronize" button to it, otherwise someone pushes it on the other device and then they go out of sync. Make them exchange the time or resync pulse somehow with a cable or infrared transmission when the devices are near again, for example battery exchange.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Down here in Florida, they solve the one lane construction zone problem with a couple of bubbas with a double sided sign that says stop on one side and slow on the other, and a couple of walkie talkies.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, they do that here (Oregon), also, when the construction is happening. The bubbas, however, are usually of the female persuasion.

I have seen the automatic stop-sign business in places where they cannot restore the road to multiple lane when the construction is not active. I have also seen this on old bridges where it has been restricted to one way at a time due to load capacity problems.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net