diff --git a/docs/reference.md b/docs/reference.md index 493b5f52..138f2243 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -244,20 +244,33 @@ Nothing is supported here yet, but soon! The following table shows which pins can be used for the unique capabilities: +#### AUX1 / ENC #### + | moteus r4.5/8/11 | Con | Aux | SPI | ADC/Sin/Cos | I2C | HW Quad | UART | 5VT | |------------------|-----|-----|------|-------------|-----|---------|------|-----| -| Aux1 / ENC | | | | | | | | | | 3.3V (3) | 1 | | | | | | | | | C | 2 | 0 | X | | | | | X | | GND (G) | 3 | | | | | | | | | K | 4 | 1 | CLK | X | | | | | | I | 5 | 2 | MISO | X | | | | | | O | 6 | 3 | MOSI | X | | | | | -| Aux2 / ABS | | | | | | | | | + + +#### AUX2 / ABS #### + +| moteus r4.5/8/11 | Con | Aux | SPI | ADC/Sin/Cos | I2C | HW Quad | UART | 5VT | +|------------------|-----|-----|------|-------------|-----|---------|------|-----| | 3.3V (3) | 1 | | | | | | | | | | 2 | 0 | | | SCL | | RX | X | | | 3 | 1 | | | SDA | | TX | X | | GND (G) | 4 | | | | | | | | +| DBG 1 | | 2 | | | | | | X | +| DBG 2 | | 3 | | | | | | X | + +NOTE: For moteus r4.5/8/11, DBG 1/2 are not present on the ABS +connector, but are exposed pads on the circuit board. + +#### Pin Configuration #### Auxiliary port configuration is achieved in two steps. First, the `aux[12].pins.X.mode` value is set to the proper capability for each diff --git a/fw/bldc_servo.cc b/fw/bldc_servo.cc index 3050d7db..24ec073a 100644 --- a/fw/bldc_servo.cc +++ b/fw/bldc_servo.cc @@ -311,8 +311,9 @@ class BldcServo::Impl { msense_(options.msense), msense_sqr_(FindSqr(options.msense)), debug_dac_(options.debug_dac), +#ifdef MOTEUS_DEBUG_OUT debug_out_(options.debug_out), - debug_out2_(options.debug_out2), +#endif debug_serial_([&]() { Stm32Serial::Options d_options; d_options.tx = options.debug_uart_out; @@ -855,18 +856,23 @@ class BldcServo::Impl { (pwm_counts_ - cnt) : (pwm_counts_ + cnt); status_.total_timer = 2 * pwm_counts_ * rate_config_.interrupt_divisor; + +#ifdef MOTEUS_DEBUG_OUT debug_out_ = 0; +#endif } void ISR_DoSenseCritical() __attribute__((always_inline)) MOTEUS_CCM_ATTRIBUTE { // Wait for sampling to complete. while ((ADC3->ISR & ADC_ISR_EOS) == 0); +#ifdef MOTEUS_DEBUG_OUT // We would like to set this debug pin as soon as possible. // However, if we flip it while the current ADCs are sampling, // they can get a lot more noise in some situations. Thus just // wait until now. debug_out_ = 1; +#endif // We are now out of the most time critical portion of the ISR, // although it is still all pretty time critical since it runs @@ -2143,9 +2149,10 @@ class BldcServo::Impl { AnalogOut debug_dac_; +#ifdef MOTEUS_DEBUG_OUT // This is just for debugging. DigitalOut debug_out_; - DigitalOut debug_out2_; +#endif RateConfig rate_config_; diff --git a/fw/moteus_controller.cc b/fw/moteus_controller.cc index 0f81c31f..673bf47f 100644 --- a/fw/moteus_controller.cc +++ b/fw/moteus_controller.cc @@ -328,8 +328,8 @@ constexpr aux::AuxHardwareConfig kAux2PortHardwareConfig = { {{ { MOTEUS_ABS_SCL, -1, 0, aux::kScl }, { MOTEUS_ABS_SDA, -1, 0, aux::kSda }, - { NC, -1, 0, aux::kNoI2c }, - { NC, -1, 0, aux::kNoI2c }, + { MOTEUS_DEBUG1, -1, 0, aux::kNoI2c }, + { MOTEUS_DEBUG2, -1, 0, aux::kNoI2c }, { NC, -1, 0, aux::kNoI2c }, }}, {{