Minor cleanup to encoders documentation

This commit is contained in:
PAJohnson
2020-08-24 20:50:52 -04:00
parent 961bc113ed
commit faae8f5b8e
+16 -15
View File
@@ -4,7 +4,7 @@
Be sure to read the [ODrive Encoder Guide](https://docs.google.com/spreadsheets/d/1OBDwYrBb5zUPZLrhL98ezZbg94tUsZcdTuwiVNgVqpU).
## Encoder Calibration
Please take into account that all encoder types supported by ODrive require that you do some sort of encoder calibration. This requires the following:
All encoder types supported by ODrive require that you do some sort of encoder calibration. This requires the following:
* Selecting an encoder and mounting it to your motor
* Choosing an interface (e.g., AB, ABI or SPI)
* Connecting the pins to the odrive
@@ -24,11 +24,11 @@ To verify everything went well, check the following variables:
* `<axis>.motor.config.direction` - This should print 1 or -1.
### Encoder with index signal
If you have an encoder with an index (Z) signal, you may avoid having to do the offset calibration on every startup, and instead use the index signal to re-sync the encoder to a stored calibration.
If you have an encoder with an index (Z) signal, you can avoid doing the offset calibration on every startup, and instead use the index signal to re-sync the encoder to a stored calibration.
Below are the steps to do the one-time calibration and configuration. Note that you can follow these steps with one motor at a time, or all motors together, as you wish.
* Since you will only do this once, it is recommended that you mechanically disengage the motor from anything other than the encoder, so it can spin freely.
* Since you will only do this once, it is recommended that you mechanically disengage the motor from anything other than the encoder, so that it can spin freely.
* Set `<axis>.encoder.config.use_index` to `True`.
* Run `<axis>.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH`. This will make the motor turn in one direction until it finds the encoder index.
* Follow the calibration instructions for an [encoder without index signal](#encoder-without-index-signal).
@@ -57,11 +57,11 @@ The following are variables that MUST be set up for your encoder configuration.
* `<axis>.encoder.config.cpr = 8192`
* `<axis>.encoder.config.mode = ENCODER_MODE_INCREMENTAL`
The following are examples of values that MAY impact the success of calibration. These are not all the varibles you have to set for startup. Only change these when you understand why they are needed; your values will vary depending on your setup:
* `<axis>.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT` select if you have a gimbal or high amp motor
* `<axis>.encoder.config.calib_range = 0.05` helps to relax the accuracy of encoder counts during calibration
* `<axis>.motor.config.calibration_current = 10.0` _sometimes_ needed if this is a large motor
* `<axis>.motor.config.resistance_calib_max_voltage = 12.0` _sometimes_ needed depending on motor
The following are examples of values that can impact the success of calibration. These are not all of the variables you have to set for startup. Only change these when you understand why they are needed; your values will vary depending on your setup:
* `<axis>.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT` The type of motor you have. Valid choices are high current or gimbal.
* `<axis>.encoder.config.calib_range = 0.05` Helps to relax the accuracy of encoder counts during calibration
* `<axis>.motor.config.calibration_current = 10.0` The motor current used for calibration. For large motors, this value can be increased to overcome friction and cogging.
* `<axis>.motor.config.resistance_calib_max_voltage = 12.0` Max motor voltage used for measuring motor resistance. For motor calibration, it must be possible for the motor current to reach the calibration current without the applied voltage exceeding this config setting.
* `<axis>.controller.config.vel_limit = 5` [turn/s] low values result in the spinning motor stopping abruptly during calibration
Lots of other values can get you. It's a process. Thankfully there are a lot of good people that will help you debug calibration problems.
@@ -74,7 +74,7 @@ Now try:
let it loop a few times and then set:
* `<axis>.requested_state = AXIS_STATE_IDLE`
Do you still have no errors? Awesome. Now save the calibration, you can set the below. Note that this only works if you are using an absolute encoder or the encoder index input (see "Encoder with index signal" above).
Do you still have no errors? Awesome. Now, setup the motor and encoder to use known calibration values. This allows you to skip motor calibration and encoder offset calibration before using closed loop control. Note that this only works if you are using an absolute encoder or the encoder index input (see "Encoder with index signal" above).
* `<axis>.encoder.config.pre_calibrated = True`
* `<axis>.motor.config.pre_calibrated = True `
@@ -83,7 +83,7 @@ And see if ODrive agrees that calibration worked by just running
(using no "= True" ). Make sure that 'pre_calibrated' is in fact True.
Also, if you have calibrated and encoder.pre_calibrated is equal to true, and you had no errors so far. Run this:
Also, if you have calibrated and encoder.pre_calibrated is equal to true, and you had no errors so far, run this:
* `odrv0.save_configuration()`
* `odrv0.reboot()`
@@ -106,19 +106,20 @@ Or ODrive may just vibrate in an entertaining way. See:
https://www.youtube.com/watch?v=gaRUmwvSyAs
## Encoder Testing
There are things you can test to make sure your encoder is properly connected.
This run the command:
There are things you can test to make sure your encoder is properly connected. `shadow_count` tracks encoder motion, even before the encoder or motor are calibrated. If your encoder is working, you should see this value change when you turn the motor.
Run the command:
* `<axis>.encoder.shadow_count `
and look at your value. Then turn your motor by hand and see if that value changes. Also, notice that the command:
* `<axis>.encoder.config.cpr = 4000`
must reflect the number of counts odrive receives after one complete turn of the motor. So use shadow_count to test if that is working properly.
must reflect the number of counts ODrive receives after one complete turn of the motor. So use shadow_count to test if that is working properly.
You will probably never be able to properly debug if you have problems unless you use an oscilloscope. If you have one, try the following:
Connect to the AB pins, see if you get square waves as you turn the motor.
Connect to the I pin, see if you get a pulse on a complete rotation. Sometimes this is hard to see.
If you are using SPI, use a logic analyzer and connect a wire to the CLK, MISO, and CS pins. Set a trigger for the CS pin and insure that the encoder position is being sent and is increasing/decreasing as you spin the motor. There is extremely cheap [Sigrok](https://sigrok.org/) supported hardware available for protocol analysis.
If you are using SPI, use a logic analyzer and connect to the CLK, MISO, and CS pins. Set a trigger for the CS pin and ensure that the encoder position is being sent and is increasing/decreasing as you spin the motor. There is extremely cheap hardware that is supported by [Sigrok](https://sigrok.org/) for protocol analysis.
## Encoder Noise
Noise is found in all circuits, life is just about figuring out if it is preventing your system from working. Lots of users have no problems with noise interfering with their ODrive operation, others will tell you "_I've been using the same encoder as you with no problems_". Power to 'em, that may be true, but it doesn't mean it will work for you. If you are concerned about noise, there are several possible sources:
@@ -138,7 +139,7 @@ One easy step that _might_ fix the noise on the Z input has been to solder a 22n
## SPI Encoders
Apart from (incremental) quadrature encoders, ODrive also supports absolute SPI encoders (since firmware v0.5). These are usually based on are Hall Effect/Magnetic sensors and measure an absolute angle. This means you don't need to repeat the encoder calibration after every ODrive reboot. Currently, the following modes are supported:
Apart from (incremental) quadrature encoders, ODrive also supports absolute SPI encoders (since firmware v0.5). These usually measure an absolute angle. This means you don't need to repeat the encoder calibration after every ODrive reboot. Currently, the following modes are supported:
* **CUI protocol**: Compatible with the AMT23xx family (AMT232A, AMT232B, AMT233A, AMT233B).
* **AMS protocol**: Compatible with AS5047P and AS5048A/AS5048B.