{"id":17788706,"url":"https://github.com/devel0/scurve-speed-eval","last_synced_at":"2025-10-11T09:44:44.435Z","repository":{"id":122983016,"uuid":"317022926","full_name":"devel0/scurve-speed-eval","owner":"devel0","description":"Acceleration for an s-curve shaped speed","archived":false,"fork":false,"pushed_at":"2024-06-19T20:09:46.000Z","size":1117,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T20:08:51.207Z","etag":null,"topics":["csharp","multiplatform","stepper-motor"],"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/devel0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-11-29T19:05:21.000Z","updated_at":"2025-01-23T06:11:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"d0843804-0b0a-47a1-b626-cd0949b10950","html_url":"https://github.com/devel0/scurve-speed-eval","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devel0/scurve-speed-eval","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fscurve-speed-eval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fscurve-speed-eval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fscurve-speed-eval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fscurve-speed-eval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devel0","download_url":"https://codeload.github.com/devel0/scurve-speed-eval/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devel0%2Fscurve-speed-eval/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006758,"owners_count":26084184,"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-11T02:00:06.511Z","response_time":55,"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":["csharp","multiplatform","stepper-motor"],"created_at":"2024-10-27T10:20:55.039Z","updated_at":"2025-10-11T09:44:44.400Z","avatar_url":"https://github.com/devel0.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scurve speed eval\n\nShow how s-curve speed type can be obtained.\n\n\u003cimg src=\"data/img/demo.gif\" width=\"700\"/\u003e\n\n---\n\n- [Description](#description)\n- [Performance considerations](#performance-considerations)\n- [Example](#example)\n- [Prerequisites](#prerequisites)\n- [Quickstart](#quickstart)\n- [How this project was built](#how-this-project-was-built)\n- [References](#references)\n\n---\n\n## Description\n\nFor symbolic calculus [AngouriMath](https://github.com/asc-community/AngouriMath) library was used.\n\nFor preliminary analysis [sympy](https://github.com/sympy/sympy) with [this](data/test.py) test was used.\n\n![](data/img/scurve-accel-decel.png)\n\n- lets name\n    - **t** (time)\n    - **x** (distance) \n    - **d** (total duration accel/decel)\n    - **s** (final speed)\n\n- suppose `[0,d/2]` the time for acceleration while `[d/2,d]` the time for deceleration to produce a target final speed `s` starting from speed=0 and pos=0\n- from base acceleration function [1-cos(t)][1]\n- expanding the period domain from `[0,2pi]` to `[0,d/2]` through [this][2] subst\n- [stretching][3] the accel function so that its integral, the speed, achieve targetspeed\n- acceleration results as [this][4]\n\n:point_right: hit F5 if math not rendered\n\n$$\n\\large\naccel(t)=\\frac{2\\cdot s}{d}\\cdot\\left(1-\\cos\\left(\\frac{4\\cdot\\pi\\cdot t}{d}\\right)\\right)\n$$\n\n- positive max accel value is at midpoint ( t=1/4d because accel positive in `[0,d/2]` ) thus above can be simplified into\n\n$$\n\\large\nmaxAccel=\\frac{4\\cdot s}{d}\n$$\n\n- [integration of accel][5] gives speed\n\n$$\n\\large\nspeed(t) = \\frac{2\\cdot s}{d} \\cdot \\left( t - \\frac{d\\cdot \\sin\\left(\\frac{4\\cdot\\pi\\cdot t}{d}\\right)}{4\\cdot\\pi} \\right)\n$$\n\n- [integration of speed][6] gives pos ( normalized removing integration constant computed for t=0 )\n\n$$\n\\large\npos(t) = \\frac{s\\cdot d \\cdot \\left( \\cos\\left(\\frac{4\\cdot\\pi\\cdot t}{d}\\right)-1 \\right)}{8\\cdot\\pi^2} + \\frac{s\\cdot t^2}{d}\n$$\n\n- [targetspeed][7] required from known final position `p` to reach in required time duration `d`\n\n$$\n\\large\ns = \\frac{2\\cdot p}{d}\n$$\n\n- from base deceleration function [cos(t)-1][8]\n\n- sets `th` as\n\n$$\n\\large\nth=t-\\frac{d}{2}\n$$\n\n- deceleration results as [this][9]\n\n$$\n\\large\ndeAccel\\left(th\\right) = \\frac{2\\cdot s}{d}\\cdot\\left(\\cos\\left(\\frac{4\\cdot\\pi\\cdot th}{d}\\right)-1\\right)\n$$\n\n- despeed results as [this][10] ( given from deAccel integral subtracting integration constant and adding speed achieved by accel at `d/2` )\n\n$$\n\\large\ndeSpeed\\left(th\\right) = \\frac{2\\cdot s\\cdot\\sin\\left(\\frac{4\\cdot\\pi\\cdot th}{d} \\right)}{4\\cdot\\pi}-\\frac{2\\cdot s\\cdot th}{d}+s\n$$\n\n- depos results as [this][11] ( given from deSpeed integral subtracting integration constant and adding pos achieved by accel at `d/2` )\n\n$$\n\\large\ndePos\\left(th\\right) = \\frac{s\\cdot d\\cdot\\left( 1-\\cos\\left(\\frac{4\\cdot\\pi\\cdot th}{d}\\right) \\right)}{8\\cdot\\pi^2}-\\frac{s\\cdot th^2}{d}+s\\cdot th+\\frac{s\\cdot d}{4}\n$$\n\n[1]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L48\n[2]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L49\n[3]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L50\n[4]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L51\n[5]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L53\n[6]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L57\n[7]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L60\n[8]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L62\n[9]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L65\n[10]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L69\n[11]: https://github.com/devel0/scurve-speed-eval/blob/435327c86769302a22fa54fb6b349a60a1b640d1/gui%2FProgram.cs#L72\n\n## Performance considerations\n\nFor a realtime purpose a bezier approach should be used like the one implemented in the [Marlin](https://github.com/MarlinFirmware/Marlin/blob/d364babbc0cdb73337d86e2c4fd9170b46b7361a/Marlin/src/module/stepper.cpp#L651).\n\n## Example\n\n![](data/img/example.png)\n\nThis [example](examples/scurve-xlsx/Program.cs) can be executed through\n\n```\ndotnet run --project examples/scurve-xlsx\n```\n\nand it will produce follow [output.xlsx](examples/scurve-xlsx/output.xlsx) by applying above formulas and doing some test calc about max allowable torque based on motion and supposed load.\n\n## Prerequisites\n\n- [vscode](https://code.visualstudio.com/)\n- [dotnet 8.0](https://dotnet.microsoft.com/download)\n\n## Quickstart\n\n```sh\ngit clone https://github.com/devel0/netcore-util\ncd netcore-util\ngit checkout bd8626104f4b5a9cb9de5db624cebbcd77a8b384\ncd ..\n\ngit clone https://github.com/devel0/netcore-sci\ncd netcore-sci\ngit checkout 151451d5cd40e8ccebf93718379e8d72dbadce86\ncd ..\n\ngit clone https://github.com/devel0/scurve-speed-eval\ncd scurve-speed-eval\ndotnet build\ndotnet run --project gui\n```\n\n## How this project was built\n\n```sh\ndotnet new console -n scurve-speed-eval\ncd scurve-speed-eval\ndotnet sln add scurve-speed-eval.csproj\ndotnet sln add .\ndotnet add reference ../netcore-util/netcore-util\ndotnet add reference ../netcore-sci/netcore-sci\ndotnet add package AngouriMath --version 1.3.0\ndotnet add package Avalonia.Desktop --version 0.10.0-preview6\ndotnet add package OxyPlot.Avalonia --version 2.1.0-20200725.1\ndotnet add package UnitsNet --version 4.76.0\ndotnet run\n```\n\n## References\n\n- [How to get sinusoidal s-curve for a stepper motor](http://fightpc.blogspot.com/2018/04/how-to-get-sinusoidal-s-curve-for.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevel0%2Fscurve-speed-eval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevel0%2Fscurve-speed-eval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevel0%2Fscurve-speed-eval/lists"}