VEX motor reflash rate

@jpearman and forum,

How fast the motor can be reflash? what is the minimum value I can choose for x that brain will accept.

for ( i =1 ; i<=12000;  i++) {
motor.spin(fwd,  i, mV)
wait (x, msec);
}
for ( i =1 ; i<=1200;  i++) {
motor.spin(fwd,  i, rps)
wait (x, msec);
}

I read somewhere that the motors updated at 100 Hz. So you would need to wait 10 msec.

4 Likes

Thank you so much.

How does voltage in vex::motor::spin(directionType dir, double voltage, voltageUnits units) be translated into speed and acceleration? It there formula for those?

Not to derail your questions, but I’m interested in why you want this? I try to use the rule of thumb from the beginnings that things (data values from sensors, commands to motors) got updated every 20ms, or 50 times a second. I’ve always considered this to be plenty of time. Even at a super fast 10’ per second you would get a number of readings / settings per foot. Thanks!

1 Like

I would like to have smooth acceleration and deceleration when moving forward. I try 10 msec and work quit well. Just want to learn what the limit is. Thank you for your input and discussion.

Commands to the motor are sent at 5ms intervals. This means that motor voltage can be updated at 200Hz. However, the motor’s internal PID loop runs in 10ms cycles, so there’s no point setting rpm more often than that. Also note that data from the motor (encoder position, etc.) is only received every 10ms.

8 Likes

So you have a test bed to try things out? You did 10ms, can you do 20…1000 by 20ms and report back the results? Its not often people can see science like this in action.

1 Like

Thank you for all the information. that is really helpful. If you have reference to those information that is greatly appreciate. Sometime it is just hard to find out there the information is located.

Certainly. I will report this later. I current try 1-D motion profile instead of PID, which requires a lot of tunning. drivetrain.driveFor did not work well when I try. It has overshot issue at high speed.

1 Like

The numbers @sazrocks quoted are correct, however, remember we are dealing with asynchronous processes here so none of this is absolute. That is, commands are sent to the motor as a reply to data it sends, the motor is nominally sending messages to the V5 every 5mS, so that is the maximum rate we can send reply command data back. Your user code has background processing happening, so when you delay for 5mS that happens most of the time but not always if the system needs to do other processing. When you change motor voltage that also has to be piped through from the processor the user code is running on to the processor handling communications, all of these things will add small delays, this is not designed as a hard real time system.

10 Likes

Here are some results of testing.

  • 4-motor drive train, green cartridge
  • gear with 36:60, (input:output)
  • same acceleration and deceleration rate,
  • test at 10, 20, 50 msec interval.

No difference observed. Smooth acceleration and deceleration. Stop at almost the same place with 3-4 replication of each time-interval.

two issues;
measured speed is different from expected speed. (see table below)
expect travel distance is significantly different from actual distance (calculated from measured speed). actual distance (calculated from measured speed) is close to the travel distance measured with measuring tape ( about 37 inches).

expected distance, where aspeed is expected speed,
tral = waittime/1000 * aspeed * M_PI * wheelDiameter / 360 * gearratio + tral ;

actual distance based on measured speed.
accutral = waittime/1000 * Drivetrain.velocity(dps) * M_PI * wheelDiameter / 360 * gearratio + accutral ;

Any suggestions?

acceleration step at 50 msec expected speed (dps) drivetrain speed measured (dps) left motor group speed right motor group speed expect distance (inch) actual distance
1 60 0 0 0 0.06 0
2 120 26 22.8 29.2 0.19 0.03
3 180 128.6 139.6 117.6 0.38 0.16
4 240 246.4 254.8 238 0.63 0.42
5 300 346.2 303.2 389.2 0.94 0.78
6 360 506 495.2 516.8 1.32 1.31
7 420 616.4 635.2 597.6 1.76 1.96
8 480 677.2 672.8 681.6 2.26 2.67
9 540 776.6 780.4 772.8 2.83 3.48
10 600 853.4 847.6 859.2 3.46 4.37
11 660 979.8 993.6 966 4.15 5.4
12 720 1075.4 1059.2 1091.6 4.9 6.53
13 780 1187.4 1184.8 1190 5.72 7.77
14 840 1197.6 1180 1215.2 6.6 9.02
15 900 1219.8 1200 1239.6 7.54 10.3
16 960 1208.2 1215.6 1200.8 8.55 11.57
17 1020 1212 1220.4 1203.6 9.61 12.84
18 1080 1174.4 1179.6 1169.2 10.74 14.07
19 1140 1183.2 1158 1208.4 11.94 15.3
20 1200 1201.4 1172.8 1230 13.19 16.56
deceleration
20 1200 1210.2 1214 1206.4 14.45 17.83
19 1140 1174.4 1180.4 1168.4 15.65 19.06
18 1080 1186.6 1182 1191.2 16.78 20.3
17 1020 1183 1166.8 1199.2 17.84 21.54
16 960 1219.8 1201.2 1238.4 18.85 22.82
15 900 1227.8 1225.2 1230.4 19.79 24.1
14 840 1192.4 1190 1194.8 20.67 25.35
13 780 1190.4 1154.8 1226 21.49 26.6
12 720 1176.4 1176 1176.8 22.24 27.83
11 660 1218 1218 1218 22.93 29.11
10 600 1155.8 1179.6 1132 23.56 30.32
9 540 1052 1085.2 1018.8 24.13 31.42
8 480 906.2 890.8 921.6 24.63 32.37
7 420 812.4 832.8 792 25.07 33.22
6 360 765 766.4 763.6 25.45 34.02
5 300 727.8 743.6 712 25.76 34.78
4 240 419.6 421.2 418 26.01 35.22
3 180 385 401.2 368.8 26.2 35.62
2 120 284.2 298.8 269.6 26.33 35.92
1 60 226.4 238.8 214 26.39 36.16
6 Likes

While we are talking about data and stuff here is a graph of my kinematics profiling.
Screen Shot 2022-02-21 at 10.36.11 PM

Now this works quite well. Now there is a decent delay between set velocity and the actual velocity.

Edit: and it would be nice for some on to explain how my motor is going over 600 rpm

5 Likes

Motors aren’t limited to their rated speed in voltage control mode. I managed to hit 2000 rpm on my TP flywheel with a 600 rpm motor and a 3:1 gear ratio (meaning the motor hit close to 670 rpm).

6 Likes

How dose voltage related to speed and torque? Are they linear or more complicated function? If I use voltage control drivetrain, I want to find out the speed thus the distance it travels. Thank you

Thank you for the interesting figure. I did the same to the table above. It seems that I did not get the motion profile I want. I may need to investigate why this happen.

Forum. any thoughts and suggestions?

1 Like

It seems like the primary difference is that mine has a constant velocity part. I can’t tell of yours has that at the peak.

1 Like

Thanks for the graph. You are not seeing the results you want because of inertia (at rest and in motion), friction , the way DC motors work and the way controllers work.

When you start off applying power, the motor controller is at the far end of it’s control band. So the initial increments will be slightly non-linear. There is initial friction to overcome in the motor and the drive train. DC motors need to have a level of voltage before there is enough magnetic attraction to move the rotor. You are up against inertia at rest. Once you get past that you see the robot move (and your graph shows that)

Once you get to where you want to go, you start to decrease and you now are fighting inertia of an object in motion. Without setting any brake action, the weight of the motor will continue to drive it. And again as power decreases the electromagnets get weaker and weaker.

Try your test again, but start out with an initial higher power level. Set the brake value on the motor to get the help from the motor to slow things down.

Edited to add the part about DC motors.

6 Likes