{"id":20275120,"url":"https://github.com/luni64/encsim","last_synced_at":"2025-10-29T06:19:27.669Z","repository":{"id":97960606,"uuid":"93673420","full_name":"luni64/EncSim","owner":"luni64","description":"Quadrature signal generator for testing encoder software. Requires a PJRC Teensy board. Generates quadrature signals with adjustable frequency, phase and bouncing","archived":false,"fork":false,"pushed_at":"2022-05-16T15:36:55.000Z","size":835,"stargazers_count":18,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-09T19:25:33.595Z","etag":null,"topics":["arduino","bounce","chatter","encoder","index-signal","quadrature","teensy"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luni64.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-06-07T19:48:09.000Z","updated_at":"2025-06-24T11:00:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"c105f95c-c304-4eb2-b25f-abbd612cfc49","html_url":"https://github.com/luni64/EncSim","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/luni64/EncSim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luni64%2FEncSim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luni64%2FEncSim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luni64%2FEncSim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luni64%2FEncSim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luni64","download_url":"https://codeload.github.com/luni64/EncSim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luni64%2FEncSim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281571919,"owners_count":26524096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","bounce","chatter","encoder","index-signal","quadrature","teensy"],"created_at":"2024-11-14T13:08:04.081Z","updated_at":"2025-10-29T06:19:27.664Z","avatar_url":"https://github.com/luni64.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EncSim\n- [Library Description](#library-description)\n- [Serial Interface](#serial-interface)\n- [API](#api)\n\n## Library Description \nEncSim is a library for the PJRC Teensy ARM boards (T3.0 - T3.6, T4.0, T4.1). It can be used for testing the performance of encoder libraries and/or hardware in a manual or automated test environment. It generates a quadrature signal which simulates optical or mechanical incremental [encoders](https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder). You can adjust the **direction**, **count rate** and the **phase** of the generated signal. For simulating mechanical encoders you can add  random [**contact bouncing**](https://en.wikipedia.org/wiki/Switch#Contact_bounce) (aka chatter) peaks to the signal. EncSym uses the [TeensyTimerTool](https://github.com/luni64/TeensyTimerTool) for generation of the quadrature signal and the random bounce peaks.\n\n### Key Features\n- Easy to use interface to control signal generation with a serial terminal.\n- Count frequency adjustable.\n- Signal phase adjustable from 90° (standard) to 10°.\n- Generates index pulses with settable distance for e.g., simulating rotary encoders with index signal.\n- Bouncing:\n  - Total bounce time adjustable.\n  - Minimum width of random bounce peaks adjustable.\n  - Maximum width of random bouce peaks adjustable.\n- Programming API for use in own sketches, automated tests or simular applications.\n\n**Precompiled Firmware** \nIf you just want to use EncSym for testing your encoder library you do not need to install EncSim. You can download precompiled hex files for various Teensy boards instead. Just upload the firmware, open a serial terminal (arduinos serial monitor, [TyCommander](https://github.com/Koromix/tytools),  [PuTTY](http://www.putty.org/), ...) and start testing. Precompiled firmware for various boards can be downloaded from [here](https://github.com/luni64/EncSim/tree/master/examples/SerialControl/precompiled_binaries).\n\n\n### Examples of generated signals\n**Bouncing:** \nThe follwing two images show the simulation of a mechanical encoder. The pulse rate was set to 50Hz and a total bounce time of 5 ms was choosen. The min and max duration of the bounce pulses was set to 20µs and 500µs respectively. The first image shows an overview, the second show the same data zoomed in.\n\n![50Hz with enabled bouncing](/media/50Hz_bounce5000_20_500.PNG?raw=true \"50 Hz bouncing\")\n![50Hz with enabled bouncing](/media/50Hz_bounce5000_20_500_zoom.PNG?raw=true \"50 Hz bouncing\")\n\n**Phase Adjustment:**  \nBelow the generated signal for a pulse rate of 100kHz and a signal phase of 45° is shown.\n\n![100kHz, 45deg](/media/100kHz45deg.PNG?raw=true \"100KHz, 45deg\")\n\n**Maximum Pulse Rate:**\n\nThe last example shows a signal with the maximum possible pulsrate of 1.4 MHz. You'll need a T3.6 @240MHz with F_BUS=120MHz to be able to get such high pulse rates. \n\n![100kHz, 45deg](/media/1_4MHz.PNG?raw=true)\n\n*** \n\n# Serial Interface\nThe signal generation can be controlled by an easy to use [serial interface](https://github.com/luni64/EncSim/tree/master/examples/SerialControl). You can use the Aduino serial monitor,  [TyCommander](https://github.com/Koromix/tytools) or any other serial terminal to send commands to the library. Internally the serial inteface uses Kroimons [SerialCommand](https://github.com/kroimon/Arduino-SerialCommand) lib for communication with the terminal.\n\n**Commands:**\n\nTyping in *help* or *?* in the terminal shows a list of all available commands:\n\n![help output](/media/interface.PNG?raw=true)\n\n**Command description**\n\n- The *up* and *down* commands generate a continous quadrature signal until you send the *stop* command. The current counter value is printed during the 'movement'.\n- *mva* and *mvr* 'move' to a given absolute or relative position respectively. Current counter value is printed during amd after the move.\n- Each move command can be intercepted by *stop* or other move commands. E.g., sending *up* followed by *down* will change the direction of the signal immediately. Sending *up* followed by *mva 0* will change direction and move back to position 0.\n- *getpos* and *setpos* get and set the current counter value\n- *freq*, *phase*, *btot*, *bmin*, *bmax*  and period set pulse rate, phase, total bounce time, minimal and maximal bounce pulse width and index pulse period respectively.\n- *print* shows the current settings.  Please note: the library clips the frequency and phase settings if the requested signal can not be generated with the given board. It is a good idea to check the actual settings with *print* if you use high frequencies and/or small phases settings.\n\n# API\nUsing EncSim from your sketches without the serial interface is easy:\n```c++\n#include \u003cTeensyDelay.h\u003e\n#include \u003cEncSim.h\u003e\n\nEncSim\u003c0,1\u003e simulator;       // use pin 0 and pin 1 as output (any two digital pins can be used)\n\nvoid setup() {\n  simulator.begin();\n\n  simulator                   // settings can be done by a \"fluent interface\"\n  .setFrequency(150)          // 150Hz count rate\n  .setPhase(90)               // normal 90° phase shift\n  .setTotalBounceDuration(0); // no bouncing\n  \n  simulator.moveRel(100);     // generate 100 counts\n}\n```\nThe following settings are available\n```c++\nsetFrequency(Hz)            // pulse rate in Hz (1-f_max), f_max depends on board and F_BUS settings\nsetPhase(deg)               // signal phase in deg (10-90)\nsetTotalBounceDuration(µs)  // total duration of bouncing phase in µs\nsetBounceDurationMin(µs)    // minimum peak width of a bouncing peak\nsetBounceDurationMax(µs)    // maximum peak width of a bouncing peak\nsetPeriod(steps)            // distance in steps between the index pulses (-1 disables index pulses)\n```\nThe following commands handle signal generation\n```c++\nmoveAbsAsync(pos)           // moves (generates pulses) to absolute position, returns after starting the move\nmoveRelAsync(delta)         // moves relative to current position\nmoveAbs(pos)                // moves to absolute position, blocks until movement is done\nmoveRes(delta)              // moves relative to current position, blocks until movement is done\nstop()                      // stops movement immediately\nbool isRunning()            // true if simulator is currently moving\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluni64%2Fencsim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluni64%2Fencsim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluni64%2Fencsim/lists"}