Author Topic: Measuring time span very precise  (Read 7206 times)

0 Members and 1 Guest are viewing this topic.

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #50 on: September 08, 2019, 06:10:59 pm »
That's great! This solution with 3 high word counters using also the overflow interrupt has some longer periods on which the linking of a captured counter to its high word is valid (25% -> 33% of a full cycle)


« Last Edit: September 08, 2019, 06:28:30 pm by HendriXML »
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12859
Re: Measuring time span very precise
« Reply #51 on: September 08, 2019, 06:58:17 pm »
Heh.  It should be possible to determine the correct software high word for one cycle under half the rollover period after the instant of capture using the 'read all the flags + high bit''method.  That's 2ms on a 16 bit counter clocked at 16MHz e.g on most 5V AVR Arduinos.  Just plot out all the possible race conditions assuming interrupts are never disabled for more than 2 ms, and build the logic accordingly.
 

Offline KrudyZ

  • Frequent Contributor
  • **
  • Posts: 276
  • Country: us
Re: Measuring time span very precise
« Reply #52 on: September 08, 2019, 07:33:09 pm »
Measuring the time between two trigger signals is a fairly common requirement.
The equipment used is called a time interval counter or analyzer.
An interesting read describing a state of the art instrument from 1978 !!! which achieved 20 ps single shot resolution can be found here:
https://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1978-08.pdf

As you can imagine newer instruments far exceed the 5370B in capabilities, but HP provided chip level schematics with detailed explanations if you want to dive deeper, which makes this very educational to read.
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #53 on: September 08, 2019, 08:08:33 pm »
It's clear to me that using the Mega 2560 board can do very nice stuff with event timing. With a resolution smaller than 1 usec. I will implement the time span measurement with that board. I'll use 2 timers 4 and 5. Their event capture pins on the board are 49 (ipc4) and 48 (ipc5).
Why use 2 timers? That give 2 timestamp registers, so they won't get in each others way. This way (as has been said by Ian and others) very small time spans can be measured. The interrupts will be also queued independent of each other, so no loss of interrupts.
Also the events can be discriminated from each other (start vs stop). Especially in the situation when a Nerfdart is shot wrong (no start gate or no stop gate) this is handy.

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
« Last Edit: September 08, 2019, 10:46:04 pm by HendriXML »
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #54 on: September 08, 2019, 08:23:01 pm »
See the ATmega2560 datasheet section 18.4.1 GTCCR - General Timer/Counter Control Register, Bit 7 – TSM: Timer/Counter Synchronization Mode.  Using it, multiple Arduino Mega2560 16 bit timers can be initialised to run in lock-step with each other.  Then you can use separate input capture units to timestamp your start and stop external events and calculate the interval as Magic suggests in reply 6 above, even if the events are only a single ATmega clock cycle apart.  Assuming the counter and captures are extended in software to 32 bit, at the highest resolution of 1/16 us, you get a rollover period of a bit under five minutes.  Drop the resolution to 1/2 using the prescaler and the rollover interval becomes slightly under 36 minutes.  The next step down has a resolution of 4us and a rollover period of 4 3/4 hours.

The only fly in the ointment is the poor accuracy of the typical Arduino ceramic resonator clock oscillator, so you will probably need to feed the Arduino a master clock from a much better quality oscillator.
I think this answers the synchronization method. I'm not sure what it does yet, but I'll figure it out.

Is it better to redo the oscillator instead of replacing the resonator with a crystal (don't know if that possible )?
« Last Edit: September 08, 2019, 08:39:16 pm by HendriXML »
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #55 on: September 08, 2019, 08:37:23 pm »
B.t.w. many thanks for all the thoughts and suggestions!
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #56 on: September 08, 2019, 10:22:12 pm »
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?
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12859
Re: Measuring time span very precise
« Reply #57 on: September 09, 2019, 02:15:12 am »
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.
 
The following users thanked this post: HendriXML

Offline magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: Measuring time span very precise
« Reply #58 on: September 09, 2019, 05:57:05 am »
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
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.
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14195
  • Country: de
Re: Measuring time span very precise
« Reply #59 on: September 09, 2019, 08:43:03 am »
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.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Measuring time span very precise
« Reply #60 on: September 09, 2019, 10:57:12 am »
Simple, accurate, and cheap. Borrow an FPGA dev board
FPGA will eventually be used in the projects, but for now a bit too soon.  :-+

Please reconsider... as an example of how this is the perfect domain for this tool, here it the complete timing module, which will be accurate to maybe +/-20ns with a 100MHz clock (pretty much standard for an FPGA).

You just need outside code to filter the inputs (synchronise them to the system clock using a few flipflips, and maybe de-glitch the start and end signals to prevent double triggering):

Code: [Select]
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity timer is
    Port ( clk           : in  STD_LOGIC;
           -- control inputs
           start_signal  : in  STD_LOGIC;
           end_signal    : in  STD_LOGIC;
           rearm_signal  : in  STD_LOGIC;
           -- statue signals
           armed         : out std_logic                      := '0';
           running       : out std_logic                      := '0';
           -- counter outputs
           count         : out STD_LOGIC_VECTOR (39 downto 0) := (others => '0');
           new_count     : out STD_LOGIC                      := '0');
end timer;

architecture Behavioral of timer is
   signal counter : unsigned(39 downto 0) := (others => '0');
begin

process(clk)
   begin
      if rising_edge(clk) then
         new_count <= '0';   -- default for the new count
         armed     <= '0';   -- default for the 'armed' status LED
         running   <= '0';   -- default for the 'running' status LED
         if counter = 0 then
            armed <= '1';     -- we are armed!
            if start_signal = '1' then
               counter <= counter +1;  -- We are triggered!
            end if;
         else -- if we are counting
            if end_signal = '1' then 
               -- time to stop and output the new count
               count     <= std_logic_vector(counter);
               new_count <= '1';
               counter   <= (others => '0');
            elsif rearm_signal = '1' then 
               -- reset into the 'armed' state
               counter   <= (others => '0');
            else
               -- keep on counting as the timer is running
               running <= '1';
               counter <= counter +1;
            end if;
         end if;
      end if;
   end process;
end Behavioral;

If you send that 40-bit "counter" to the AVR when new_count is '1' (most likely as ASCII hex). your problem is fixed. Far better than these "angels dancing on the head of a H/W timer's IRQ latency" issues.
« Last Edit: September 09, 2019, 11:02:19 am by hamster_nz »
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Online iMo

  • Super Contributor
  • ***
  • Posts: 4782
  • Country: pm
  • It's important to try new things..
Re: Measuring time span very precise
« Reply #61 on: September 09, 2019, 11:55:04 am »
The jump into the FPGA world is for most ..duino users a difficult exercise. It is not only about the verilog but the entire infrastructure (boards, programmers, tool chain, etc) you have to master.

Even I've been driving the TDC7200 off an FPGA (start/stop TOF for my reciprocal counter), wiring it to an ..duino is matter of say 100 minutes (14pins smd, SPI interface). The arduino library is there, what you need is an external source of up to 10MHz for the TDC7200 calibration (the chip is 3.3V). And the resolution is 55ps with 35ps stddev in two modes (upt to 500ns and up to 8ms). So no need to mess with FPGAs, and you get a tool comparable with $10k HP rigs..
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #62 on: September 09, 2019, 12:33:48 pm »
Thanks again for the responses.

FPGA's are not in my comfort zone. If I use a component and scripts I only do so if I understand them well, or in the process of learning them. I don't like to copy 'n paste stuff.

I'm now going trough the elaborate post of Ian together with a good image of the Mega 2560 board, to figure out which traces/components have a role.

Before the mod is ordered/finished I'll off course use the resonator that is on board. Experimenting with a little oled display to show the measured speed. I also need to invert the signal coming from the gates (I guess). It is a comparator pull down signal when something crosses the beam.

What I like about this exercise is:
"Building" a high freq accurate clock signal
Modding the board, that is one step towards lower level interaction with the AVR. Seeing it as a component and not only as a module (together with the board).
Being already familiar with IDE and stuff. So that part won't be too difficult.
« Last Edit: September 09, 2019, 12:49:14 pm by HendriXML »
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #63 on: September 09, 2019, 12:39:23 pm »
I've just started, but it might be interesting to show what's standard on the board. (I also haven't checked the powerlines yet..)

I think it's now driven by the resonator (AG) near R14.
« Last Edit: September 09, 2019, 12:47:17 pm by HendriXML »
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #64 on: September 09, 2019, 01:04:44 pm »
By the way, contrary to the datasheet, my experience shows that 3.3V clocks drive 5V AVRs with no problem.
I think I might try that as well.
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #65 on: September 09, 2019, 01:49:33 pm »
A summary action list without a level shifter would be:
1) Program CKSEL Fuse to 0000
2) Cut traces to XTAL1 and XTAL2
3) Add clock output of TCXO Oscillator to XTAL1
4) Add power and components to Oscillator

I think I'll glue the TCXO Oscillator to the Atmel chip, in that case it would be very easy to solder the output to XTAL1.
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #66 on: September 09, 2019, 02:36:19 pm »
I think I'll glue the TCXO Oscillator to the Atmel chip, in that case it would be very easy to solder the output to XTAL1.

Glueing the oscillator to a heat source might not be the best of idea. So will do it on the board. 
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 14195
  • Country: de
Re: Measuring time span very precise
« Reply #67 on: September 09, 2019, 03:13:26 pm »
The external oscillator should also work with the clock setting for the crystal currently used. Chances are even better than that it works with 3.3 V level. In this case one needs cut the XTAL2 line. With fuse setting 0000 (that is external clock) one could get away without cutting the trace at XTAL2 as the pin would be unused in this case.

The board just below the µC  is probably the better position than on top of the µC.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: Measuring time span very precise
« Reply #68 on: September 09, 2019, 06:33:29 pm »
Desolder the resonator instead of cutting traces. Put a big blob of solder on each end and melt them both at the same time by applying soldering iron to the side.

Then you will realize it's easier to put an SMD quartz there instead of modding the board for active generators.
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #69 on: September 09, 2019, 06:40:49 pm »
I also searched for a different TCXO Oscillator:
https://nl.mouser.com/ProductDetail/ECS/ECS-TXO-5032-160-TR?qs=GSXfdiLIrOFsAHbhYZImDw%3D%3D
The previous one was shockingly small 2.0 x 1.6 mm.., this one 5.0 x 3.2 mm that's a bit better. I guess the pictures didn't match the smaller component.

I understand now what Ian meant with the small s..t caps.

They don't show not much info on how to implement this component. Would a normal THT ceramic bypass cap of 100 nF be ok? Or does it need to be SMT for its "short" legs?
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #70 on: September 09, 2019, 06:42:57 pm »
Desolder the resonator instead of cutting traces. Put a big blob of solder on each end and melt them both at the same time by applying soldering iron to the side.

Then you will realize it's easier to put an SMD quartz there instead of modding the board for active generators.
Only the resonator would need replacing by a quartz ? Not the caps? I'll try to find a replacement.
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #71 on: September 09, 2019, 06:56:06 pm »
Hmm, days ago it would haven been accurate enough, but now I got attached to the better specs. And as said the modding needs to be a bit challenging.
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: Measuring time span very precise
« Reply #72 on: September 09, 2019, 08:10:37 pm »
Yes, the capacitors may need replacement too unless they are close enough in value. Removal technique is the same.
If their value is only slightly wrong, the frequency will be off a bit. Less than 0.1% IIIRC.
« Last Edit: September 09, 2019, 08:18:00 pm by magic »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12859
Re: Measuring time span very precise
« Reply #73 on: September 10, 2019, 01:40:42 am »
The problem with resonators is their accuracy: At best the standard resonator will be several hundreds of ppm off from the nominal frequency, at worst it could easily be 0.1% out.  It is also likely to drift horribly with varying temperature.  A crystal will be a lot better: With the specified load capacitance, you can reasonably expect it to be within 20 to 30 ppm at 25 deg C room temperature.  If you trim the caps you can ge:t a bit closer, but it still wont be particularly stable with respect to temperature.  If the wrong caps are used with the crystal you could easily introduce another 50 ppm of frequency error.  OTOH the TCXO above is specced to hold its frequency within +/-5 ppm over quite a wide temperature range. That's a worst case error of  three seconds a week or to put it another way, if all your input signals are clean with sharp edges,  you could build a five digit seconds and decimal fractions timer and trust the last digit.

Replacing the resonator with a crystal is relatively high risk if all you've got to do the job is an iron and the usual hand tools.  Track cut and patching to fit a TCXO is a *LOT*lower risk.  OTOH, if you've got a well kitted out SMD rework station with a hot air pencil, and enough practice using it, and don't mind the lower accuracy result, by all means go for swapping the resonator for a crystal and swapping its caps for the right ones to match the crystal.  The only problem will be finding a small enough footprint crystal. 

There's also a cheap and dirty 'no parts' (except fine magnet wire) oscillator improvement hack for genuine Arduinos that use a separate USB AVR for their host USB interface.  Tack a fine modwire onto XTAL2 of the USB AVR, which has a real crystal, because of the tight frequency control  reqired for USB, and onto the XTAL1 pin of the main MCU, also cutting the track from that pin from the resonator.   However due to the long modwire it will probably 'pull' the crystal frequency slightly and will radiate more EMI so maybe not the best idea if you live next door to a radio ham with an interest in DXing..

For the mod you really want good groundplane where you are going to put the TCXO, so you can tie its Gnd to board ground with a very short wire, and placed well away from heat sources like regulators and the MCU itself.  The area under the G of the yellow GND you added to the image looks like the best choice.  You've already identified the best place to pick up 3.3V, and 5V if you need it.   

That board layout is a bit different to the one I was working from for the instructions. I'd make the track cuts where they are still straight and parallel coming from the MCU XTAL pins just above where they bend 45 deg to the left towards the resonator and just below where the adjacent track bends to the right.  That's where IMHO you've got the best chance of not nicking an adjacent track with the scalpel blade.  Alternatively find the silk screened "C5" and "C6" of the resonator caps, and cut the tracks on a line between the right edges of those silkscreened markings.  That gives you a wider spacing between them if you ever have to  undo the mod, so less fiddly to bridge the cuts. 

When you are bypassing tiny little parts you need tiny little capacitors.  If you can find a N.O.S 5V metal can DIL14 (corner pins only) 16MHz TCXO with glass frit hermetic seals on three of its four legs and the Gnd leg welded direct to the can, then you can use your disk ceramic 100nF cap reasonably safely, but if you used it with a SMD TCXO and it got bumped you''d be risking ripping the 'pin' pads off the SMD package.  For the SMD TCXOs you need SMD caps just to get ones that will fit conveniently across the pins that need decoupling, and as the pin pitch shrinks you need to go increasingly towards the 'invisible fly sh-t' end of the SMD passives size range.  When you are right down at the limit of what an expert with steady hands can deadbug without needing a micromanipulator, a through hole passive would have leads considerably larger diameter than the pin pitch so would be even more of a nightmare to use than the SMD fly sh-t.  Its really not hard to put one in place, tombstoned or flat.  Tin the pad its got to go on, (one only if mounting flat). get a trace of paste flux on the corresponding end of the part., place it with tweezers and reheat the tinned pad to make the joint.  Then hold flat ones down with a toothpick or small flat jeweller's screwdriver while you solder the other end.  Tombstoned ones are a bit trickier, but you've got the benefit of a lot of groundplane area at the bottom end, so if you are quick and have the top end wire or pin in exactly the right place you can solder it without remelting the bottom joint.  If you dwell too long. it *WILL* remelt then stick to your bit (and the same if you slip while holding a flat one down). Don't try to retrieve small passives stuck on your bit - just curse eloquently, wipe them off, clean up one pad with braid if the SMD part needs to go flat, then get a fresh one off the reel or cut tape and try again.  A good nights sleep and 24H without coffee or other high caffeine drinks helps most SMD novices considerably, as does obscenely bright easily positionable bench task lighting.  If you need sunglasses because of the glare, its probably a little too bright!

The first TCXO you found was a good convenient match to the pin order and spacing of the suggested 74LVC1T45 level shifter.  so although its tiny they were a good pair.  If you are trying to  go direct to XTAL1 with a 3.3V signal level, it may or may not work.  The MCU datasheet says 'don't count on it' but practical experience says the odds are in your favour.  The larger TCXO will definitely be easier to deadbug.  It has a control voltage input on 'pin' pad 1 for +/-5 PPM of frequency trim, which could be useful if you become a 'time-nut' but it says it can be left N/C so you can ignore it for now*.  Its decoupling cap would probably be best fitted diagonally across 'pin' pads 2 and 4, again before attaching any wires.  Don't be scared of working with tiny parts. Press the TCXO on some thin double sided sticky tape, and you can get the cap and wires attached to it working on your bench before you even touch the Arduino board, so if that doesn't go well all you are out is the cost of the TCXO and the 10nF cap.  Once you've got the wires on and its looking like a crippled spider, you can pry it off the tape with the tip of your scalpel blade and transplant it to its final position on a drop of glue on the board.

* Future Time nuttery could include ovenizing the TCXO in a little copper foil 'jacket'  inside an expanded polystyrene block, itself with an aluminum foil 'jacket', with a small power transistor to heat it and a DS18S20 digital temperature sensor for the Arduino to read and control the oven temperature, a high precision DAC to control the pin 1 voltage to trim the TCXO, and a GPS module with one PPS output pulse so the Arduino has a long-term stable reference to trim the TCXO to.   That's the basics of a budget GPSDO, and could easily let you get a reliable sixth digit of accuracy.  Obviously you'd need to put all the gubbins on a proto shield and run a modwire down to the Arduino XTAL1 track. (Or if you are feeling really too clever, desolder the resonator and caps and solder a pogo pin to the underside of the protoshield so it lands on an XTAL1 pad!)
« Last Edit: September 10, 2019, 01:56:15 am by Ian.M »
 

Offline HendriXMLTopic starter

  • Super Contributor
  • ***
  • Posts: 1085
  • Country: nl
    • KiCad-BOM-reporter
Re: Measuring time span very precise
« Reply #74 on: September 10, 2019, 09:09:37 am »
Please don't mention more accuracy using ovens.. I'm a bit sensitive for that  :-DMM

Then untreated TCXO will for now be just fine. I'll be using this timer mostly in conjunction with other measurements that are far less accurate. But it may be a nice project to execute just for fun in the future.

About the level shifter I'm not sure yet, but I'll order the parts anyway. And already know how it works: once I have the oscillator running standalone (A good reason to have it a little bit bigger) when it's not new anymore, I will to follow the Atmel specs.

I only once soldered a small SMD op amp dead bug style before, and looking through mounted binoculars https://www.bestbinocularsreviews.com/Pentax-Papilio-85x21-Binoculars-118.htm I really enjoyed soldering the wires. Wouldn't want to create whole boards this way, but only a few components is satisfying.
“I ‘d like to reincarnate as a dung beetle, ‘cause there’s nothing wrong with a shitty life, real misery comes from high expectations”
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf