Author Topic: Divide by 10 cct needed  (Read 10149 times)

0 Members and 4 Guests are viewing this topic.

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Divide by 10 cct needed
« Reply #25 on: July 01, 2026, 01:23:28 pm »
Quote
8 pin 14,250 in stock, $0.2194 each for 5+
plus at least £100 for something to get the program from yer brain into the chip.

Would you believe $7.50 for a mini dev board for prototyping, a USB programmer/debugger interface, AND a usb cable?

https://www.aliexpress.com/item/1005005221751705.html

I assume you already own a computer of some kind, otherwise you would not be posting here.

You do need to supply your own Dupont leads.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Divide by 10 cct needed
« Reply #26 on: July 01, 2026, 03:08:27 pm »
Here's code for the divide by 10 that should work on an 8 pin CH32V003. The same technique used for the AVR example would also work on the CH32V003 and give nice precise timing, but here I show running at 48 MHz and having the hardware sample the input pin at 48 MHz, which will result in a little jitter on the 1 MHz output (up to 21ns). If that is not acceptable then use the external clock technique.

Presented without comments to illustrate the shortness of the program. If you want a commented version for actual use lmk.

There is plenty of example code around (including for STM32F1 (etc) which has nearly identical peripherals. Or, it's easily in range of vide coding in a couple of minutes with a short English description.

Uses pin PC2 for the input signal, PC4 for the output which toggles every 5 input edges (both pos and neg). Will work at up to 36 MHz input.

Code: [Select]
#include "ch32fun.h"

static void div10_init(void)
{
  RCC->APB2PCENR |= RCC_APB2Periph_GPIOC | RCC_APB2Periph_TIM1;
  RCC->APB2PRSTR |= RCC_APB2Periph_TIM1;
  RCC->APB2PRSTR &= ~RCC_APB2Periph_TIM1;
 
  GPIOC->CFGLR &= ~(0xf << (4 * 2));
  GPIOC->CFGLR |= (0x4) << (4 * 2);
  GPIOC->CFGLR &= ~(0xf << (4 * 4));
  GPIOC->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP_AF) << (4 * 4);
 
  TIM1->PSC = 4;
  TIM1->ATRLR = 0;
  TIM1->CH4CVR = 0;
  TIM1->SWEVGR |= TIM_UG;
  TIM1->CHCTLR2 |= (TIM_OC1M_1 | TIM_OC1M_0) << 8;
  TIM1->CCER |= TIM_CC4E;
  TIM1->BDTR |= TIM_MOE;
  TIM1->SMCFGR |= (1 << 14);
  TIM1->CTLR1 |= TIM_CEN;
}

int main(void)
{
  SystemInit();
  div10_init();
  while (1) __WFI();
}
 

Offline METopic starter

  • Frequent Contributor
  • **
  • Posts: 687
  • Country: gb
Re: Divide by 10 cct needed
« Reply #27 on: July 01, 2026, 07:19:53 pm »
I may add a slide switch on the 2955 ocxo output.
 

Offline METopic starter

  • Frequent Contributor
  • **
  • Posts: 687
  • Country: gb
Re: Divide by 10 cct needed
« Reply #28 on: July 01, 2026, 07:25:15 pm »
I have a blu-pill and an arduino nano, can i use them?.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 4164
  • Country: us
Re: Divide by 10 cct needed
« Reply #29 on: July 01, 2026, 07:49:15 pm »
The AVR code I posted about should work unchanged for the Nano.

You can test it by uploading the code and checking the frequency at D9 - you should see the divided frequency on that pin (16 MHz divided down).

Then you have to desolder the onboard crystal (or cut some traces) and feed your 10 MHz input signal into the 328's pin 9.
« Last Edit: July 01, 2026, 07:53:21 pm by ledtester »
 

Offline themadhippy

  • Super Contributor
  • ***
  • Posts: 4551
  • Country: gb
Re: Divide by 10 cct needed
« Reply #30 on: July 01, 2026, 08:03:29 pm »
Quote
I assume you already own a computer of some kind, otherwise you would not be posting here.
never ass u me ,could be using a phone,or a works machine were you aint allowed to install software on,might even be using a pc down the local library
 

Offline Uunoctium

  • Frequent Contributor
  • **
  • Posts: 517
  • Country: de
Re: Divide by 10 cct needed
« Reply #31 on: July 01, 2026, 08:26:54 pm »
tl;dr
my solution is a piece of wire + switch
since that analyzer is anyway running at internal 10MHz
 
The following users thanked this post: neillnz, ME

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3351
  • Country: au
Re: Divide by 10 cct needed
« Reply #32 on: July 01, 2026, 10:05:51 pm »
Using a micro controller to devide by ten... and a 74HC4017 is a specialized component!

It depends on the lens you use.
Bruce is using a MCU lens, the logic has a single function, so that makes it 'specialized'.

Of course those buying CMOS logic use a different lens. Any Logic part is of course single function, so a part that is single sourced and hard to procure is called specialized.

A part that is multi sourced and well stocked at low prices, is not considered specialized at all - we would call that part generic or jellybean.  8)
 
The following users thanked this post: Benta, ME

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 3351
  • Country: au
Re: Divide by 10 cct needed
« Reply #33 on: July 01, 2026, 10:56:06 pm »
Here's code for the divide by 10 that should work on an 8 pin CH32V003. The same technique used for the AVR example would also work on the CH32V003 and give nice precise timing, but here I show running at 48 MHz and having the hardware sample the input pin at 48 MHz, which will result in a little jitter on the 1 MHz output (up to 21ns). If that is not acceptable then use the external clock technique.

For metering and RF work, that jitter is certainly a problem.
But hey, When all you have is a hammer, every problem becomes a Nail.  :-DD

A higher power solution than a jellybean CMOS counter with more jitter and way more man-hours, but lookie here, the list price is 10c lower ! :palm:
 
The following users thanked this post: Someone, Benta

Offline CaptDon

  • Super Contributor
  • ***
  • Posts: 2612
  • Country: is
Re: Divide by 10 cct needed
« Reply #34 on: July 02, 2026, 12:13:17 am »
There are several /10 choices in the TTL family. Even the simple 7490. I probably have about 10 each of 7490 and 74LS90 here on hand. If you connect the /5 section first driving the /2 section you get a square wave output. There are also the up/down counter versions and preset able versions. Does ME have any hobbyist friends? Even the old Radio Shack sold 7490's as well as JimPacks.
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7175
  • Country: de
Re: Divide by 10 cct needed
« Reply #35 on: July 02, 2026, 12:39:56 am »
The AVR code I posted about should work unchanged for the Nano.

You can test it by uploading the code and checking the frequency at D9 - you should see the divided frequency on that pin (16 MHz divided down).

Then you have to desolder the onboard crystal (or cut some traces) and feed your 10 MHz input signal into the 328's pin 9.

"AVR code", "should". "test".  "checking". "cut some traces". "desolder".

I feel I'm looking into some kind of a parallel universe here, where only coding counts and basic electronic skills are completely absent. It's scary.
People calling a 4017 counter (or even any counter) "specialized" although it belongs to the "standard logic" portfolio at any manufacturer is so weird.

74HC190 built as a "dead bug" circuit will take about 5 mins of soldering and work out-of-the-box.
No debugging/checking etc. required, the manufacturer did that for you.

But it doesn't allow posting "coding skills", which is unfortunately sad for the coder...

« Last Edit: July 02, 2026, 12:42:24 am by Benta »
 

Offline temperance

  • Super Contributor
  • ***
  • Posts: 1609
  • Country: 00
Re: Divide by 10 cct needed
« Reply #36 on: July 02, 2026, 01:42:17 am »
Quote
I feel I'm looking into some kind of a parallel universe here, where only coding counts and basic electronic skills are completely absent. It's scary.

Dinosaurs capable of soldering naked transistors together are rare these days. Why code seems to win is because of how students are being educated I think. 1 semester covers all basic semiconductors. But learning about micro controllers and coding takes place over several semesters. The best part: they don't learn proper coding skills either. A super loop or interrupt driven architecture is what most learn about and a few simple structures like circular buffers.

On the first job, real life comes to visit the ego. After a few weeks, they find themself at the bottom of a very steep hill.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 19210
  • Country: us
  • DavidH
Re: Divide by 10 cct needed
« Reply #37 on: July 02, 2026, 02:47:06 am »
A divide by 10 is within reach of an injection locked LC or Wien bridge oscillator, so the entire divide by 10 can be made with a single transistor or operational amplifier.  Some old frequency counters did exactly this to support an external frequency input which could be 1, 2, 5, or 10 MHz.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Divide by 10 cct needed
« Reply #38 on: July 02, 2026, 03:55:55 am »
Here's code for the divide by 10 that should work on an 8 pin CH32V003. The same technique used for the AVR example would also work on the CH32V003 and give nice precise timing, but here I show running at 48 MHz and having the hardware sample the input pin at 48 MHz, which will result in a little jitter on the 1 MHz output (up to 21ns). If that is not acceptable then use the external clock technique.

For metering and RF work, that jitter is certainly a problem.

But not for others. If ±10ns of jitter on a 1 MHz wave is a problem then use the same approach as shown for the AVR of using the 10 MHz signal as the MCU clock. That's fine if the 10 MHz is always there. If you're doing a generic "divide by 10" on a highly variable input signal then the alternative approach I showed is better.

Quote
A higher power solution than a jellybean CMOS counter

Not much. Seems 74HC4017 is going to use 2-3 mA. The CH32V003 is going to use 3-5 mA. Pretty close. But you might use it for other functions at the same time (especially since the actual CPU is idle after initialisation), saving on BoM, board space etc.

Quote
way more man-hours, but lookie here, the list price is 10c lower ! :palm:

I can literally set up that MCU-based solution in 10 or 15 minutes. I'm sorry if you can't. Designing with digital logic ICs is also in my skill-set (for 40+ years).

The lower price is a bonus, but the MAIN advantage is that you can keep a good number of MCUs on hand because they can be used for an unlimited number of applications as long as they don't require the ultimate in performance.

 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Divide by 10 cct needed
« Reply #39 on: July 02, 2026, 04:09:51 am »
I feel I'm looking into some kind of a parallel universe here, where only coding counts and basic electronic skills are completely absent. It's scary.

Who says they are absent?

I was building electronic kits in the 70s. Some AY-3-8500 pong/soccer etc, and AY-3-8710 tank battle. A "car" cassette player kit from David Reid (which I used in my bedroom as a teen/uni student). Designed my own projects using 555s and 741s and 74-series and transistors, generally on veroboard. By 1983 I'd moved on to designing and building my own 6502 and M6809 boards. Combine a 6502 with a 6532 RIOT (RAM, I/O, Timer) and a small EPROM and you've basically got a microcontroller.

Quote
74HC190 built as a "dead bug" circuit will take about 5 mins of soldering and work out-of-the-box.

IF you have one on hand. I have some 74-series chips on hand, but not one of those. I have a bag of MCUs.

Quote
But it doesn't allow posting "coding skills", which is unfortunately sad for the coder...

BOTH are important. MCUs have been around for 45+ years . .the Intel 8051 was 1980, and still in use.

Sad if you don't have coding skills at this point.
 

Offline Andy Chee

  • Super Contributor
  • ***
  • Posts: 2098
  • Country: au
Re: Divide by 10 cct needed
« Reply #40 on: July 02, 2026, 10:35:02 am »
you can make divide by 10 cct using a SPLD like GAL22V10 / ATF22V10
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 11157
  • Country: gb
Re: Divide by 10 cct needed
« Reply #41 on: July 02, 2026, 11:32:43 am »
This thread has left me pondering on how many transistors it takes to do a simple low jitter divide of 10MHz. The extremes are, well, extreme.
Best Regards, Chris
 

Offline eugene

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: us
Re: Divide by 10 cct needed
« Reply #42 on: July 02, 2026, 01:16:05 pm »
Another solution would be to just get a 10MHz 1MHz crystal and be done with it.   :-DD

Seriously, I'm in the MCU camp. I have a bunch of 6 pin AVRs that I bought for ~$0.50 each. Taking ledtester's advice, I would use one of those. But honestly, I don't care what anyone else would do. That's their choice.
« Last Edit: July 02, 2026, 01:18:07 pm by eugene »
90% of quoted statistics are fictional
 

Offline ftg

  • Frequent Contributor
  • **
  • Posts: 500
  • Country: fi
    • ftg's RF hax paeg
Re: Divide by 10 cct needed
« Reply #43 on: July 02, 2026, 01:45:25 pm »
And I would be in the 74-series camp.
Less jitter, easier build and no need to deal with software.
No IDE's, compilers or programmers required, just solder.  :)
 

Offline nonius_

  • Regular Contributor
  • *
  • Posts: 168
  • Country: nl
Re: Divide by 10 cct needed
« Reply #44 on: July 02, 2026, 02:01:40 pm »
+1

Am definitely in the solder-camp too. 'Solder is my programming language' :) Have drawers full of TTL & CMOS IC's, just have to get out of my office chair and walk 4m to the drawer with 7490s, but I'd have to order a microcontroller. (plus a programmer, install the software and learn to program. And I *HATE* programming, though I was once quite good at it, back in the days of C).

A TTL or CMOS /10 divider seems so obvious I'm surprized alternatives are even mentioned. Here I was thinking that this was an electronics forum, not GitHub :)

That being said, it's all irrelevant now, since Uunoctium showed the most elegant solution using nothing but a piece of wire (coax?) and a switch....
set SCE to AUX
 

Offline eugene

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: us
Re: Divide by 10 cct needed
« Reply #45 on: July 02, 2026, 02:15:51 pm »
And I would be in the 74-series camp.
Less jitter, ...

As I already said, I have no interest in talking anyone out of their preferred solution, but this jitter I keep reading about is fake news.
90% of quoted statistics are fictional
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 19210
  • Country: us
  • DavidH
Re: Divide by 10 cct needed
« Reply #46 on: July 02, 2026, 04:06:33 pm »
And I would be in the 74-series camp.
Less jitter, easier build and no need to deal with software.
No IDE's, compilers or programmers required, just solder.  :)

Most logic has poor power supply rejection; as the supply voltage changes, the logic threshold changes creating jitter.  For small scale integration like TTL or CMOS series gates, it is possible to closely regulate the voltage at the supply pin to minimize this jitter.  But for large scale integration like a microcontroller or especially FPGA, this becomes essentially impossible and jitter becomes much higher even when cycle accurate programming is used.

There are a some ways to improve the situation.  Output signals can be reclocked using an external flip-flop.  Alternatively, inherently low jitter logic can be used like ECL.

Shown below is jitter caused by a TTL divider chain modulating the supply voltage to a poorly implemented TTL delay circuit.  Fix the delay circuit and the shown jitter would be considerably reduced.  The fast pulse edge itself is coming from discrete ECL.  The slight linear slope after the edge might be cable droop.
« Last Edit: July 02, 2026, 04:08:52 pm by David Hess »
 
The following users thanked this post: oPossum, Ian.M

Offline Benta

  • Super Contributor
  • ***
  • Posts: 7175
  • Country: de
Re: Divide by 10 cct needed
« Reply #47 on: July 02, 2026, 05:37:33 pm »
So an AVR would be better on this point?   :-//
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 9063
  • Country: ca
Re: Divide by 10 cct needed
« Reply #48 on: July 02, 2026, 06:09:28 pm »
I think you want zero MCU intervention - a timer/counter that can be clocked by an external pin, output compare to another pin.
But all MCU's use a synchronizer latch FF on GPIO pin inputs, fed by the I/O clock. So you'd get quantized jitter me thinks.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 4164
  • Country: us
Re: Divide by 10 cct needed
« Reply #49 on: July 02, 2026, 06:48:50 pm »
In the AVR code the 10 MHz signal does not go through a GPIO pin. Rather, it is used as the CPU clock and a timer is configured to toggle an output pin every 5 cycles.

 
The following users thanked this post: eugene


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->