ev3dev / lms2012-compat

lms2012 VM compatibility layer for ev3dev
http://www.ev3dev.org
7 stars 4 forks source link

Motor speed inconsistency #57

Closed laurensvalk closed 7 years ago

laurensvalk commented 7 years ago

Motors run slower on lms2012-compat, see comment in screenshot:

A motor is commanded to run for 10 seconds at 10% speed, and the final amount of degrees is displayed on the screen. The results differ for lms2012-compat compared to standard firmware.

Test code: https://github.com/laurensvalk/lms2012-compat-demo --> speedtest

ev3dev1

laurensvalk commented 7 years ago

Same experiment with medium motor at 10%:

lms2012-compat: 1207 degrees after 10 seconds (20 rpm)
EV3           : 1687 degrees after 10 seconds (28 rpm)
rhempel commented 7 years ago

There is going to be some difference between lens and ev3dev drivers and the concept of % speed

laurensvalk commented 7 years ago

Sure, but that's not what's happening here :)

laurensvalk commented 7 years ago

For reference, these are conversion factors between the LEGO FW speed (%) values and rotations per minute (rpm).

They are different for the Large and Medium motor.

These values don't actually appear in the source code but they are found experimentally. (And equivalent lms2012-compat code would eventually result in the same values.)

ev3speed

dlech commented 7 years ago

FYI, the most important version numbers are the output uname -r and dpkg -s lms2012-compat | grep Version. It won't always be clear from the SD card image version what is actually being used. If you ever upgrade a package, the image version becomes meaningless.

laurensvalk commented 7 years ago

Ok, I'll report those too. For the issues reported so far, you may assume a clean image (with given image number) with no updates.

dlech commented 7 years ago

I think I have this close enough.

motor official firmware lms2012-compat
large 17.6 RPM 18.4 RPM
medium 28.3 RPM 27.3 RPM

It turns out that there were some bad assumptions on my part and some inconsistencies in the official firmware that were throwing off my math.

dlech commented 7 years ago

Thanks for the test programs. They were quite useful. I've attached an updated version that prints the calculated RPM on the screen at the end of the program. (just delete .zip from the file name)

lms2012test.ev3.zip

laurensvalk commented 7 years ago

Ok. I came across this when my existing programs performed visually differently (robot walked much more slowly) than with the official FW. I'll resume testing with your updates.

dlech commented 7 years ago

I'm going to leave this open so that I remember to leave a note when I do a kernel release with this fix.

dlech commented 7 years ago

FWIW, I have also verified that the unregulated motor block works as expected, meaning that the the same power in EV3-G results in the same duty cycle output on both the official firmware and lms2012-compat. 0 = 0% duty cycle, 1 = 20% duty cycle 100 = 100% duty cycle and everything else in between is scaled linearly. duty_cycle = (80 * power + 1900) / 99

laurensvalk commented 7 years ago

Wow, that's pretty crazy :+1:

laurensvalk commented 7 years ago

I'll be using that block extensively in my next test (next week), running this.

dlech commented 7 years ago

Fix has been released in kernel 4.9.4-ev3dev-bpo-stretch-r4-ev3-lms2012