Skip to the content
PCBKitNew board
2 layers47 × 72.1 mmTinyFreqCounter, the printed circuit board in 3D

TinySeqCounter PCB or generic 7seg x 3digit pcb

Size
47 × 72.1 mm
Copper layers
2
Thickness
1.6 mm
Parts
19
Nets
38
Pads
260
Tracks, vias
201, 3
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
13 Jun 2023
Updated
13 Jun 2023

Overview

TinyFreqCounter is an open-source printed circuit board by tendai22, from the tendai22/TinySeqCounter_pcb repository on GitHub, published under the MIT licence. It is a 2-layer board of 47 × 72.1 mm with 19 parts on 38 nets, routed with 201 tracks and 3 vias.

Its parts include 10 resistors, 3 connectors, 2 ICs, 1 capacitor and 1 diode. It belongs with the PIC boards of this library.

README

README.md

TinyFreqCounter

A little 3 digit 7 segment LED display with a simple Frequency counter, for a companiou unit of retroPC SBC's.

可愛い3桁7セグメントLED表示器です。レトロCPU基板のCPUクロック周波数表示のために作りました。PIC18F27Q43のカウンタがいい感じで3種類あったので、外付けプリスケーラなしで1チップでできました。

3桁LEDディスプレイとPIC18Fの2チップ構成です。秋月C基板サイズ(72mm x 47mm)の上半分がLEDとPIC18Fチップで、下半分は蛇の目パターンにしてあります。簡単なセンサと組み合わせて無骨な温度計なんてのもありです。

レトロPCの外部クロック発生器を74HCU04と水晶でつくると、簡単な周波数カウンタとなります。

PICのファームウェアは https://github.com/tendai22/TinySeqCounter.git にあります。

周波数カウンタ

おおよそ100kHz~33MHzの範囲のクロックパルスを生成させ、CPUに食わせます。その時7セグLEDで周波数を表示させれば写真映えすると期待できます。

分解能として10進3桁、2進数で1024~2048の範囲の値を得て、そこから周波数3桁を定数を掛けたり割ったりして算出します。

周波数カウンタとしては、一定時間内のパルス数をカウントする方式です。測定時間は32.768msとします。を一定にしてプリスケーラを変えて測定終了し、結果を算出し表示します。1024~2048の範囲とは、10進数3桁に相当します。カウント後最下位ビットを見て「0捨1拾」して切りのいい数字にまとめます。

1MHz以上の範囲では、プリスケーラの分周数を次第に大きくしてオーバフローが収まり、カウント数が1024~2047の範囲になったところで測定終了、表示更新となります。

1MHz未満の範囲では、プリスケーラを1/1としてカウント数を32で割った値を周波数(kHz単位)とします。

7セグメントディスプレイ

なんの変哲もない素のダイナミック点灯です。1桁8msごとに更新して、ちらつきをなくしています。

クロックジェネレータ

蛇の目部分に手配線で構成します。回路図と配線図は以下の通り。


図1: クロックジェネレータ回路図

図2: パターン配線図

設計メモ

周波数カウンタ機能

まず、クロックパルスを数えるカウンタ、数える期間を算出するカウンタが必要になる。前者はTIM0, 後者をTIM1で行く。TIM0が持つ幅広い範囲のプリスケーラを活用することで、外付けプリスケーラが不要となった(4060を買っていたが)。

TIM1は測定期間を決めるタイマとして使う。Foscを4分周したものをTIM1に入れ、プリスケーラ1/8で16ビットカウンタとして使うと、16bitがあふれるまでの時間が32.768msとなり、これを測定期間とする。

入力クロックパルスの周波数をいくつか選び、分周比をいくらにすると32.768msの間に1024~2048パルスになるかを計算すると以下の表を得る。

入力周波数プリスケーラ
分周比
パルス幅カウント
100MHz1/204810.24us1600
10MHz1/25625.6us1280
1MHz1/3232us1024

100MHz~1MHzの範囲でプリスケーラを調整すると上の表を得る。 TIM0のプリスケーラ分周比は1/1から1/65536まで16段階で選べるので、この周波数範囲ならば10進数で有効数字3桁は問題なく確保できる。

1MHz~1kHzの範囲では、プリスケーラ分周比を1/1とする。すると、

入力周波数プリスケーラ
分周比
パルス幅カウント
1000kHz1/11us32768
100kHz1/110us3276
10kHz1/1100us327
1kHz1/11000us32

となる。1kHz以下の精度は不要なので、この範囲では分周比1/1固定としてカウントを得ることにする。

7セグメントLEDダイナミック駆動

RC0-7をセグメントに割り当て、RB0-2を桁駆動に割り当てる。RC0-7側に電流制限抵抗(150ohmを選択)をつける。アノードコモン、カソードコモンどちらでもソフトで対応できると考える。

当初、周波数カウンタの測定期間32.768msを駆動周波数としてみたが、ちらつきが多く耐えられない。試行の結果、この1/4周期の8.192msでちらつきを抑えることができた。

TIM1を8.192msとして、4回ごとに測定を行うことにする。タイマがあと1つ(TIM2)使えるのでそれでダイナミック駆動することも考えたが、リフレッシュ処理の割り込みと測定周期が非同期となりはまり具合が予想できないので、リフレッシュ処理と測定のタイマを共通とし、一つの割り込み処理ルーチンの中で両処理を行うこととする。

ピンアサイン

試作により周波数カウンタ機能とダイナミック駆動の処理を確認できたので、ピンアサインを確定させた。

ピン割り当て機能説明
RB7,6ICSPCLK,
ICSPDAT
これは固定で他の割り当てはできない。他との共用も避けた。
RB5,4TX1,RX1シリアルポートをここに割り当てる。
RB3T0CKIクロックパルスをここに入力する。74HCU04による発振器だけでなく、SBCのPICが生成するクロックをここにつないでもよい。
RB0-2LED DIG1-37セグLEDのコモン端子3本を割り当てる
RC0-7LED A-F7セグLEDのセグメント7個と小数点1個を割り当てる

PIC18Fのピン割り当ての柔軟さにより、RA0-7に手を付けずに周波数カウンタが実現できた。

Parts

19
QtyValueFootprintReferences
8150Resistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1, R2, R3, R4, R5, R6, R7, R8
210kResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR9, R10
10.1uFCapacitor_THT:C_Disc_D3.0mm_W2.0mm_P2.50mmC1
11N4148Diode_THT:D_DO-35_SOD27_P7.62mm_HorizontalD1
1CLKIOConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ2
1OSL-305610-local:OSL-30561_no_courtyardU2
1PIC18F27Q43-IPPackage_DIP:DIP-28_W7.62mmU1
1SNAPConnector_PinHeader_2.54mm:PinHeader_1x06_P2.54mm_VerticalJ1
1SW_Push0-local:SW_PUSH_6mm_H4.3mmSW1
1SerialConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ3

The 18 most common of 19 parts.

Questions

How big is the TinyFreqCounter PCB?

It measures 47 × 72.1 mm and has 2 copper layers, 1.6 mm thick.

What parts does the TinyFreqCounter use?

19 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the TinyFreqCounter KiCad files?

From the tendai22/TinySeqCounter_pcb repository on GitHub, at the commit this page was made from: the board is TinyFreqCounter.kicad_pcb and its schematic TinyFreqCounter.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the TinyFreqCounter design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers43.9 × 27.7 mmTcd1304-4v, the printed circuit board in 3D

    Tcd1304-4v

    OpnTec/open-spectrometer-hardware

    Open source VIS spectrometer

    19 parts1.5k
  • 2 layers50 × 60 mmDebate Device, the printed circuit board in 3D

    Debate Device

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    19 parts915
  • 2 layers102.9 × 96.7 mmISA adapter, the printed circuit board in 3D

    ISA adapter

    polpo/picogus

    Emulation of ISA sound cards and CD-ROM on Raspberry Pi Pico (GUS, SB/Adlib, MPU-401, Tandy, CMS, Panasonic CD-ROM) with USB mouse/joystick support

    19 parts805
  • 2 layers60 × 39 mmPs2usb, the printed circuit board in 3D

    Ps2usb

    rasteri/HIDman

    Adapting USB devices to work on old computers

    19 parts432
  • 2 layers70.1 × 43.2 mmIaq device, the printed circuit board in 3D

    Iaq device

    nkitanov/iaq_board

    IAQ Board is a DIY (Do-It-Yourself) device for measuring internal air quality

    19 parts396
  • 2 layers80 × 80 mmGB BRK CPU G1, the printed circuit board in 3D

    GB BRK CPU G1

    Gekkio/gb-hardware

    Game Boy -related custom hardware by gekkio

    19 parts379CC-BY-4.0
  • 2 layers25.4 × 25.4 mmIna169, the printed circuit board in 3D

    Ina169

    Ardumower/ardumower

    Develop an open source robotic lawn mower (HW+SW reference platform)

    19 parts282
  • 2 layers58.4 × 28.6 mmNew rele, the printed circuit board in 3D

    New rele

    zmaker/arduino_cookbook

    gli sketch del nuovo progetto Arduino Cookbook e dei video di YouTube

    19 parts269