I have a sketch that controls a DC motor with quadrature encoder driven by an analog potentiometer on a Leonardo.
The sketch uses:
#define PWMPIN 10 // Output pin to control PWM for motor controller on digital #define DIRPIN 9 // Output direction for motor controller on digital #define CHANNELA 3 // motor position sensor pin Digital Pin #define CHANNELB 2 // motor position sensor pin Digital Pin #define POTPIN A0 // select the input pin for the potentiometer on analog pin
My goal is to adapt the above sketch for a proprietary system (see picture below) that only has the five analog pins. I am looking for a way to “map” the above outputs to the ananlog pin config listed below.
#define PWMPIN A0 // Output pin to control PWM for motor controller #define DIRPIN A1 // Output direction for motor controller #define CHANNELA A2 // position sensor pin #define CHANNELB A3 // position sensor pin #define POTPIN A4 // select the input pin for the potentiometer
On top of this, the PWM has to work at least 30Khz to avoid motor “squeal”, that is handled by the pwm.h library.
The digital pins have been specifically chosen for their performance on the Leonardo as shown in the pin schematic attached below. The Leonardo and the proprietary card use the ATMEGA32U4 16-bit microcontroller.
Any thoughts or examples are most welcome.