Various algorithm to control things
Перейти к файлу
Dmitriy Antipov 749fe8c6d5
Add reset block (#6)
* Update pid.ts

* description

Description warning. I noticed a bug that when you use a controller instance with a certain number before and reuse it again the next time and do a reset before setting the values \u200b\u200band or the regulation limits, then the controller for some reason leads the control action to one side.

For example, I put the ev3 robot on a line, two color sensors. Judging by the values from the sensors, it should go straight (the control action should be near zero), but the controller shows that it wants to take the robot to the side.
The problem is not always, but often.

Example...
automation.pid1.reset();
automation.pid1.setGains(KP_LINE_FOLLOW, 0, KD_LINE_FOLLOW);
automation.pid1.setControlSaturation(-100, 100);

If the reset is done after, then the problem does not occur at all.
automation.pid1.setGains(KP_LINE_FOLLOW, 0, KD_LINE_FOLLOW);
automation.pid1.setControlSaturation(-100, 100);
automation.pid1.reset();
2023-07-18 20:18:48 +02:00
.vscode initial upload 2018-05-04 09:11:07 -07:00
.gitignore initial upload 2018-05-04 09:11:07 -07:00
.travis.yml initial upload 2018-05-04 09:11:07 -07:00
LICENSE Initial commit 2018-05-04 08:56:17 -07:00
Makefile initial upload 2018-05-04 09:11:07 -07:00
README.md Update README.md (#1) 2023-06-12 11:45:39 -07:00
SECURITY.md Microsoft mandatory file (#4) 2023-06-12 11:45:13 -07:00
behaviors.ts initial upload 2018-05-04 09:11:07 -07:00
movingaveragefilter.ts added moving average 2018-05-04 09:22:56 -07:00
ns.ts Update pxt.json, ns.ts 2019-10-09 15:07:35 -07:00
pid.ts Add reset block (#6) 2023-07-18 20:18:48 +02:00
pxt.json 0.0.3 2019-10-09 15:07:41 -07:00
test.ts added moving average 2018-05-04 09:22:56 -07:00
tsconfig.json initial upload 2018-05-04 09:11:07 -07:00

README.md

Automation Build Status

Various algorithm for Systems & Control operations for Microsoft MakeCode editors.

How to use this library?

In your MakeCode editor, click on the gearwheel menu and click "Extensions", search for "automation" and select this project.

PID controller

A Proportional-Integral-Derivative control is a classic control structure in automation. The user needs to define 3 gains (Kp, Ki, Kd) to tune the controller.

See Reference: Feedback System, Karl Johan Astrom & Rickard M. Murry

let v = 0;
automation.pid1.setGains(1, 0.01, 0.001);
for (let i = 0; i < 10; ++i) {
    v = automation.pid1.compute(0.1, 5);
}

Behaviors

An example of Behavior-based robotics control system.

Moving Average Filter

let r = 0;
for (let i = 0; i < 10; ++i) {
    r = automation.movingAverageFilter1.filter(Math.random());
}

Supported targets

  • for PXT/maker
  • for PXT/adafruit
  • for PXT/codal
  • for PXT/ev3

License

MIT

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.