You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/communication/commander/index.md
+38-8Lines changed: 38 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -32,13 +32,42 @@ This g-code like interface provides callback to configure and tune any:
32
32
33
33
Furthermore commander enables you to easily create your own commands and extend this interface in any way you might need for your particular application.
34
34
35
+
## What happens when user sends a command?
36
+
When the commander received the string:
37
+
38
+
<imgsrc="extras/Images/cmd1.png"class="width20">
39
+
40
+
It first checks the command id, identifies its `M` and sends the remaining string to the motor handling callback. Then the motor callback checks what is the coommand id, finds `V` and sends the remaining string to the PID velocity callbacK. Then the PID velocity callback scans the command id and finds it is the `D`, so derivative gain and sets the value.
41
+
42
+
Commander | Motor callback (cmd id `M` ) | PID callback (cmd id `V` )
First id that it finds is `O`, which is for example motor. It calls the callback that is assigned to this command (which is in this case motor callback) with the string remaining string. Then the motor callback finds the command `E` and knows its the status (enabled/disabled) either getting or getting. It checks the value and sees that the value is empty, which means the user has sent a get request.
The end of line (eol) character is an optional input of the `Commander` class which represents end of command character. User can define its own end of command characters here, but by default the character used is newline character `\n`. For example i
67
+
68
+
<blockquoteclass="warning"><pclass="heading">BEWARE: EOL characters</p> Different operating systems have different EOL characters by default. Newline character is probably the most common one but there is also the carriage return '\r' for linux users. Be sure to provide it to the constructor of the Commander class if you wish to use it with your setup!</blockquote>
69
+
70
+
The echo flag can be used as a debugging feature but it is not recommended to be used for real time motor control and configuration!
42
71
43
72
Next step would be to add the commander function that reads the `Serial` instance that you provided into the Arduino `loop()`:
44
73
```cpp
@@ -292,7 +321,10 @@ When using a standard callback for `BLDCMotor` and `StepperMotor` classes:`comma
292
321
-**R** - Motor phase resistance
293
322
-**S** - Sensor offsets
294
323
-**M** - sensor offset
295
-
-**E** - sensor electrical zero
324
+
-**E** - sensor electrical zero
325
+
-**W** - PWM settings
326
+
-**T** - pwm modulation type
327
+
-**C** - pwm waveform centering boolean
296
328
-**M** - Monitoring control
297
329
-**D** - downsample monitoring
298
330
-**C** - clear monitor
@@ -531,11 +563,9 @@ void loop() {
531
563
532
564
## *Simple**FOC**Studio* by [@JorgeMaker](https://github.com/JorgeMaker)
533
565
534
-
SimpleFOCStudio is an awesome application built by [@JorgeMaker](https://github.com/JorgeMaker) which we will try to keep up to date with out library. It is a python application that uses commander interface for tunning and configuring the motor. More info about it will come soon.
SimpleFOCStudio is an awesome application built by [@JorgeMaker](https://github.com/JorgeMaker) which we will try to keep up to date with out library. It is a python application that uses commander interface for tunning and configuring the motor.
537
567
538
-
To install this application follow the readme in the [git repository](https://github.com/JorgeMaker/SimpleFOCStudio).
For more info about this application and <spanclass="simple">Simple<spanclass="foc">FOC</span>library</span> make sure to follow [the community forum](https://community.simplefoc.com).
570
+
For more info how to install and use this application visit the studio [docs <iclass="fa fa-external-link"></i>](studio).
<blockquoteclass="warning"><pclass="heading">CPR, PPR?!</p> PPR (pulses per revolution) - this is the physical number of impulses the encoder has per revolution. CPR (counts per revolution) - this is amount you are going to have in your counter after the full rotation of the encoder. Now depending on whether you use quadrature mode (counting each edge of the impulse) or not (counting just the rising edge) you will have different CPR for the same PPR. For quadrature mode you will have CPR = 4xPPR and if not using quadrature mode you will have CPR=PPR</blockquote>
36
36
37
-
Additionally the encoder has one more important parameter and this is the pullup location. MAny encoders require pullups and in cases when you have an encoder that needs one and you don't have one on your hands you can use Arduino pullups. That is set by changing the value of the `encoder.pullup` variable. The default value is set to `Pullup::EXTERN` but if you would like to change it to use the MCU ones do:
37
+
Additionally the encoder has one more important parameter and this is the pullup location. MAny encoders require pullups and in cases when you have an encoder that needs one and you don't have one on your hands you can use Arduino pullups. That is set by changing the value of the `encoder.pullup` variable. The default value is set to `Pullup::USE_EXTERN` but if you would like to change it to use the MCU ones do:
<blockquoteclass="warning"><pclass="heading">Arduino Pullup 20kΩ</p> Be careful when using internal pullups, Arduino has relatively high valued pullups around 20kΩ, which means that you might have some problems for higher velocities (for shorted impulse durations). Recommended pull-up values are in between 1kΩ and 5kΩ.</blockquote>
Additionally the hall senso has one more optional parameter you may set, the pullup location. Hall sensors usually require pullups and in cases when your sensor needs one and you don't have one on your hands you can use Arduino pullups. That is set by changing the value of the `sensor.pullup` variable. The default value is set to `Pullup::EXTERN` but if you would like to change it to use the MCU ones do:
30
+
Additionally the hall senso has one more optional parameter you may set, the pullup location. Hall sensors usually require pullups and in cases when your sensor needs one and you don't have one on your hands you can use Arduino pullups. That is set by changing the value of the `sensor.pullup` variable. The default value is set to `Pullup::USE_EXTERN` but if you would like to change it to use the MCU ones do:
31
31
```cpp
32
32
// use internal pullups
33
-
sensor.pullup = Pullup::INTERN;
33
+
sensor.pullup = Pullup::USE_INTERN;
34
34
```
35
35
<blockquoteclass="warning"><pclass="heading">Arduino Pullup 20kΩ</p> Be careful when using internal pullups, Arduino has relatively high valued pullups around 20kΩ, which means that you might have some problems for higher velocities (for shorted impulse durations). Recommended pull-up values are in between 1kΩ and 5kΩ.</blockquote>
Copy file name to clipboardExpand all lines: docs/simplefoc_library/code/sensors/magnetic/magnetic_sensor_analog.md
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,9 @@ The parameters of the class are
27
27
-`min_raw_count` - the smallest expected reading. Whilst you might expect it to be 0 it is often ~15. Getting this wrong results in a small click once per revolution
28
28
-`max_raw_count` - the largest value read. Whilst you might expect it to be 2^10 = 1023 it is often ~ 1020. Note: For ESP32 (with 12bit ADC the value will be nearer 4096)
29
29
30
+
<blockquoteclass="info"> <pclass="heading"> 💡 Find out min and max</p>
31
+
Every mcu is a bit different and every sensor as well so we advise you to use the provided example in the <codeclass="highlighter-rouge">examples/sensor_test/magentic_sensor_analog_example/find_raw_min_max</code> to find out the maximal and minimal values of your sensor.
32
+
</blockquote>
30
33
Finally after the initialization the only thing you need to do afterwards is to call the `init()` function. This function initializes the sensor hardware. So your magnetic sensor initialization code will look like:
If you wish to use more than one magnetic sensor, make sure you connect their `chip_select` pins to different arduino pins and follow the same idea as above, here is a simple example:
44
+
If you wish to use more than one magnetic sensor, make sure you connect their ADC pins to different arduino pins and follow the same idea as above, here is a simple example:
0 commit comments