I'm trying to drive a DC-motor as fast as the (manual) rotation of an encoder.
Therefore I use the library in topic, and a fixed timerinterrupt to find out the speed of the encoder.
It seems that can't control the H-bridge when I enable a timer interrupt.
It probably uses the same timer, but I don't know how to control that.
Underneath a simple test:
void setup()
{
Serial.begin(9600);
while(!Serial);
//Drive motor
if(ifxMcsUniDirectionalMotor1.begin())
Serial.println("Init fail +++ Init Fail +++ Init Fail");
ifxMcsUniDirectionalMotor1.start();
ifxMcsUniDirectionalMotor1.setSpeed(120);
delay(1000);
ifxMcsUniDirectionalMotor1.setSpeed(160);
delay(1000);
//Setup Timer interrupt
TimeInterrupt.begin(PRECISION); //Initialize the interrupt with high precision timing
TimeInterrupt.addInterrupt(encoderDelta, 100);
TimeInterrupt.addInterrupt(info, 500);
// Drive motor again, no succes
ifxMcsUniDirectionalMotor1.start();
ifxMcsUniDirectionalMotor1.setSpeed(120);
delay(1000);
ifxMcsUniDirectionalMotor1.setSpeed(160);
delay(1000);
//Serial.println("Stopping motor");
//ifxMcsUniDirectionalMotor1.stop();
}
Attached the library code that shows the timer use, but it does that kinda directly to the CPU. I can't read that very well. Anyone any ideas how to get around this one? Tx. Kind regards.
I seemed to have misread that the external interrupt pins on UNO are 5&6. They appear to be pins 2&3. Now 3 is the PWM output to my motor shield. That can't work well... Tx Pylon. Problem solved!