ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

APM_RC needs a non-constrained version of OutputCh for use as DC motor driver or other non ESC/Servo Output

Open jason4short opened this issue 13 years ago • 1 comments

Either remove constraint or offer additional API for setting PWM. Thanks! Jason

void APM_RC_APM1::OutputCh(uint8_t ch, uint16_t pwm) { pwm=constrain(pwm,MIN_PULSEWIDTH,MAX_PULSEWIDTH); pwm<<=1; // pwm*2;

switch(ch)
{
case 0:  OCR5B=pwm; break;  //ch1
case 1:  OCR5C=pwm; break;  //ch2
case 2:  OCR1B=pwm; break;  //ch3
case 3:  OCR1C=pwm; break;  //ch4
case 4:  OCR4C=pwm; break;  //ch5
case 5:  OCR4B=pwm; break;  //ch6
case 6:  OCR3C=pwm; break;  //ch7
case 7:  OCR3B=pwm; break;  //ch8
case 8:  OCR5A=pwm; break;  //ch9,  PL3
case 9:  OCR1A=pwm; break;  //ch10, PB5
case 10: OCR3A=pwm; break;  //ch11, PE3
}

}

jason4short avatar Jan 23 '13 00:01 jason4short

Two thoughts:

  1. APM_RC is now part of the AP_HAL, but in function is essentially unchanged.
  2. Motor control is fundamentally very different from servo PWM. How about using a separate library for that? I can work on this with you, if you like.

pchickey avatar Jan 24 '13 03:01 pchickey