Author Topic: Divide by 10000000  (Read 14949 times)

0 Members and 1 Guest are viewing this topic.

Offline ludzinc

  • Supporter
  • ****
  • Posts: 506
  • Country: au
    • My Misadventures In Engineering
Re: Divide by 10000000
« Reply #25 on: June 01, 2017, 04:21:05 am »
It all depends what you want to do with 1pps. If it is only to drive an alarm clock, then it is fine to do that with a MCU.
If you are actually going to feed it to a discipline clock generator which will use 1pps input to drive PLL in order to generate a perfectly phase aligned clock, then think twice. Your MCU is likely to generate quite some jitter that will ruin your output clock.

If you are clocking the micro from the GPS 10MHz clock, and the division is performed by a timer rather then software, then you are only adding the residual jitter from the hardware timer.  This isn't something you'd ever see specified in a datasheet,  do you have any numbers?

Disciplined clock sources perform a lot of averaging on the 1PPS signal anyway, so a small amount of jitter shouldn't be a problem.

*than
 

Online mikerj

  • Super Contributor
  • ***
  • Posts: 3238
  • Country: gb
Re: Divide by 10000000
« Reply #26 on: June 01, 2017, 08:23:23 am »
It all depends what you want to do with 1pps. If it is only to drive an alarm clock, then it is fine to do that with a MCU.
If you are actually going to feed it to a discipline clock generator which will use 1pps input to drive PLL in order to generate a perfectly phase aligned clock, then think twice. Your MCU is likely to generate quite some jitter that will ruin your output clock.

If you are clocking the micro from the GPS 10MHz clock, and the division is performed by a timer rather then software, then you are only adding the residual jitter from the hardware timer.  This isn't something you'd ever see specified in a datasheet,  do you have any numbers?

Disciplined clock sources perform a lot of averaging on the 1PPS signal anyway, so a small amount of jitter shouldn't be a problem.

*than

Sorry, don't quite understand?
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 6719
  • Country: nl
Re: Divide by 10000000
« Reply #27 on: June 01, 2017, 08:41:52 am »
He corrected you on using then instead of than, without properly quoting only the relevant part.
 

Offline dgminala

  • Contributor
  • Posts: 21
Re: Divide by 10000000
« Reply #28 on: December 03, 2019, 09:32:07 pm »
The late Ulrich B , made an AVR PPSDIV (Picdiv lookalike)

The M8 version ought to be easy to adapt to an arduino
http://www.ulrich-bangert.de/html/downloads.html

/Bingo

Sorry to resurrect an old thread, but I'm hoping to get a bit of information about the AVR PPSDIV code that Ulrich B posted for a decade frequency divider using  AVR and Mega8 devices.  I'm a complete newbie to the world of microcontrollers and am clueless about assembly code. At this stage of my life, I'm not sure that I want to learn to write it.
There seems to be no documentation about his rewrite of Tom van Baak's project.  Can anyone tell me which model(s) of AVR and Mega8 the code can be written into and work as described?  I'm assuming that the code is specific to only one or very few models.

I have a couple projects in mind that would seriously benefit from a single-chip solution to a decade divider that would, starting with a 10MHz input, provide decade frequency outputs from 1MHz to 1Hz (simultaneously). I realize that the Ulrich B project doesn't provide a 1MHz output, but I could live with an extra divider chip if I could get the rest of the decades in a single chip.  But which chips can I use with this code?

Thanks for any advice,
Dave M


 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: Divide by 10000000
« Reply #29 on: December 04, 2019, 08:03:43 pm »
I think i assembled (compiled) it for a Tiny84 here  (Not tested i real Hw)
https://www.eevblog.com/forum/projects/lars-diy-gpsdo-with-arduino-and-1ns-resolution-tic/msg2042386/#msg2042386

T84 code here
https://www.eevblog.com/forum/projects/lars-diy-gpsdo-with-arduino-and-1ns-resolution-tic/?action=dlattach;attach=597535

This one ought to run on a M8 (Full port D) - You can't use it on an Arduino (board) , as the Arduino Serial port are on Port D  , but you prob. could on a "bare M328"
http://www.ulrich-bangert.de/PPSDividerMega8.zip

/Bingo
« Last Edit: December 04, 2019, 08:42:44 pm by bingo600 »
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6761
  • Country: pl
Re: Divide by 10000000
« Reply #30 on: December 04, 2019, 08:40:20 pm »
ATtiny84 (or 44/24, whichever you can get cheaper) looks like a perfect device. In addition to full PORT A, it has a PWM output right on the next pin after PORT A, which means that 1MHz generation can be added seamlessly by means of a hardware timer.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: Divide by 10000000
« Reply #31 on: December 04, 2019, 08:45:32 pm »
ATtiny84 (or 44/24, whichever you can get cheaper) looks like a perfect device. In addition to full PORT A, it has a PWM output right on the next pin after PORT A, which means that 1MHz generation can be added seamlessly by means of a hardware timer.

Just my thought  - CTC and load (10-1)  into the ocra , pull 1MHz out on the OCRA pin  :-+

/Bingo
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6761
  • Country: pl
Re: Divide by 10000000
« Reply #32 on: December 04, 2019, 08:57:54 pm »
And, with 90% probability, up to nine NOPs to align 1MHz with all the bitbanged clocks ;)
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5317
  • Country: gb
Re: Divide by 10000000
« Reply #33 on: December 05, 2019, 11:33:38 am »
Today’s bloat programmers approach this using all the flash available filling it with nearly 10 million NOPs, two GPIO twiddles and a jump, and have plenty of time to berate the greybeards who achieved the same task in a dozen bytes of object code.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14445
  • Country: fr
Re: Divide by 10000000
« Reply #34 on: December 05, 2019, 06:35:37 pm »
Today’s bloat programmers approach this using all the flash available filling it with nearly 10 million NOPs, two GPIO twiddles and a jump, and have plenty of time to berate the greybeards who achieved the same task in a dozen bytes of object code.

 ;D

But you forgot to add that the end result would probably only meet the specs remotely. So they may end up with a 9999897 division instead. Oh crap, isn't that good enough? The "user story" didn't even state a required tolerance!

Anyway, if you're not happy with it, just create a new "user story". You may get the fix in a few "sprints", if you're lucky (meaning, if other user stories, such as adding a cute blinking LED, are not scheduled first.)  :-DD
 

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
Re: Divide by 10000000
« Reply #35 on: December 05, 2019, 08:00:18 pm »
I can't help with all outputs available at once but I do have some code that will provide switch selectable frequencies from a 10MHz source using an ATtiny85.
Extract from my notes about a GPSDO which I've had running for a while now...

A range of output frequencies is provided by a second ATtiny85 again clocked from the OCXO.
It also provides a fixed 10MHz output from its clock buffer pin.
 
A 10 way switch is used to select frequencies of Off, 5M, 2.5M, 1M, 100k, 10k, 1k, 100, 10 or 1Hz
(Off position ensures no subharmonics on 10MHz output.)
 
ATtiny85 has limited number of I/O pins so resistor chain and (single) Analog Input pin was used.
Running the A/D continuously would compromise output purity so the comparator was used to generate interrupt when switch position changed.
This was achieved by the use of ten resistors in two chains arranged such that odd switch positions give voltages below the internal comparator reference (1.1v) and even positions give voltages above.
The ‘interrupt on comparator change’ function is then used to start the A/D only when required.
(The switch I used was MBB so the wiper was always connected. A stop was required between positions 1 and 10 to avoid shorting the supply.)

(My first attempt at writing AVR assembler so please be gentle, I'm more used to coding with a soldering iron.)


asm & hex files attached in the zip

Jim
« Last Edit: December 05, 2019, 08:04:35 pm by jimmc »
 
The following users thanked this post: edavid

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1926
  • Country: us
Re: Divide by 10000000
« Reply #36 on: December 06, 2019, 07:53:58 pm »
It occurs to me that one could daisy-chain two 16 bit Compare modules in an MCU and create a one-chip purely hardware solution, with one Compare module acting as a prescaler for the other.

Example: In the PIC18F family, Timers can be clocked by an external pin. The associated CCP module can control an output pin. The first CCP can take in the original signal, and its output pin can be hardwired to the input pin of the second Timer. The second CCP's output pin then becomes your divided output signal. You'd have 32 bits of divisor, and by setting that to 50% of the desired value you'd get a 50% duty cycle output waveform implemented purely in hardware. If your use of the output signal is edge sensitive, you're good to go.

The firmware's only job would be to configure the Timer and CCP modules. Thereafter, the hardware would run autonomously with no firmware involvement at all. This completely eliminates the question of firmware latency, eases the fear of those concerned about Assembly language, etc. Just put the firmware in a tight loop that does nothing. It might even be possible to halt code execution to save power and reduce noise. Putting the core into a light sleep mode might do it, many peripheral modules can be configured to continue hardware operation while the core is asleep.

The one hangup is maximum Timer input frequency. A quick glance at the PIC18F family reveals that 10MHz is a bit too fast. But the concept still holds, and other families (from other manufacturers?) may support the frequency in question. Looks like the PIC18F would handle inputs under 5MHz, for example.

Just another way of looking at the "problem". An MCU can sometimes be used as a programmable logic block without direct ongoing firmware involvement.
 

Online Gyro

  • Super Contributor
  • ***
  • Posts: 9485
  • Country: gb
Re: Divide by 10000000
« Reply #37 on: December 06, 2019, 08:02:27 pm »
Today’s bloat programmers approach this using all the flash available filling it with nearly 10 million NOPs, two GPIO twiddles and a jump, and have plenty of time to berate the greybeards who achieved the same task in a dozen bytes of object code.

Oh I don't know, Don Lancaster was using much the same technique to generate video timings back it the '70s.
Best Regards, Chris
 
The following users thanked this post: Howardlong

Online magic

  • Super Contributor
  • ***
  • Posts: 6761
  • Country: pl
Re: Divide by 10000000
« Reply #38 on: December 06, 2019, 09:11:55 pm »
Latest AVRs can cascade timers without wiring up physical pins, and supposedly many ARMs can too.

But really, look at the dates :scared:
You responded to a question asked 2 years ago which has been bumped by somebody with a related but slightly different problem ;)
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1926
  • Country: us
Re: Divide by 10000000
« Reply #39 on: December 06, 2019, 09:18:13 pm »
Yeah, I saw that, but since the thread got resurrected I thought somebody might search it someday.
 

Offline perdrix

  • Frequent Contributor
  • **
  • Posts: 640
  • Country: gb
Re: Divide by 10000000
« Reply #40 on: December 06, 2019, 10:00:26 pm »
I think you'll find that the 2pS figure is in the right ballpark.

The guy who did that really knows his stuff, is a real expert on the bleeding edge of precision timekeeping.

David
 

Offline eb4fbz

  • Regular Contributor
  • *
  • Posts: 178
  • Country: es
Re: Divide by 10000000
« Reply #41 on: December 06, 2019, 10:34:50 pm »
I think you should never use interrupts for this because the unpredictable interrupt latency would introduce some jitter. Just nops and loops should be fine.
 

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
Re: Divide by 10000000
« Reply #42 on: December 07, 2019, 04:51:22 pm »
I think you should never use interrupts for this because the unpredictable interrupt latency would introduce some jitter. Just nops and loops should be fine.

In general I would agree, however if the MCU does nothing but sleep waiting for an interrupt which is synchronous with the system clock then latency is fixed and not a problem.
In the example I posted earlier there are two sources of interrupts, Timer1 which meets the above criteria and Analog comparator which is effectively resets everything.


Jim
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5317
  • Country: gb
Re: Divide by 10000000
« Reply #43 on: December 08, 2019, 01:06:55 am »
Today’s bloat programmers approach this using all the flash available filling it with nearly 10 million NOPs, two GPIO twiddles and a jump, and have plenty of time to berate the greybeards who achieved the same task in a dozen bytes of object code.

Oh I don't know, Don Lancaster was using much the same technique to generate video timings back it the '70s.

Back in those days such jiggery pokery was for sound engineering reasons, where the overriding design axiom was to keep costs down: it also coincided with a golden age when real programmers knew the cycle count of each instruction and cared about code size, speed and determinism... I am not sure many of today’s programmers would know where to start on those facets!
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1987
  • Country: dk
Re: Divide by 10000000
« Reply #44 on: December 10, 2019, 04:53:38 pm »
I think you should never use interrupts for this because the unpredictable interrupt latency would introduce some jitter. Just nops and loops should be fine.

Arm NVIC has predictable IRQ's , that was a design goal in the Cortex.

But a decent ARM , prob has enough 32 & 16 bit timers + OCR regs to do it all from timers ... 5..10 outputs.
NXP used to have several 32bit timers , and TI too , STM has a few in the larger packets.

/Bingo
 

Offline wilfred

  • Super Contributor
  • ***
  • Posts: 1252
  • Country: au
Re: Divide by 10000000
« Reply #45 on: December 10, 2019, 11:02:21 pm »
Back in those days such jiggery pokery was for sound engineering reasons, where the overriding design axiom was to keep costs down: it also coincided with a golden age when real programmers knew the cycle count of each instruction and cared about code size, speed and determinism... I am not sure many of today’s programmers would know where to start on those facets!

Are you quite sure it was a golden age? You CAN still do it. But all the intervening development has been to allow you the luxury of not having to.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf