ArduinoGeneral

Phase Locked Loop (PLL) Motor Control with Romeo

userHead dhs 2011-03-15 05:27:20 9973 Views7 Replies
Has anyone successfully controlled DC motors with PLL using Romeo? The wiki manual (http://www.dfrobot.com/wiki/index.php?title=DFRduino_Romeo-All_in_one_Controller_%28SKU:DFR0004%29) contains some sample code (section 7.4), but it only differs from PWM control by swapping the E1/E2 and M1/M2 pin assignments. When I use the PLL asignments, the motor is always full on or off (speed control does not appear to be possible). I'm using the 2010 Romeo (V1.0).

Ultimately, I'm trying to eliminate the annoying motor whine that comes from the default PWM frequency of 977 Hz, and I was hoping PLL control might be able to provide quiet speed control.
2021-12-29 23:48:57 On Romeo, the jumpers must be hardwired. Unplug the jumpers on the romeo's right top. And then I used the following link slope game. userHeadPic sarahroxon6
2011-04-02 12:06:35 To better tune the PWM, you need to adjust the timer of ARduino. As the default PWM output is 500hz in default. 

A higher PWM frequency will reduce the motor noise, and gives better performance.
userHeadPic R2D2C3PO
2011-03-17 14:01:44 Thanks, the new code seems to work fine, except I think a digitalWrite(E1/E2,LOW) is needed to stop the motors.  As far as I can tell, the negative speed range is from 127 to 0, and the positive speed range is from 128 to 255.

I can still hear the analogWrite() pulse frequency, but it appears that the motor speeds are linear with the PLL speed command, which is nice.
userHeadPic dhs
2011-03-16 15:12:23 Check out the following code:

[code]//Standard DLL Speed control

int E1 = 4;    //M1 Speed Control
int E2 = 7;    //M2 Speed Control
int M1 = 5;    //M1 Direction Control
int M2 = 6;    //M1 Direction Control

///For previous Romeo, please use these pins.
//int E1 = 6;    //M1 Speed Control
//int E2 = 9;    //M2 Speed Control
//int M1 = 7;    //M1 Direction Control
//int M2 = 8;    //M1 Direction Control

//When m1p/m2p is 127, it stops the motor
//when m1p/m2p is 255, it gives the maximum speed for one direction
//When m1p/m2p is 0, it gives the maximum speed for reverse direction

void DriveMotorP(byte m1p, byte m2p)//Drive Motor Power Mode
{
 
   
   
    digitalWrite(E1, HIGH);
  analogWrite(M1, (m1p));
       
  digitalWrite(E2, HIGH);
  analogWrite(M2, (m2p));
       

   
}

void setup(void)
{
    int i;
    for(i=6;i<=9;i++)
    pinMode(i, OUTPUT); 
    Serial.begin(19200);      //Set Baud Rate
}
void loop(void)
{
    char val = Serial.read();
    if(val!=-1)
      {
          switch(val)
          {
            case 'w'://Move Forward
                    DriveMotorP(0xff,0xff);
                    break;
            case 'x'://Move Backward
                    DriveMotorP(0x00,0x00);;
                    break;
            case 's'://Stop
                    DriveMotorP(0x7f,0x7f);
                    break;     
           
            }   
          delay(40);
      }
     
}[/code]
userHeadPic R2D2C3PO
2011-03-16 13:17:15 I tried connecting the 4 F/F jumpers as shown, but I am still not able to control the motor speed using the example code in the wiki manual.  In this configuration the motors only respond to analogWrite values >=128, and they are always full on.  I would expect the following code to only apply 1/2 power the motors, but it applies full power.

[code]
int E1 = 4;    //M1 Speed Control
int E2 = 7;    //M2 Speed Control
int M1 = 5;    //M1 Direction Control
int M2 = 6;    //M1 Direction Control

void setup(void) {
    for(int i=4;i<=7;i++)
    pinMode(i, OUTPUT);
    analogWrite (E1,128);
    digitalWrite(M1,HIGH);   
    analogWrite (E2,128);   
    digitalWrite(M2,HIGH);
}

void loop(void) {
}
[/code]
userHeadPic dhs
2011-03-15 21:29:22 Here is the jumper configuration.
[img]
userHeadPic R2D2C3PO
2011-03-15 18:25:41 Yes. You need hard wire the jumpers on Romeo.  Unplug the jumpers on the right top of the romeo. And applied the following connection. 4 F/F jumper cables are required.

userHeadPic R2D2C3PO