DC motor problem

I am trying to gradually change the speed of the motor. However, sometimes as the motor speed is increasing the motor reaches a point where it doesnt further increase speed and just starts pulsing. Sometimes this is at full speed and other times at half speed. I have no idea why it does this. So i tried throwing in a delay command but still nothing. Also, i have tried it without the delay command and i still get the same pulsing. the motor controller im using is the polou smco2b. It supports the 127 speeds.Please help. thanks a lot.

/*
 * SMC05A Pololu Dual Serial Motor Controller
 * Jeremy Bridon <jbridon@psu.edu>
 * Anthony Cascone <acascone@psu.edu>
 */
 
/*** Includes ***/
 
#include <SoftwareSerial.h>
#include "math.h"
 
/*** Definitions ***/
 
#define rxPin 6    // Defines the "recieve" pin for software serial to motor controller
#define txPin 7    // Defines the "transmit" pin for software serial to motor controller
#define resetPin 8 // Defines the reset pin for the motor controller
 
// Create a special SoftwareSerial for direction communications with the motor controller
SoftwareSerial motorSerial = SoftwareSerial(rxPin, txPin);
 int i=0;
/*** Sample Setup Usage ***/
 
void setup()
{
      // Set the baud rate of standard serial
      Serial.begin(9600);
 
      // Initialize the motor controller
      InitMotor();
}
 
void loop()
{

  while(i<126)
  {
    delay(75);
        SetMotor(0,i);
i=i+1;  
}     

}
 
// Public: Initialize the motor controller and unique serial communications
void InitMotor()
{
      // Setup Pins for I/O
      
      pinMode(txPin, OUTPUT);            // Serial Transmit Pin
      pinMode(resetPin, OUTPUT);      // Motor Reset Pin
 
      // Set the baud rate of software serial
      motorSerial.begin(9600);

 
    // Reset the motor controller (By setting low then high signals to the resetPin)
        digitalWrite(resetPin, HIGH);      
      delay(10);
        digitalWrite(resetPin, LOW);
      delay(10);
      digitalWrite(resetPin, HIGH);
      delay(10);
}
 

// Public: Set a speed (0 to 127) and direction (boolean) to a motor
void SetMotor(int motorIndex, int speed)
{
      // Create the packet buffer
      unsigned char buffer[4];
 
      // Start byte and device ID byte
      buffer[0] = 0x80;
      buffer[1] = 0x00;
 
      // Set motor index
      unsigned char index = 0;

 
      // Motor number and direction

            buffer[2] = 0x00 | index;

 
      // Motor speed
      unsigned char targetSpeed = speed;

      buffer[3] = targetSpeed;
 
      // Send the packet
      SendPacket(buffer, 4);
}
 
// Private: Send a packet through the custom serial motorSerial
void SendPacket(unsigned char *buffer, int bufferCount)
{
      for(int i = 0; i < bufferCount; i++)
            motorSerial.print(buffer[i], BYTE);
}

From what I can gather:-
In your loop() the value of i constantly goes up. There needs to be something to stop it when it reaches the limit. What I think is happening is that it is overflowing and constantly doing the same ramp bit. That's why it appears to pulse.