Code Monkey home page Code Monkey logo

arduino-web-timers's Introduction

"Buy Me A Coffee"

Arduino Web Timers

image

Application to configure and visualise timers. All your changes are stored in the url, bookmark and share configured timers!

Supported microcontrollers:

  • Atmel atmega328p (e.g Arduino Uno, Nano, Pro-mini)
  • Atmel atmega328pb (newer, some times found in pro-minis)
  • Logic Green lgt8f328p checkout this core
  • If people uses this, I can add more (e.g attiny)

Supported timers (all!)

  • Timer0
  • Timer1
  • Timer2
  • Timer3 (lgt8f328p and atmega328pb)
  • Timer4 (atmega328pb)

Supported modes (all!)

  • Normal
  • Fast PWM
  • CTC
  • Phase Correct PWM
  • Frequency Phase Correct PWM

Supported features (all!)

  • Code Generation
  • Output Compare Match Interrupts
  • Input Compare Interrupt
  • All output generation modes
  • Select output pins
  • Clock prescalers
  • External clock
  • Dead Time
  • Timer clock speed doubling
  • High current output
  • Port muxing
  • ...

How does this work?

  • I manually extracted all relevant tables from the microcontrollers' datasheets and stored them as tab separated value (tsv) tables. Here is atmega328p timer0 for example.
  • There you'll find 2 kinds of data:
    • Registers: One register per column, each cell is the name of a bit.
    • Constraints: Each column represents a variable (can be a bit of a register or some UI input or output). Each row is a possible valid combination of values assigned to variables.
  • When the user selects any checkbox, the possible values of the variable it represents is reduced to only what's selected
  • A custom constraint solver finds out what values are possible for each of the other variables and the rest is disabled in the UI (note that tables are interconnected when they share variables)
  • Given the user selection, a suggestion for all other variables is created one by one by:
    • Computing the viable values of a variable
    • Picking the first viable value for that variable
    • Repeating until all variables have only one viable value
  • Finally the values of variables are used to run the simulation (plot) and write the code & comments.
  • The code output is generared by iterating over each regiser and picking the bits that are set to one.
  • The computation of frequency and period is made in fractional math (not floats) to ensure the results are exactly correct.

A fun fact: I learned a lot about timers myself while creating this web app, but even more by playing with it! You can see all internal variables the constraint solver sees by switching to "With internals" at the top right of the screen.

--

Development

npm install npm run start

Deployment

A Gihub action for deployment is automatically triggered on each commit to master.

It can also be done locally via: npm run deploy

arduino-web-timers's People

Contributors

dbuezas avatar

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.