Thursday, September 8, 2011

Task 20a - Motor spinning at different rates using digital PWM: software & video

This version of Task-20 is slightly different, in that the motor speeds up, then slows down again, speeds up, slows down..

The variation in software is shown below:

void loop()                    
{
  for (int j=100; j>=0; j--)        // slowly decrease mark-space ratio, increasing speed
  {
    Serial.print("Mark-space ratio is 4 - ");
    Serial.println(j);
    RotateMotor(1,0,1,j);        // rotate motor Right @ set speed..
  }//for()  
 
    for (int j=0; j<=100; j++)   // slowly increase mark-space ratio, decreasing speed
  {
    Serial.print("Mark-space ratio is 4 - ");
    Serial.println(j);
    RotateMotor(1,0,1,j);       // rotate motor Right @ set speed..
  }//for()
}//end loop()


2 comments:

  1. i've got an improved version of the variable-speed software which uses a 'kick-start' routine & a 'run' routine.
    The 'kick-start' is in the setup() part & the 'run' is in the loop().
    i'll post it later..

    ReplyDelete
  2. i've found something else:
    you can use an Analog pin with a built-in PWM function (~470Hz)

    i've been using PWM on the ENable pin on the DC-MINI board, but the 'truth-table' lists the EN as STOP when @ logic '0'.

    maybe this is why the slower motion is so jerky?

    ReplyDelete