Author Topic: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing  (Read 1857 times)

0 Members and 1 Guest are viewing this topic.

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
These are super inexpensive devices made with PIC chips that can act as high precision synchronous timing blocks and frequency dividers that don't introduce errors of their own. The cost is extremely low. Paired with a GPSDO very accurate timestamping and many other things can be done.

Not quite to the nanosecond level (not even close) but very very good value for the money. <<wrong

An old thread on Time-nuts (from Oct 2013 "Time stamping with a PICPET") that I had saved says that picpet 's time stamping can be used to measure a time interval to an accuracy of 400 ns. Thats better than NTP (see the discussion at the link below)

https://www.febo.com/pipermail/time-nuts/2013-October/thread.html

I don't feel qualified to explain its internal workings.

(Edit: You can get a good idea of what I would like to do in this previous thread.
https://www.eevblog.com/forum/testgear/possible-to-make-a-quality-universal-timercounter-using-$12-pic-countergpsdo/

I'd like an ability to extend the value of the "known to be accurate signals" I do have. )

One likely can utilize them as a starting point/building block of verifiable accuracy (because of the synchronous aspect my understanding is that it's deterministic in a way that differentially clocked devices aren't.) Just like any other transform that derives one frequency completely from another frequency, it doesnt increase the existing error, it multiplies or divides frequencies like a clock chip does- this is more accurate than most MCPUs would manipulate time-relevant bits.

http://www.leapsecond.com/pic/ << explanation of why some features of these PIC chips are desirable for timing

http://www.leapsecond.com/pic/picpet.htm
http://leapsecond.com/pic/picpet2.htm
and
http://www.leapsecond.com/pic/picdiv.htm


@tvb's profile page https://www.eevblog.com/forum/profile/?u=370294
« Last Edit: December 17, 2018, 04:50:41 am by cdev »
"What the large print giveth, the small print taketh away."
 
The following users thanked this post: rbm

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 662
  • Country: us
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #1 on: December 16, 2018, 05:49:54 pm »
Is there something about the PIC that makes it particularly suitable for a software divider?  More so than an ARM Cortex M, AVR, or some other MCU line?  Hang around time-nuts long enough and someone always mentions picdiv, usually in glowing terms.  I don't understand what makes it special.  Is this just another manifestation of the ham radio <=> PIC correlation?
 

Offline jpb

  • Super Contributor
  • ***
  • Posts: 1711
  • Country: gb
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #2 on: December 16, 2018, 09:55:57 pm »
Is there something about the PIC that makes it particularly suitable for a software divider?  More so than an ARM Cortex M, AVR, or some other MCU line?  Hang around time-nuts long enough and someone always mentions picdiv, usually in glowing terms.  I don't understand what makes it special.  Is this just another manifestation of the ham radio <=> PIC correlation?
I don't know much about it but I think that it is because the older pic chips allow for an external 10MHz clock so you can clock it from the reference that it is going to divide or time stamp. Something like an ARM is going to have an independent crystal or internal oscillator which makes it faster but not so useful for timing/division.
Similarly, if you read some of Quartzlock's technical notes it is clear that they use the 10MHz reference to clock a PIC and then use two 16bit DACs on the PIC (one fine one course) to get an effective 20 bit DAC for the frequency control voltage on their GPSDO's and other circuits.
« Last Edit: December 16, 2018, 09:58:49 pm by jpb »
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #3 on: December 16, 2018, 11:07:18 pm »
I added a link to my original post - to a discussion with more info.
"What the large print giveth, the small print taketh away."
 

Offline Hexley

  • Contributor
  • Posts: 47
  • Country: us
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #4 on: December 16, 2018, 11:09:20 pm »
The key to tvb's PIC cleverness is that he uses the signal-to-be-divided as the processor clock. Then he simply uses instruction loops to count off the desired number of clock cycles and toggle an output pin. So it is perfectly synchronous, and has no uncertainties from clock re-synchronization or interrupt latency, etc.

Hence the attraction for timing applications where jitter has to be minimized.

I like the approach for general-purpose dividers. As long as the input signal is in the range of the PIC input clock spec (<20 MHz, say), and as long as the divisor is not too small, then it is easy roll an arbitrary divider into a small 8-pin package. You just have to be comfortable tweaking the PIC assembly code to get the right division ratio.

For a recent PLL, I used one PIC to divide the 10 MHz VCO signal by 500, and a second PIC to divide the 3.840 reference by 192 in order to get 20 KHz inputs to the phase comparator. Worked a treat.
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #5 on: December 16, 2018, 11:12:30 pm »
I'd like to be able to use frequencies derived from my GPSDO as inputs to DDS hardware without any potential inaccuracies caused by other oscillators.
"What the large print giveth, the small print taketh away."
 

Offline mark03

  • Frequent Contributor
  • **
  • Posts: 662
  • Country: us
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #6 on: December 16, 2018, 11:18:31 pm »
http://www.leapsecond.com/pic/ << explanation of why some features of these PIC chips are desirable for timing

Hmmm.  AFAIK most of those properties are true of all MCUs.  Certainly the part about deterministic interrupt latency.   And all of the STM32s I'm familiar with allow you to clock the part directly off of an external clock source, without any internal oscillator or PLL being used.

Achieving fully deterministic cycle counts per instruction probably requires jumping through a few more hoops on a typical Cortex M.  But you can always run from RAM with no wait states AFAIK, especially if you clock the part at a rate comparable to those 8-bitters.

In any case, nothing wrong with the PIC.  I just always got the impression that there was something "special" about it for this application, and am wondering anew if that is in fact the case.

Edit:  Reading Hexley's reply, I realized one thing which is special about the PIC:  8-pin packages!
« Last Edit: December 16, 2018, 11:20:49 pm by mark03 »
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
"What the large print giveth, the small print taketh away."
 
The following users thanked this post: apis, Kean

Offline texaspyro

  • Super Contributor
  • ***
  • Posts: 1384
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #8 on: December 17, 2018, 02:43:32 am »
The PICs instruction timings are VERY regular and predicable which makes writing cycle-accurate code rather easy.

Also, Lady Heather supports using the PICPET as a time interval counter.  The 400 ns resolution is not the best, but works very well for a lot of things.
 

Offline imo

  • Super Contributor
  • ***
  • Posts: 2621
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #9 on: December 17, 2018, 05:50:10 pm »
You may use those pic/atmega DIV chips for an XOR based GPSDO. I've done it recently and it works pretty well.
Simply divide 10MHz OCXO freq to 10kHz (or 20kHz), XOR the 10kHz from the NEO GPS with that picDIV 10kHz, pass the result via an LPF to the OCXO EFC. I've been using an opapm as a buffer. The LPF creates a loop with around 25 minutes settling time.
 

Online awallin

  • Frequent Contributor
  • **
  • Posts: 666
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #10 on: December 17, 2018, 05:55:33 pm »

Did anyone compile the .ASM assembler-source into the .HEX bit-file with a recent download of MPLAB-X?

I tried this a bit some months ago, but it was not exactly plug-and-play. The assembler variant/dialect that the new MPLAB-X wants to see seems to have changed from the olden days when TvB wrote the sources.

+1 for anyone who manages to compile the .asm and does a write-up of it for others to follow  :-+
 

Offline imo

  • Super Contributor
  • ***
  • Posts: 2621
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #11 on: December 17, 2018, 05:58:57 pm »
There are old MPASM versions still available. Download and try..
Here you are:
https://www.microchip.com/development-tools/pic-and-dspic-downloads-archive

You want "MPLAB IDE v8.92"
« Last Edit: December 17, 2018, 06:08:22 pm by imo »
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #12 on: December 17, 2018, 06:06:54 pm »
So, you mean, use a fairly recent Ublox GPS with the configurable time pulse output, configure it to 10 KHz, with a 50% duty cycle? (losing the ublox 1pps unless its one of the higher end models that has two configurable outputs)

You may use those pic/atmega DIV chips for an XOR based GPSDO. I've done it recently and it works pretty well.
Simply divide 10MHz OCXO freq to 10kHz (or 20kHz), XOR the 10kHz from the NEO GPS with that picDIV 10kHz, pass the result via an LPF to the OCXO EFC. I've been using an opapm as a buffer. The LPF creates a loop with around 25 minutes settling time.

So you need an OCXO thats has the right kind of EFC- ($10-20 maybe, with some luck?)

The cheapest deals on ublox adjustable TP output GPS devices are probably around $10-15

Two PIC chips - around $2  Some PCB material or even perfboard.. An appropriate regulated power supply.
"What the large print giveth, the small print taketh away."
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #13 on: December 17, 2018, 06:10:19 pm »
Do you know when they changed it? (approximately)

I'm asking because I have a bunch of older tools Ive downloaded and I am wondering which ones might be usable with the older format and which arent.

Well, I guess I'll see. :)



I hope these older vendor tools work with a newer Linux. Generally older binaries work but not always.


I could probably run it under Wine then.

ASM for assembler?

There are old MPASM versions still available. Download and try..
Here you are:
https://www.microchip.com/development-tools/pic-and-dspic-downloads-archive

You want "MPLAB IDE v8.92"
« Last Edit: December 17, 2018, 06:26:10 pm by cdev »
"What the large print giveth, the small print taketh away."
 

Offline imo

  • Super Contributor
  • ***
  • Posts: 2621
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #14 on: December 17, 2018, 06:13:20 pm »
Quote
So, you mean, use a fairly recent Ublox GPS with the configurable time pulse output, configure it to 10 KHz, with a 50% duty cycle?
Yes, an XOR gate works as a phase comparator, the XOR's output is low-pass filtered and fed into the EFC. It works "analog way", no special 4046/adc/mcu/dac is required. You do not see all the fancy data outputs, however, unless you monitor the EFC voltage.
I do monitor the EFC, and the EFC voltage settles after about 20minutes with properly designed low pass filter, then the EFC tracks the OCXO's fluctuations. The EFC fluctuations with a decent OCXO are in hundreds of uVolts range.. (ie. my Trimble OCXO is 160ppb/Volt).
« Last Edit: December 17, 2018, 06:47:14 pm by imo »
 
The following users thanked this post: cdev

Online nctnico

  • Super Contributor
  • ***
  • Posts: 19691
  • Country: nl
    • NCT Developments
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #15 on: December 17, 2018, 10:03:18 pm »
The key to tvb's PIC cleverness is that he uses the signal-to-be-divided as the processor clock. Then he simply uses instruction loops to count off the desired number of clock cycles and toggle an output pin. So it is perfectly synchronous, and has no uncertainties from clock re-synchronization or interrupt latency, etc.
True but you can achieve the same thing with a hardware timer (driving a timer match output) while driving a microcontroller from a stable clock. The bonus is that you don't need to count clock cycles but just configure the timer. Much easier to achieve. Add a display and a few buttons and you can create a pulse generator with variable timing.
« Last Edit: December 17, 2018, 10:12:00 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1457
  • Country: dk
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #16 on: December 18, 2018, 11:03:27 am »
There are old MPASM versions still available. Download and try..
Here you are:
https://www.microchip.com/development-tools/pic-and-dspic-downloads-archive

You want "MPLAB IDE v8.92"

Seems to be a 111MB download

If you're on a "Real OS" , you might try out gputils , it has a MPASM compatible assembler (gpasm).
https://gputils.sourceforge.io/

I just gave it a shot for fun:

Code: [Select]
sudo apt-get install gputils


wget http://www.leapsecond.com/pic/src/pd07.asm
wget http://www.leapsecond.com/pic/src/delayw.asm

Verify against original hex
wget http://www.leapsecond.com/pic/src/pd07.hex

cp pd07.asm pdxx.asm

gpasm pdxx.asm

diff pd07.hex pdxx.hex

DONE

If you have an AVR , there is an AVR-Div here (I have never tried it in real life) just build the source for a T84
https://www.eevblog.com/forum/projects/lars-diy-gpsdo-with-arduino-and-1ns-resolution-tic/msg2042386/#msg2042386

/Bingo
« Last Edit: December 18, 2018, 11:06:24 am by bingo600 »
 
The following users thanked this post: cdev, awallin

Offline rbm

  • Regular Contributor
  • *
  • Posts: 228
  • Country: ca
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #17 on: December 27, 2018, 01:00:20 am »
I've sent emails to the published address but no response was forth coming.  Does anyone know if TVB is still producing these PICDIVs?  Any other sources than Leapsecond?
- Robert
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 5453
  • Country: 00
Re: @tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing
« Reply #18 on: January 02, 2019, 03:16:18 pm »
I'm pretty sure tvb there is the same tvb that has an account here but I don't think he minds it if you download the code from his site and burn it to your own PIC yourself. He may even prefer that people do that. Make sure its clear he's the author and give his contact info and web url in anything you make with it and I'm sure you'll be fine.


"What the large print giveth, the small print taketh away."
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf