Giter Site home page Giter Site logo

stateoff / pico_frequency_finder Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

Finds the closest possible clocks to a given frequency for the Raspberry Pi Pico

License: MIT License

Python 100.00%
overclocking raspberry-pi raspberry-pi-pico rp2040

pico_frequency_finder's Introduction

๐Ÿ” ๐Ÿ• Pico Frequency Finder

Finds the closest possible clocks to a given frequency for the Raspberry Pi Pico. The output is a CSV formatted list. This tool uses vcocalc.py from the pico-sdk and just makes it convenient to compare various frequency multipliers quickly.

Getting started

  1. Install python 3.x
  2. Clone
[email protected]:StateOff/pico_frequency_finder.git
cd pico_frequency_finder
  1. Set PICO_SDK_PATH to a local clone of the pico-sdk
# Linux
export PICO_SDK_PATH="/home/stateoff/pico-sdk"

# Windows (cmd)
set PICO_SDK_PATH="C:\pico-sdk"
  1. Run with a requested frequency as argument.
python frequency_finder.py --all --min_freq 50 --max_freq 180 3.579545454545454545
  1. Sample output
             Error, Mult,        Requested Freq,         Achieved Freq,    Over-/Undercl,  FBDIV,   VCO,  PD1,  PD2
0.0000000000000000,   22,   78.7500000000000000,   78.7500000000000000,       -46.250000,    105,  1260,    4,    4
0.0048701298701275,   17,   60.8522727272727266,   60.8571428571428541,       -64.142857,     71,   852,    7,    2
0.0097402597402549,   34,  121.7045454545454533,  121.7142857142857082,        -3.285714,     71,   852,    7,    1
0.0113636363636402,   19,   68.0113636363636402,   68.0000000000000000,       -57.000000,    119,  1428,    7,    3
0.0211038961038952,   15,   53.6931818181818201,   53.7142857142857153,       -71.285714,     94,  1128,    7,    3
0.0259090909090958,   13,   46.5340909090909065,   46.5600000000000023,       -78.440000,     97,  1164,    5,    5
...

Help

usage: frequency_finder.py [-h] [--all] [--max_freq MAX_FREQ] [--min_freq MIN_FREQ] [--input_freq INPUT_FREQ] [--version] requested_freq

Finds the closest possible clocks to a given frequency for the Raspberry Pi Pico.
This tool is based on the `vcocalc.py` tool from the pico-sdk.

Make sure to set the PICO_SDK_PATH environment variable.

Columns Description:
    Error -> Absolute difference between requested (multiplied) and achieved frequency
    Mult -> Integer multiplier of the requested frequency
    Requested Freq -> Multiplied Requested Frequency (requested_freq * Mult)
    Achieved Freq -> Possible frequency
    Over-/Undercl -> Difference to given input frequency
    FBDIV -> Feedback Divider
    VCO -> Voltage Controller Oscillator frequency (fbdiv * crystal_freq_khz)
    PD1 -> First Post Divider
    PD2 -> Second Post Divider
    
positional arguments:
  requested_freq        Desired frequency

options:
  -h, --help            show this help message and exit
  --all                 Print all result, by default the closest match(es) will be shown
  --max_freq MAX_FREQ   The maximum frequency the CPU can be overclocked to
  --min_freq MIN_FREQ   The minimum frequency the CPU can run with
  --default_freq INPUT_FREQ
                        The default CPU frequency used to calculate over-/underclock
  --version             Show version and exit

License & Credits

This tool depends on the vcocalc.py tool in the pico-sdk by raspberry pi.

Written by Blazej Floch.

MIT compare LICENSE

pico_frequency_finder's People

Contributors

bfloch avatar

Watchers

 avatar

pico_frequency_finder's Issues

vcocalc.py output format has changed

The changes broke this script. Suggested modifications:

diff --git a/frequency_finder.py b/frequency_finder.py
index 72ce83f..cb7be5b 100644
--- a/frequency_finder.py
+++ b/frequency_finder.py
@@ -52,7 +52,7 @@ CALC_SCRIPT_CMD = [
     CALC_SCRIPT_PATH
 ]

-PAT_RESULT = re.compile(r'Achieved: (\d+[.]\d+) MHz\nFBDIV: (\d+) [(]VCO = (\d+) MHz[)]\nPD1: (\d+)\nPD2: (\d+)')
+PAT_RESULT = re.compile(r'Achieved: (\d+[.]\d+) MHz.*\n.*\nFBDIV: (\d+) [(]VCO = (\d+[.]\d+) MHz[)].*\nPD1: (\d+).*\nPD2: (\d+)')


 def get_achieved_frequency(requested_freq: float) -> dict:
@@ -69,7 +69,7 @@ def get_achieved_frequency(requested_freq: float) -> dict:
     return {
         "freq": float(match[0][0]),
         "fbdiv": int(match[0][1]),
-        "vco": int(match[0][2]),
+        "vco": float(match[0][2]),
         "pd1": int(match[0][3]),
         "pd2": int(match[0][4]),
     }
@@ -117,6 +117,8 @@ if __name__ == '__main__':
     args = parser.parse_args()

     min_multiplier = math.floor(args.min_freq / args.requested_freq)
+    if (min_multiplier < 1):
+        min_multiplier = 1
     max_multiplier = math.floor(args.max_freq / args.requested_freq)
     default_freq = args.default_freq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.