Mbot Ranger's on board encoder motors (PID, moveTo)


#1

Hello :slight_smile:

I am new to Makeblock’s product and I have several issues with the one I have. I would like to control my mBot Ranger using the moveTo(position/angle, speed) on Arduino in order to keep track of its position. The mBot Ranger I have uses a Me Auriga and two 180 Optical encoder motors.

The first problem is that the robot is not moving in straight line. Do you know how I could correct this ?

The second issue is the setting of PID. How do I set the right values for PID in setPosPid() ? Do I also need to use the setSpeedPid() or is the setPosPid() sufficient? I am not sure but is the setSpeedPid() for the function runSpeed() and the setPosPid() for moveTo() ? I saw some examples and wrote the following section :

 Encoder_1.setPulse(9);
 Encoder_2.setPulse(9);
 Encoder_1.setRatio(39.6);
 Encoder_2.setRatio(39.6);
 Encoder_1.setPosPid(0.18,0,0);
 Encoder_2.setPosPid(0.18,0,0);
 Encoder_1.setSpeedPid(0.18,0,0);
 Encoder_2.setSpeedPid(0.18,0,0);
 Encoder_1.runSpeed(0);
 Encoder_2.runSpeed(0); 
 Encoder_1.setMotionMode(PID_MODE);
 Encoder_2.setMotionMode(PID_MODE);

I would like to specify that I am not using the Makeblock software but Arduino’s.

The third issue is about the moveTo() function. The speed should be less than the maximum speed written on the encoder motor’s datasheet, i.e 178 rpm, right? For example, when I type moveTo(360,100), is the speed equal to 100 rpm or 100/255 * 178 = 69.8 rpm ? I am confused because I read many other topics.

Finally, for the rotation…

//Forward/Backward
   Encoder_1.moveTo(-pos,vel);
   Encoder_2.moveTo(pos,vel);
//Rotation
   Encoder_1.moveTo(pos,vel);
   Encoder_2.moveTo(pos,vel);

Could you please guide me ? It is quite urgent …

Thanks in advance,

Shanika


#2

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.