Motor sensing blocks - efficiency, power and current

Mentor here. I’m trying to understand how to use some of the motor sensing blocks that I found in the Motor API section. I wrote MotorTest.v5blocks (50.6 KB) to spin a motor up and down so that I could watch the change in values of each sensor. The program increases the voltage up by 0.5 every half a second in one thread while another thread prints sensor values to the console.

The program output (below) has zeros for a number of loop iterations for efficiency, current and power in spite of the increasing voltage and RPMs. If I try to calculate the Watts going to the motor based on applied Volts and the reported Amps, the values don’t make sense.

Additionally, the block testing if the motor is spinning or not always reports false. In the console output you can see “Not spinning?” being printed inspite of the motor not being stopped.

Am I doing something wrong? Is this a limitation of the blocks API?

Logging started
0.005000:Volts=0.500000:RPM=0.000000:Vel=0.000000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
0.510000:Volts=1.000000:RPM=9.000000:Vel=4.500000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
1.015000:Volts=1.500000:RPM=17.400000:Vel=8.700000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
1.520000:Volts=2.000000:RPM=28.466668:Vel=14.233334:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
2.025000:Volts=2.500000:RPM=38.666668:Vel=19.333334:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
2.530000:Volts=3.000000:RPM=49.066668:Vel=24.533334:Nm=0.000000:Temp=40.000000:Amp=0.018000:W=0.000000:Eff=0.000000
3.035000:Volts=3.500000:RPM=59.133334:Vel=29.566668:Nm=0.000000:Temp=40.000000:Amp=0.027000:W=0.000000:Eff=0.000000
3.540000:Volts=4.000000:RPM=71.333337:Vel=35.666668:Nm=0.000000:Temp=40.000000:Amp=0.026000:W=0.000000:Eff=0.000000
4.045000:Volts=4.500000:RPM=81.266670:Vel=40.633335:Nm=0.000000:Temp=40.000000:Amp=0.036000:W=0.000000:Eff=0.000000
4.550000:Volts=5.000000:RPM=89.933338:Vel=44.966669:Nm=0.000000:Temp=40.000000:Amp=0.041000:W=0.000000:Eff=0.000000
5.055000:Volts=5.500000:RPM=98.733330:Vel=49.366665:Nm=0.000000:Temp=40.000000:Amp=0.045000:W=0.000000:Eff=0.000000
5.560000:Volts=6.000000:RPM=107.400000:Vel=53.700004:Nm=0.000000:Temp=40.000000:Amp=0.051000:W=0.000000:Eff=0.000000
6.065000:Volts=6.500000:RPM=122.133327:Vel=61.066666:Nm=0.000000:Temp=40.000000:Amp=0.057000:W=0.000000:Eff=0.000000
6.570000:Volts=7.000000:RPM=130.333328:Vel=65.166664:Nm=0.000000:Temp=40.000000:Amp=0.062000:W=0.000000:Eff=0.000000
7.075000:Volts=7.500000:RPM=139.600002:Vel=69.800005:Nm=0.000000:Temp=40.000000:Amp=0.066000:W=0.000000:Eff=0.000000
7.580000:Volts=8.000000:RPM=150.933323:Vel=75.466666:Nm=0.000000:Temp=40.000000:Amp=0.068000:W=0.000000:Eff=0.000000
8.085000:Volts=8.500000:RPM=158.733330:Vel=79.366670:Nm=0.000000:Temp=40.000000:Amp=0.066000:W=0.000000:Eff=0.000000
8.590000:Volts=9.000000:RPM=162.800002:Vel=81.400003:Nm=0.000000:Temp=40.000000:Amp=0.071000:W=0.000000:Eff=0.000000
9.095000:Volts=9.500000:RPM=177.199993:Vel=88.599997:Nm=0.000000:Temp=40.000000:Amp=0.071000:W=0.000000:Eff=0.000000
9.600000:Volts=10.000000:RPM=182.533340:Vel=91.266670:Nm=0.000000:Temp=40.000000:Amp=0.068000:W=0.000000:Eff=0.000000
10.105000:Volts=10.500001:RPM=186.733332:Vel=93.366671:Nm=0.000000:Temp=40.000000:Amp=0.065000:W=0.000000:Eff=0.000000
10.610000:Volts=11.000000:RPM=193.666668:Vel=96.833334:Nm=0.000000:Temp=40.000000:Amp=0.071000:W=0.000000:Eff=0.000000
11.115000:Volts=11.500000:RPM=200.666666:Vel=100.333333:Nm=0.000000:Temp=40.000000:Amp=0.075000:W=0.000000:Eff=0.000000
11.620001:Volts=12.000000:RPM=202.466655:Vel=101.233327:Nm=0.000000:Temp=40.000000:Amp=0.088000:W=0.000000:Eff=0.000000
12.125000:Volts=12.500000:RPM=210.666656:Vel=105.333328:Nm=0.000000:Temp=40.000000:Amp=0.086000:W=0.000000:Eff=0.000000
12.630000:Volts=12.500000:RPM=211.066651:Vel=105.533326:Nm=0.000000:Temp=40.000000:Amp=0.094000:W=0.000000:Eff=0.000000
13.135000:Volts=12.500000:RPM=207.800007:Vel=103.900003:Nm=0.000000:Temp=40.000000:Amp=0.082000:W=0.000000:Eff=0.000000
13.640001:Volts=12.500000:RPM=209.333324:Vel=104.666662:Nm=0.000000:Temp=40.000000:Amp=0.079000:W=0.000000:Eff=0.000000
Not spinning?
14.145001:Volts=11.500000:RPM=203.933334:Vel=101.966667:Nm=0.000000:Temp=40.000000:Amp=0.079000:W=0.000000:Eff=0.000000
14.650001:Volts=11.000000:RPM=202.533340:Vel=101.266670:Nm=0.000000:Temp=40.000000:Amp=0.070000:W=0.000000:Eff=0.000000
15.155000:Volts=10.500001:RPM=195.999994:Vel=98.000002:Nm=0.000000:Temp=40.000000:Amp=0.064000:W=0.000000:Eff=0.000000
15.660000:Volts=10.000000:RPM=198.399982:Vel=99.200001:Nm=0.000000:Temp=40.000000:Amp=0.062000:W=0.000000:Eff=0.000000
16.165001:Volts=9.500000:RPM=185.600004:Vel=92.800007:Nm=0.000000:Temp=40.000000:Amp=0.052000:W=0.000000:Eff=0.000000
16.670001:Volts=9.000000:RPM=179.666662:Vel=89.833336:Nm=0.000000:Temp=40.000000:Amp=0.062000:W=0.000000:Eff=0.000000
17.175000:Volts=8.500000:RPM=170.733333:Vel=85.366669:Nm=0.000000:Temp=40.000000:Amp=0.057000:W=0.000000:Eff=0.000000
17.680000:Volts=8.000000:RPM=161.333323:Vel=80.666666:Nm=0.000000:Temp=40.000000:Amp=0.060000:W=0.000000:Eff=0.000000
18.184999:Volts=7.500000:RPM=154.733334:Vel=77.366672:Nm=0.000000:Temp=40.000000:Amp=0.051000:W=0.000000:Eff=0.000000
18.690001:Volts=7.000000:RPM=150.466657:Vel=75.233331:Nm=0.000000:Temp=40.000000:Amp=0.062000:W=0.000000:Eff=0.000000
19.195000:Volts=6.500000:RPM=134.800005:Vel=67.400002:Nm=0.000000:Temp=40.000000:Amp=0.056000:W=0.000000:Eff=0.000000
19.700002:Volts=6.000000:RPM=131.266665:Vel=65.633330:Nm=0.000000:Temp=40.000000:Amp=0.046000:W=0.000000:Eff=0.000000
20.204999:Volts=5.500000:RPM=119.666660:Vel=59.833331:Nm=0.000000:Temp=40.000000:Amp=0.040000:W=0.000000:Eff=0.000000
20.709999:Volts=5.000000:RPM=104.799998:Vel=52.400002:Nm=0.000000:Temp=40.000000:Amp=0.046000:W=0.000000:Eff=0.000000
21.215000:Volts=4.500000:RPM=100.133324:Vel=50.066667:Nm=0.000000:Temp=40.000000:Amp=0.035000:W=0.000000:Eff=0.000000
21.719999:Volts=4.000000:RPM=90.666666:Vel=45.333333:Nm=0.000000:Temp=40.000000:Amp=0.027000:W=0.000000:Eff=0.000000
22.225001:Volts=3.500000:RPM=77.333336:Vel=38.666668:Nm=0.000000:Temp=40.000000:Amp=0.019000:W=0.000000:Eff=0.000000
22.730000:Volts=3.000000:RPM=68.199997:Vel=34.099998:Nm=0.000000:Temp=40.000000:Amp=0.021000:W=0.000000:Eff=0.000000
23.235002:Volts=2.500000:RPM=55.866666:Vel=27.933333:Nm=0.000000:Temp=40.000000:Amp=0.004000:W=0.000000:Eff=0.000000
23.740001:Volts=2.000000:RPM=49.000001:Vel=24.500000:Nm=0.000000:Temp=40.000000:Amp=0.013000:W=0.000000:Eff=0.000000
24.245002:Volts=1.500000:RPM=36.666667:Vel=18.333334:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
24.750001:Volts=1.000000:RPM=26.800001:Vel=13.400000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
25.255001:Volts=0.500000:RPM=15.866667:Vel=7.933333:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
25.760000:Volts=0.000000:RPM=9.200000:Vel=4.600000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
EndStop
Not spinning?
26.264999:Volts=0.500000:RPM=-3.466667:Vel=-1.733333:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
26.770000:Volts=1.000000:RPM=-9.666667:Vel=-4.833333:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
27.275000:Volts=1.500000:RPM=-20.066669:Vel=-10.033334:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
27.780001:Volts=2.000000:RPM=-30.400000:Vel=-15.200000:Nm=0.004326:Temp=40.000000:Amp=0.033000:W=0.013770:Eff=22.814796
28.285000:Volts=2.500000:RPM=-42.266669:Vel=-21.133335:Nm=0.013147:Temp=40.000000:Amp=0.060000:W=0.058178:Eff=40.775142
28.790002:Volts=3.000000:RPM=-53.066669:Vel=-26.533334:Nm=0.003025:Temp=40.000000:Amp=0.043000:W=0.016806:Eff=13.704237
29.295001:Volts=3.500000:RPM=-66.533332:Vel=-33.266666:Nm=0.012391:Temp=40.000000:Amp=0.071000:W=0.086316:Eff=35.946774
29.800000:Volts=4.000000:RPM=-71.933336:Vel=-35.966668:Nm=0.003968:Temp=40.000000:Amp=0.057000:W=0.029886:Eff=13.841624
30.305002:Volts=4.500000:RPM=-86.133337:Vel=-43.066669:Nm=0.008149:Temp=40.000000:Amp=0.074000:W=0.073487:Eff=22.672832
30.810001:Volts=5.000000:RPM=-94.333334:Vel=-47.166667:Nm=0.005340:Temp=40.000000:Amp=0.073000:W=0.052743:Eff=15.036534
31.315000:Volts=5.500000:RPM=-102.599990:Vel=-51.300001:Nm=0.009231:Temp=40.000000:Amp=0.088000:W=0.099167:Eff=21.298330
31.819999:Volts=6.000000:RPM=-113.066661:Vel=-56.533332:Nm=0.005526:Temp=40.000000:Amp=0.087000:W=0.065412:Eff=12.793210
32.325001:Volts=6.500000:RPM=-121.199989:Vel=-60.599999:Nm=0.000000:Temp=40.000000:Amp=0.079000:W=0.000000:Eff=0.000000
32.830002:Volts=7.000000:RPM=-131.933331:Vel=-65.966668:Nm=0.000000:Temp=40.000000:Amp=0.076000:W=0.000000:Eff=0.000000
33.334999:Volts=7.500000:RPM=-139.733338:Vel=-69.866672:Nm=0.000000:Temp=40.000000:Amp=0.089000:W=0.000000:Eff=0.000000
33.840001:Volts=8.000000:RPM=-145.666671:Vel=-72.833338:Nm=0.000000:Temp=40.000000:Amp=0.083000:W=0.000000:Eff=0.000000
34.345002:Volts=8.500000:RPM=-160.733328:Vel=-80.366669:Nm=0.000000:Temp=40.000000:Amp=0.083000:W=0.000000:Eff=0.000000
34.849999:Volts=9.000000:RPM=-167.733335:Vel=-83.866673:Nm=0.000000:Temp=40.000000:Amp=0.080000:W=0.000000:Eff=0.000000
35.355000:Volts=9.500000:RPM=-171.266661:Vel=-85.633335:Nm=0.000000:Temp=40.000000:Amp=0.087000:W=0.000000:Eff=0.000000
35.860002:Volts=10.000000:RPM=-179.333329:Vel=-89.666662:Nm=0.000000:Temp=40.000000:Amp=0.079000:W=0.000000:Eff=0.000000
36.365001:Volts=10.500001:RPM=-191.399994:Vel=-95.699997:Nm=0.000000:Temp=40.000000:Amp=0.086000:W=0.000000:Eff=0.000000
36.870000:Volts=11.000000:RPM=-194.799995:Vel=-97.400007:Nm=0.000000:Temp=40.000000:Amp=0.092000:W=0.000000:Eff=0.000000
37.375000:Volts=11.500000:RPM=-200.999999:Vel=-100.500000:Nm=0.000000:Temp=40.000000:Amp=0.098000:W=0.000000:Eff=0.000000
37.880001:Volts=12.000000:RPM=-206.200004:Vel=-103.100002:Nm=0.000000:Temp=40.000000:Amp=0.086000:W=0.000000:Eff=0.000000
38.384998:Volts=12.500000:RPM=-211.133337:Vel=-105.566669:Nm=0.000000:Temp=40.000000:Amp=0.092000:W=0.000000:Eff=0.000000
38.889999:Volts=12.500000:RPM=-210.933328:Vel=-105.466664:Nm=0.000000:Temp=40.000000:Amp=0.101000:W=0.000000:Eff=0.000000
39.395000:Volts=12.500000:RPM=-207.533336:Vel=-103.766668:Nm=0.000000:Temp=40.000000:Amp=0.088000:W=0.000000:Eff=0.000000
39.900002:Volts=12.500000:RPM=-213.933325:Vel=-106.966662:Nm=0.000000:Temp=40.000000:Amp=0.096000:W=0.000000:Eff=0.000000
Not spinning?
40.405002:Volts=11.500000:RPM=-206.066656:Vel=-103.033328:Nm=0.000000:Temp=40.000000:Amp=0.081000:W=0.000000:Eff=0.000000
40.910001:Volts=11.000000:RPM=-204.600000:Vel=-102.300000:Nm=0.000000:Temp=40.000000:Amp=0.072000:W=0.000000:Eff=0.000000
41.415000:Volts=10.500001:RPM=-197.933331:Vel=-98.966665:Nm=0.000000:Temp=40.000000:Amp=0.061000:W=0.000000:Eff=0.000000
41.919999:Volts=10.000000:RPM=-194.399986:Vel=-97.200003:Nm=0.000000:Temp=40.000000:Amp=0.072000:W=0.000000:Eff=0.000000
42.424998:Volts=9.500000:RPM=-190.866661:Vel=-95.433340:Nm=0.000000:Temp=40.000000:Amp=0.055000:W=0.000000:Eff=0.000000
42.930002:Volts=9.000000:RPM=-177.666664:Vel=-88.833342:Nm=0.000000:Temp=40.000000:Amp=0.050000:W=0.000000:Eff=0.000000
43.435001:Volts=8.500000:RPM=-168.799996:Vel=-84.400005:Nm=0.000000:Temp=40.000000:Amp=0.045000:W=0.000000:Eff=0.000000
43.940001:Volts=8.000000:RPM=-157.799997:Vel=-78.900003:Nm=0.000000:Temp=40.000000:Amp=0.052000:W=0.000000:Eff=0.000000
44.445000:Volts=7.500000:RPM=-147.466660:Vel=-73.733330:Nm=0.000000:Temp=40.000000:Amp=0.042000:W=0.000000:Eff=0.000000
44.950004:Volts=7.000000:RPM=-143.399992:Vel=-71.699996:Nm=0.000000:Temp=40.000000:Amp=0.041000:W=0.000000:Eff=0.000000
45.455003:Volts=6.500000:RPM=-130.733335:Vel=-65.366669:Nm=0.000000:Temp=40.000000:Amp=0.038000:W=0.000000:Eff=0.000000
45.960002:Volts=6.000000:RPM=-124.133325:Vel=-62.066665:Nm=0.000000:Temp=40.000000:Amp=0.039000:W=0.000000:Eff=0.000000
46.465001:Volts=5.500000:RPM=-112.133324:Vel=-56.066666:Nm=0.000000:Temp=40.000000:Amp=0.028000:W=0.000000:Eff=0.000000
46.970000:Volts=5.000000:RPM=-103.533328:Vel=-51.766667:Nm=0.000000:Temp=40.000000:Amp=0.027000:W=0.000000:Eff=0.000000
47.474999:Volts=4.500000:RPM=-93.800001:Vel=-46.900001:Nm=0.000000:Temp=40.000000:Amp=0.025000:W=0.000000:Eff=0.000000
47.979999:Volts=4.000000:RPM=-86.400003:Vel=-43.200002:Nm=0.000000:Temp=40.000000:Amp=0.025000:W=0.000000:Eff=0.000000
48.485003:Volts=3.500000:RPM=-74.933333:Vel=-37.466667:Nm=0.000000:Temp=40.000000:Amp=0.015000:W=0.000000:Eff=0.000000
48.990002:Volts=3.000000:RPM=-65.733333:Vel=-32.866666:Nm=0.000000:Temp=40.000000:Amp=0.016000:W=0.000000:Eff=0.000000
49.495001:Volts=2.500000:RPM=-53.733335:Vel=-26.866667:Nm=0.000000:Temp=40.000000:Amp=0.003000:W=0.000000:Eff=0.000000
50.000000:Volts=2.000000:RPM=-42.000003:Vel=-21.000001:Nm=0.000000:Temp=40.000000:Amp=0.003000:W=0.000000:Eff=0.000000
50.505004:Volts=1.500000:RPM=-31.800001:Vel=-15.900001:Nm=0.000000:Temp=40.000000:Amp=0.001000:W=0.000000:Eff=0.000000
51.009998:Volts=1.000000:RPM=-21.733334:Vel=-10.866667:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
51.515002:Volts=0.500000:RPM=-13.000001:Vel=-6.500000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
52.020001:Volts=0.000000:RPM=-7.800000:Vel=-3.900000:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
EndStop
Logging finished

Is spinning is only valid when using spinTo and spinFor blocks. If the motor is not under load then torque, output power and efficiency will be close to zero.

To calculate the wattage of the motor power that gets converted into usable mechanical work you would need to subtract back EMF from the voltage applied to the motor.

UsableMotorPower = MotorCurrent * (AppliedVoltage - MotorBackEMF) - ElectricalLosses - MechanicalLosses.

Where MotorBackEMF is proportional to the velocity of rotation of the motor, Torque generated by the motor is proportional to the Current, which is a function of the difference of the applied voltage and backEMF divided by the electrical resistance in the motor circuit.

Essentially, as you apply voltage to the motor it will generate max torque at rest and then its rotation velocity will increase and torque decrease until the point of equilibrium.

More related information here:

How to Increase the Speed Past 100% in VEXcode Pro V5 - #22 by technik3k

I’m going to be a little pedantic here. The documentation does not draw a link between “spinTo” or “spinFor” blocks/functions. Thanks for pointing that out.

Ok, a free spinning motor doesn’t have any resistance making the sensor values effectively unmeasurable. That makes sense, except that in the middle of the output (excerpt below) it has readings for torque, power and efficiency. What does that mean? Is that a glitch or an indication that there is something wrong with the motor?

27.275000:Volts=1.500000:RPM=-20.066669:Vel=-10.033334:Nm=0.000000:Temp=40.000000:Amp=0.000000:W=0.000000:Eff=0.000000
27.780001:Volts=2.000000:RPM=-30.400000:Vel=-15.200000:Nm=0.004326:Temp=40.000000:Amp=0.033000:W=0.013770:Eff=22.814796
28.285000:Volts=2.500000:RPM=-42.266669:Vel=-21.133335:Nm=0.013147:Temp=40.000000:Amp=0.060000:W=0.058178:Eff=40.775142

Thanks for the informative reply! The links to prior information were especially helpful. Both responses have been helpful in understanding the problem.