Skip to content

Commit

Permalink
Include DBG 1/2 in the aux2 port to get 2 more pins
Browse files Browse the repository at this point in the history
  • Loading branch information
jpieper committed Jun 27, 2022
1 parent 7919ebf commit 0490246
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
17 changes: 15 additions & 2 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions fw/bldc_servo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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_;

Expand Down
4 changes: 2 additions & 2 deletions fw/moteus_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
}},
{{
Expand Down

0 comments on commit 0490246

Please sign in to comment.