[SOLVED] Motor Speed Problem

BrickPi.MotorSpeed[PORT_A]=200;

like above, I can set up Motor speed.
But while brickpi changes motor speed I set up, real motor speed is not a 200m/s.
So How can I get a current Motor speed value??

do you have a BrickPi+ or BrickPi3?

BrickPi.MotorSpeed will not work for the BrickPi3. Since that command does do something we can safely assume it is not the BrickPi3.

@vlvl5 can you explain what you mean by 200m/s? When you set the motor speed you are adjusting the Pulse Width Modulation, PWM. This pulses the motors really fast to adjust its speed. In order to read the motorā€™s speed you would have to measure at different times how much the wheel turned. For example the wheel starts at 0 degrees and 0 seconds have gone by, then 1 second later the motor is at 360 degrees. That would mean the motor is turning at 1 rotation (360 degrees) per second. The BrickPi3 can do this automatically but the older BrickPiā€™s canā€™t, so youā€™ll have to code it.

I have brickpi+.

BrickPi.MotorSpeed[PORT_A] = 200

I thought 200 is motorā€™s speed. So I used ā€˜m/sā€™.

Ok. Well normally ā€œm/sā€ refers to meters per second.
Anyways you say the real motor speed is not 200, but Iā€™m a little confused as too how you even found that it wasnā€™t.

about MotorSpeed[PORT_A]: ā€œSpeedā€ is actually misleading, itā€™s about pwm, not speed.
edit:
At full pwm (100% = 255 for the BrickPi+) the motor rotates at about 100 degrees/100ms (no load).
If you apply 200pwm, that is 200/255 = 78%, which means 78% of the maximum rotation speed = 78 degrees/100ms - but tbh, that is just a rough estimation because pwm and rotation speed are not by a strict linear dependency.

2 Likes

I mean if I set up motor speed as certain value, the motor starts to rotate to reach that value.

I think motor does not reach that value as soon as I set up motor speed. So I said Itā€™s not motorā€™s real speed.

motor raise speed increasingly to reach that value. I want to know motor current speed

You can calculate current speed by reading the encoder, waiting, and reading the encoder again. You can use the difference between the two readings compared to the time between readings to calculate speed. For example, if the first reading is 180 degrees, and 100ms later the reading is 220 degrees, the speed would be 400 degrees per second ((220[second reading]-180[first reading]) * (1[one second]/0.1[100ms between readings])) == 400[degrees per second motor speed].

This topic was automatically closed after 2 days. New replies are no longer allowed.