|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Simple<b>FOC</b>WebController |
| 4 | +nav_order: 3 |
| 5 | +permalink: /webcontroller |
| 6 | +parent: tools |
| 7 | +grand_parent: <span class="simple">Simple<span class="foc">FOC</span>utils</span> |
| 8 | +--- |
| 9 | + |
| 10 | +# *Simple**FOC**WebController* <small>by [@geekuillaume](https://github.com/geekuillaume) </small> |
| 11 | + |
| 12 | +This is a controller interface for the <span class="simple">Simple<span class="foc">FOC</span>library</span>. It uses WebSerial to communicate with a suitable micro-controller using serial port communications and the [Commander](commander_interface) interface. |
| 13 | + |
| 14 | +Most of the code for this application was provided by [@geekuillaume](https://github.com/geekuillaume), his github repository can be found [here](https://github.com/geekuillaume/simplefoc-webcontroller) and his application can be found [here](https://simplefoc.besson.co/). |
| 15 | +Our app is a fork of his code, that has been further extended to support more devices and configuration parameters, as well as to ease the monitoring visualisation. |
| 16 | + |
| 17 | +<a href ="https://github.com/geekuillaume/simplefoc-webcontroller" class="btn btn"><i class="fa fa-github"></i> Github repo</a> <a href ="https://docs.simplefoc.com/simplefoc-webcontroller/" class="btn btn-primary"><i class="fa fa-github"></i> Open <span class="simple">Simple<span class="foc">FOC</span>webcontroller</span></a> |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +<img src="extras/Images/webcontroller.gif" > |
| 22 | + |
| 23 | +<blockquote class="info"> |
| 24 | +<p class="heading">📢 Early stage project</p> |
| 25 | +This project is still in its early stage, we are counting on your patience and looking forward to hear your feedback. As there are many people in the community with far more knowledge about these kinds of apps than we do, don't hesitate to leve the issues and do the pull requests. |
| 26 | +</blockquote> |
| 27 | + |
| 28 | +### Features: |
| 29 | +- Plug and play with the *Simple**FOC**library* version 2.3+ |
| 30 | +- Real-time tuning and configuration of the motors |
| 31 | +- Real-time plotting and monitoring of motor variables |
| 32 | +- Support for multiple motors |
| 33 | + |
| 34 | + |
| 35 | +## Using the *Simple**FOC**WebController* |
| 36 | + |
| 37 | +<a href ="https://docs.simplefoc.com/simplefoc-webcontroller/" class="btn btn-primary"><i class="fa fa-github"></i> Open <span class="simple">Simple<span class="foc">FOC</span>webcontroller</span></a> |
| 38 | + |
| 39 | +*Simple**FOC**WebController* does not require any installation, its only requirement is that your browser has `WebSerial` support. Check the supportedd browsers [here](https://caniuse.com/web-serial). |
| 40 | + |
| 41 | +### Motion control tunning blocks |
| 42 | +Once you have your application running in your browser, connected to your microcontroller running the <span class="simple">Simple<span class="foc">FOC</span>library</span>. You can easily change most of the control parameters of different motion control loops and visualise different monitored variables. |
| 43 | + |
| 44 | +<img src="extras/Images/webcontroller_motor.png" class="width80"> |
| 45 | + |
| 46 | +### Integrated serial terminal |
| 47 | + |
| 48 | +*Simple**FOC**WebController* also has integrated serial terminal for easier debugging and monitoring. |
| 49 | + |
| 50 | +<img src="extras/Images/webcontroller_init.png" class="width80"> |
| 51 | + |
| 52 | + |
| 53 | +## Arduino code |
| 54 | +Basically there are three things you need to do: |
| 55 | +1. Use the commander interface and add the motor to the commander |
| 56 | +2. Use the monitoring and add the `motor.monitor()` in the loop |
| 57 | +3. Make set the `motor.monitor_start_char` and `motor.monitor_end_char` to the same character as the motor id added to the commander |
| 58 | + |
| 59 | +Here is a mockup of the code: |
| 60 | + |
| 61 | +```cpp |
| 62 | +#include <SimpleFOC.h> |
| 63 | + |
| 64 | +.... |
| 65 | + |
| 66 | +// include commander interface |
| 67 | +Commander command = Commander(Serial); |
| 68 | +void doMotor(char* cmd) { command.motor(&motor, cmd); } |
| 69 | + |
| 70 | +void setup(){ |
| 71 | + .... |
| 72 | + // add the motor to the commander interface |
| 73 | + // The letter id (here 'M') of the motor |
| 74 | + char motor_id = 'M'; |
| 75 | + command.add(motor_id,doMotor,'motor'); |
| 76 | + // tell the motor to use the monitoring |
| 77 | + motor.useMonitoring(Serial); |
| 78 | + // configuring the monitoring to be well parsed by the webcontroller |
| 79 | + motor.monitor_start_char = motor_id; // the same latter as the motor id in the commander |
| 80 | + motor.monitor_end_char = motor_id; // the same latter as the motor id in the commander |
| 81 | + |
| 82 | + commander.verbose = VerboseMode::machine_readable; // can be set using the webcontroller - optional |
| 83 | + ... |
| 84 | + |
| 85 | +} |
| 86 | +void loop(){ |
| 87 | + .... |
| 88 | + |
| 89 | + .... |
| 90 | + // real-time monitoring calls |
| 91 | + motor.monitor(); |
| 92 | + // real-time commander calls |
| 93 | + command.run(); |
| 94 | +} |
| 95 | +``` |
0 commit comments