Electronics > Projects, Designs, and Technical Stuff

Measuring time span very precise

<< < (12/16) > >>

HendriXML:
B.t.w. many thanks for all the thoughts and suggestions!

HendriXML:
Just to get an idea, can this be used as a master clock?

https://nl.mouser.com/ProductDetail/ECS/ECS-TXO-2016-33-160-TR?qs=PzGy0jfpSMvKXA%252Blz%252B4RRQ%3D%3D

No extra components needed? Except for level conversion and 3.3 V power supply?

Ian.M:
The Arduino Mega 2560 has an on-board 3.3V 50mA regulator for 3.3V peripheral interfacing, so all you'd really need to use that TCXO would be to add level shifting (e.g 74LVC1T45 in SOT26 package) to get a full 5V swing , and run the output to XTAL1, after disconnecting the resonator.   

I've written you up a set of instructions to do the mod, assuming a genuine MEGA 2560 or a clone with a very similar layout.  They are written for someone who hasn't done a lot of SMD rework, but is confident doing fine PCB work neatly:

You'll need an Arduino MEGA 2560 + a suitable PSU for it - not your PC unless you use a power only USB lead; the above TCXO (or a very similar one with a compatible pinout), a 74LVC1T45 level shifter in SOT26 package, two very small SMD 10nF ceramic caps (metric 1608 imp. 0603); fine Magnet wire - preferably with solder-through polyurethane enamel, a few inches of fine single strand tinned copper wire - pull a couple of strands from any factory tinned multistrand wire you've got handy; gel superglue, clear nail varnish; IPA, foam Q-tips, and kitchen towel for cleanup; an Xacto Knife or other scalpel with a small convex curved cutting edge for track cuts and solder mask scraping,  a small flat blade Jeweller's screwdriver for prodding stuff and holding wires in place, a small softwood disposable chopstick to assist with forming the magnet wires, a pair of fine heat resistant non-magnetic tweezers for handling SMD parts, and also the usual soldering tools and consumables.  You may also need an AVR ISP programmer.

CAUTION: The following instructions were written without either a Mega 2560 or the level shifter IC and TCXO, in front of me, so please carefully read through each step, and check that it both makes sense to you and makes sense electrically when checked against the datasheets and the Mega 2560 schematic, and check part positioning before you do anything to the Arduino board.


* General instruction for later steps: Try to keep all wiring as neat as possible, ends inline with pins and tracks and at rightangles to pads for passives.  Form the wires to lie along the board surface using the end of the chopstick to hold the wire against the board and make a bend with the free end of the wire where needed.  If you don''t have a really good pair of flush cutting miniature precision dykes, the tinned wire and magnet wire are probably best cut with the scalpel with firm pressure against a hard surface, if possible while bending the wire up and down so it breaks at the blade.  If cutting wire in-situ on the board, be careful not to cut any tracks!
* Preload the Arduino with the simple 'Blink LED' demo sketch so its easy to check its working.  Confirm that!
* Scratch up the surface of the solder mask for adhesion and dead bug* the 16MHz TCXO on a drop of superglue on the area of topside ground plane above the word POWER next to the 100K (105) resistor beside the resonator etc. Leave space for the '1T45 in the next but one step.
* Very carefully bend up the middle pin each side of the '1T45, leaving the four end pins alone.  With the tip of the jeweller's screwdriver held against the root of each middle pin in turn (so you don't attempt to reverse the bend right on the original factory bend line and crack the pin) carry on bending the pins up. Flip it over, put it on a hard surface and form the middle pins till their ends are flat to the surface its top is on.
* Scrape a bit of ground plane next to the TCXO and at rightangles away from the middle of its long side (on the long side with both pin pads fully square, not the one with the pin 1 pad with a bevelled inner corner), and solder the '1T45 down by both its middle pins with its pin 6 next to TCXO 'pin' 4 ánd its pin 4 next to TCXO 'pin' 3.  The spacing is almost the same so you can get it really close
* Solder a 10nF SMD ceramic (fly-s**t sized 0603 as it needs to be no more than 1.8mm long) across TCXO 'pins' 1 and 2.
* Scrape  a spot for a really close ground next to the TCXO 'pin' 2 (Gnd) and run a strand of thin tinned bare copper wire up to the end of the 10nF cap to connect it.
* Using thin magnet wire, tin the end far enough to get it across '1T45 pin 6 (VccB), and TCXO 'pins' 4 (Vcc) and 1 (Tri-State) control (on the cap end), solder it to all three, and take the other end of the magnet wire to a spot scraped and tinned on the track to the 3.3V pin of the nearby power header.
* Solder a strand of thin tinned copper wire between TCXO 'pin' 3 (Output) to '1T45 pin 4 (B - configured as input) to hook up the TCXO to the level shifter.
* Tombstone# another 10nF cap soldered to the ground plane right next to '1T45 pin 1 (VccA), and solder the cap top end to the pin 1.  Run magnet wire from pin 1 / cap top to the 5V end pad of the decoupling cap next to the Power header.
* You should now have a working 16MHz TCXO with 5V level output on the remaining unsoldered pin 3 (A) of the '1T45.  Power on the Arduino and check its there with an x10 scope probe, and that the sketch still runs. Disconnect the Arduino again.
* Cut the tracks to the resonator on the longish straight run in line with the edge of the ATmega, so you can more easily reverse the mod if you need to, as neatly as possible, making two parallel cuts side by side approx 0.5mm apart, at rightangles across both tracks, with moderate pressure and a rocking motion of the scalpel blade. Clear any remaining copper out of the gaps between the cuts, and scrape back the solder resist on the lower track to pin 34 (Xtal1) of the MCU, on the MCU side of where you cut, to bare it starting a few mm in from the end you just cut.  Leave solder resist on the track end right next to the cut so the wire you will add there doesn't short to the resonator side of the track cut if you've tinned slightly too much of the wire end
* Tin the track you just scraped and run magnet wire from it to pin 3 (A - configured as output) of the '1T45.
* Congratulations, the hookup is now complete.  Power on the Arduino, and check it still runs the sketch.
* Now clean-up the flux residue with a foam Q-tip wetted with IPA.  Keep blotting it on the kitchen paper to remove dirty IPA, and wet it again with clean IPA, changing Q tips as required.  Blot off excess IPA with a dry foam Q-tip.  Dry the board thoroughly, with warm air  if you've got it.
* Check all magnet wires are formed to the board and arranged neatly, then tack them down at bends etc. with small drops of superglue, holding them in place with the jewler's screwdriver if they try to spring up.
* Finally, coat the mod and its wires with the clear nail varnish to protect them and allow to dry thoroughly.  Overnight is good, or wait till touch dry then an hour in a very warm, but not boiling hot place.
* Ideally you should reFlash the ATmega to change all the CKSEL Fuse bits to binary 0000 to permanently select the external clock. You'll need an ISP programmer (e.g. USBasp, or another Arduino running the ArduinoISP sketch).  Follow your programmers instructions (or find a tutorial) for changing FUSE bits.  Be careful - if you get them wrong you can 'brick'the ATmega and wont be able to recover it without a HV ISP programmer or another Arduino + a 'fuse-buster'shield. If you do zero the CKSEL fuse bits, you'll need to reprogram them if you ever want to revert to the resonator.If you ever want to revert the mod, after reflashing the fuse bits (if you changed them) with the usual Mega 2560 ones, disconnect the 3.3V supply to the mod to power down the TCXO, and the pin A output to the cut track, then bridge the two track cuts with strands of fine tinned copper wire. The 5V to the '1T45 can be left as it goes inactive when its 3.3V VccB is removed.

Corrections to any errors or omissions are welcome.

H.T.H
Ian.

* Dead Bug / Dead Bugging:  Mounting a chip upside down on a dot of glue, pins (or pads for leadless packages) up in the air for patch-wiring with magnet wire.  So called because of its resemblance to a deceased fly on its back!  Don't forget to mirror image the datasheet pinout, as that will originally be a top view and you've now got it bottom up.

# Tombstone / Tombstoning: When a SMD passive is flipped up on end with only one end soldered to the board. Usually a process fault when one end is solder starved, or reflows much sooner than the other then surface tension flips it up, but sometimes done deliberately for Manhatten Island prototyping and for SMD prototyping if you don't have a pair of pads to put the part across.  So called because of the resemblance to a traditional grave marker.

magic:

--- Quote from: HendriXML on September 08, 2019, 08:08:33 pm ---Is there a special way to synchronize them? Or is this just a matter of finding the code to
DisableInterrupts
SetCounterTimer4(0)
SetCounterTimer5(0)
EnableInterrups

--- End quote ---
No, because counter4 will already be at a few counts by the time you set counter5 to zero.
Maybe SetCounterTimer5(4) would do what you want, but it's better to stop clock to the timers for the time of setting them up. See the first post by Ian.M in this thread.

I'm not sure what's the point of using a quartz generator. Does it come with some ceramic resonator out of the box? Even then it's accuracy may be good enough.
If you build the project and find out it's not, it may be easier to replace the resonator with a passive quartz crystal than mess with generators and level shifters.

By the way, contrary to the datasheet, my experience shows that 3.3V clocks drive 5V AVRs with no problem.

Kleinstein:
If the board is fitted with a ceramic resonator (usually plastic case) one may consider converting to a quartz resonator (metal case). A quartz may need extra caps to ground (some 20 pF). Many of the boards I saw already have a quartz - ceramic resonators are not that common at 16 MHz.

Just a normal external resonator may not be much better than a quartz directly at the µC, especially if the supply and ground connection is not good. An external oscillator would in my opinion only make sense if a TCXO, so one with very stable frequency.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod