Am I wrong believing the Teensy can support multiple PWM outputs at the same time? I am working on a simple multiple motor controller and can only seem to get one motor at a time to work. Here is a snipet of the code:
Val = (constrain(msg->mtr_A, 0, 511)); // msg should be in range 0-512
if ( Val & 0x100) // is direction negative
{
bitClear(Val,8);
digitalWrite(ADIR, HIGH);
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(APWM, Val);
}
else
{
digitalWrite(ADIR, LOW);
Val = 0x100-Val;
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(APWM, (Val));
}
Val = (constrain(msg->mtr_B, 0, 511)); // msg should be in range 0-512
if ( Val & 0x100) // is direction negative
{
bitClear(Val,8);
digitalWrite(BDIR, HIGH);
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(BPWM, Val);
}
else
{
digitalWrite(BDIR, LOW);
Val = 0x100-Val;
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(BPWM, ( Val));
}
At this point only 1 motor seems to function at a time. APWM is A9 and BPWM is A7 if that matters.
I know there is something simple I'm missing but currently at a loss as to why only one output works at a time.
Val = (constrain(msg->mtr_A, 0, 511)); // msg should be in range 0-512
if ( Val & 0x100) // is direction negative
{
bitClear(Val,8);
digitalWrite(ADIR, HIGH);
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(APWM, Val);
}
else
{
digitalWrite(ADIR, LOW);
Val = 0x100-Val;
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(APWM, (Val));
}
Val = (constrain(msg->mtr_B, 0, 511)); // msg should be in range 0-512
if ( Val & 0x100) // is direction negative
{
bitClear(Val,8);
digitalWrite(BDIR, HIGH);
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(BPWM, Val);
}
else
{
digitalWrite(BDIR, LOW);
Val = 0x100-Val;
if ( Val < DEADBAND)
{
Val = 0;
}
analogWrite(BPWM, ( Val));
}
At this point only 1 motor seems to function at a time. APWM is A9 and BPWM is A7 if that matters.
I know there is something simple I'm missing but currently at a loss as to why only one output works at a time.