@tvb's remarkable PicPet and PicDiv = inexpensive high-precision timing - Page 1
Forum section: electronics / testgear

author: cdev
author_rank: Super Contributor
timestamp: December 16, 2018, 01:59:25 pm
content: 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. <<wrongAn 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.htmlI 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 timinghttp://www.leapsecond.com/pic/picpet.htmhttp://leapsecond.com/pic/picpet2.htmandhttp://www.leapsecond.com/pic/picdiv.htm@tvb's profile pagehttps://www.eevblog.com/forum/profile/?u=370294

author: mark03
author_rank: Frequent Contributor
timestamp: December 16, 2018, 05:49:54 pm
content: 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?

author: jpb
author_rank: Super Contributor
timestamp: December 16, 2018, 09:55:57 pm
content: Quote from: mark03 on December 16, 2018, 05:49:54 pmI 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.

author: cdev
author_rank: Super Contributor
timestamp: December 16, 2018, 11:07:18 pm
content: I added a link to my original post - to a discussion with more info.

author: Hexley
author_rank: Regular Contributor
timestamp: December 16, 2018, 11:09:20 pm
content: 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.

author: cdev
author_rank: Super Contributor
timestamp: December 16, 2018, 11:12:30 pm
content: 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.

author: mark03
author_rank: Frequent Contributor
timestamp: December 16, 2018, 11:18:31 pm
content: Quote from: cdev on December 16, 2018, 01:59:25 pmHmmm. 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!

author: cdev
author_rank: Super Contributor
timestamp: December 17, 2018, 01:47:10 am
content: Also solving world hungerhttp://ww1.microchip.com/downloads/en/AppNotes/01375a.pdf

author: texaspyro
author_rank: Super Contributor
timestamp: December 17, 2018, 02:43:32 am
content: 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.

author: iMo
author_rank: Super Contributor
timestamp: December 17, 2018, 05:50:10 pm
content: 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.

author: awallin
author_rank: Frequent Contributor
timestamp: December 17, 2018, 05:55:33 pm
content: 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

author: iMo
author_rank: Super Contributor
timestamp: December 17, 2018, 05:58:57 pm
content: There are old MPASM versions still available. Download and try..Here you are:https://www.microchip.com/development-tools/pic-and-dspic-downloads-archiveYou want "MPLAB IDE v8.92"

author: cdev
author_rank: Super Contributor
timestamp: December 17, 2018, 06:06:54 pm
content: 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 hastwoconfigurable outputs)Quote from: imo on December 17, 2018, 05:50:10 pmSo 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-15Two PIC chips - around $2 Some PCB material or even perfboard.. An appropriate regulated power supply.

author: cdev
author_rank: Super Contributor
timestamp: December 17, 2018, 06:10:19 pm
content: 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?Quote from: imo on December 17, 2018, 05:58:57 pm

author: iMo
author_rank: Super Contributor
timestamp: December 17, 2018, 06:13:20 pm
content: QuoteYes, 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).

author: nctnico
author_rank: Super Contributor
timestamp: December 17, 2018, 10:03:18 pm
content: Quote from: Hexley on December 16, 2018, 11:09:20 pmTrue 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.

author: bingo600
author_rank: Super Contributor
timestamp: December 18, 2018, 11:03:27 am
content: Quote from: imo on December 17, 2018, 05:58:57 pmSeems to be a 111MB downloadIf 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:sudo apt-get install gputilswget http://www.leapsecond.com/pic/src/pd07.asmwget http://www.leapsecond.com/pic/src/delayw.asmVerify against original hexwget http://www.leapsecond.com/pic/src/pd07.hexcp pd07.asm pdxx.asmgpasm pdxx.asmdiff pd07.hex pdxx.hexDONEIf you have an AVR , there is an AVR-Div here (I have never tried it in real life) just build the source for a T84https://www.eevblog.com/forum/projects/lars-diy-gpsdo-with-arduino-and-1ns-resolution-tic/msg2042386/#msg2042386/Bingo

author: rbm
author_rank: Regular Contributor
timestamp: December 27, 2018, 01:00:20 am
content: 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?

author: cdev
author_rank: Super Contributor
timestamp: January 02, 2019, 03:16:18 pm
content: 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.