Speed values for EVShield with medium EV3 motors are not proportional
 Arduino   Started by Matthew Pham   2016-05-12 09:01:24 -04:00   Comments: 8    Viewed: 771

  1. Matthew Pham
    Matthew Pham Member
    Hi,

    I am having an issue with setting speed values for the EVShield, as the speed is not proportional.

    I am using:
    • An EVShield which was purchased 7th December 2015
    • 3 medium EV3 motors
    • A Zippy Flightmax 1800mAh 9.9V 5C LifePo TX battery pack
    I have created some code for testing the motors which compares the time it takes for one motor to run 10 rotations, at speeds ranging from 5 to 40.

    Below I have pasted the results of my tests, for each speed setting that I have tested.

    As you can see, the rotations per second, at a speed set to 5 seems very quick, as it results in more than half the RPM compared with a speed of 40.


    Total RotationsMotor SpeedMotor Time (milliseconds)Rotation Time (milliseconds)Rotations per second
    1053341334.12.99
    10103088308.83.24
    10152835283.53.53
    10202633263.33.80
    10252481248.14.03
    10302329232.94.29
    10352329232.94.29
    10402227222.74.49

    Below are a couple of lines that I'm using in my code:

    evshield.bank_a.motorRunRotations(SH_Motor_2, SH_Direction_Forward, 5, 10, SH_Completion_Wait_For, SH_Next_Action_BrakeHold);

    evshield.bank_a.motorRunRotations(SH_Motor_2, SH_Direction_Forward, 40, 10, SH_Completion_Wait_For, SH_Next_Action_BrakeHold);


    I'm using millis() to keep track of the time it takes for each instruction to complete.

    I am confused as this behaviour appears very different to what occurs when I set speed values from 1 to 100 using RobotC and an EV3 brick.

    Has anyone else encountered a similar issue? Is there something I need to configure so that the EVShield recognises that it is connected to medium motors rather than large motors?
    Matthew Pham, 2016-05-12 09:01:24 -04:00
  2. Andrew Page
    Andrew Page Member

    In most programming enviroments I have used Speed is the %of Time power is applied to the port.  Under light load, there will not be much difference between values.

    Did you have a load applied or just a free moter?

    I do not see in either the PiStorms or Arduino code where the units of speed are specified.

    Andrew Page, 2016-05-12 10:27:59 -04:00
  3. Matthew Pham
    Matthew Pham Member
    Thanks for your quick response Andrew.

    I have tested using both a light load and just using a free motor, with similar findings. The table I posted earlier was with a free motor.

    The idea of speed being % of time power applied to the port makes sense, but it seems strange to me that the RPM is that high for a setting of 5. The difference between 0 and 5, is very high compared to the difference between 5 and 10, so it doesn't seem like it could be % of time power, since the RPM should basically double with a setting of 10, right?.

    The Arduino code that I have found on the mindsensors website is here:

    https://github.com/mindsensors/EVShield/blob/master/EVShield.h

    I have copied the section for the motorRunRotations function which I am using in my code. The comments specify that it is between 0 and 100, but I can't find any other information which would specify units of speed.

    The other strange finding is that it reaches close to a maximum speed at a setting of 50.

    /**
      Run the motor for a set number of complete rotations and proceed to the next action
      @param which_motors specifiy the motor(s) to operate on
      @param direction specifiy the direction to run the motor
      @param speed the speed value (between 0 and 100)
      @param rotations The rotations the motor should rotate through
      @param wait_for_completion whether this API should wait for competion or not
      @param next_action for these motor being operated on
      @return 0 if the operation was finished satisfactorily,
      in case return value is non-zero you should check for the bits for error conditions.
      */
     uint8_t motorRunRotations(SH_Motor which_motors, SH_Direction direction,
     int speed, long rotations,
     SH_Completion_Wait wait_for_completion,
     SH_Next_Action next_action);
    Matthew Pham, 2016-05-13 00:34:52 -04:00
  4. Matthew Pham
    Matthew Pham Member
    Hi again,

    If it helps, I have also tried writing values directly to the IC2 registers, using the code below. Setting a speed of 1 is definitely rotating the motors much faster than expected. I don't think there is anything else I can do with the code to make the wheels spin slower, but if anyone has any suggestions, that would be much appreciated. Would a firmware update be required and maybe address the issue?



    uint8_t ctrl = SH_CONTROL_SPEED | SH_CONTROL_GO;

    evshield.bank_b._i2c_buffer[0] = (uint8_t)(int8_t) 1; // write a speed of 1 directly to the I2C register
    evshield.bank_b._i2c_buffer[1] = 0; // duration (set to 0 since I'm using SH_CONTROL_GO command and no time related controls)
    evshield.bank_b._i2c_buffer[2] = 0; // command register B
    evshield.bank_b._i2c_buffer[3] = ctrl; // command register A

    uint8_t reg = SH_SPEED_M1;
    evshield.bank_b.writeRegisters(reg, 4);
    Matthew Pham, 2016-05-16 01:51:35 -04:00
  5. Nitin Patil
    Nitin Patil Member Staff Member
    Hello Matthew,
    We are working on  this issue.
    Hopefully we will come up some resolution in couple of days.

    Nitin Patil, 2016-05-18 12:05:18 -04:00
  6. Matthew Pham
    Matthew Pham Member
    Hi Nitin,

    Is there any update on this issue?

    The only workaround solution we have identified at the moment is to use a lower voltage battery of 7.4V, which results in slowing down the overall speed of the motors. 

    However, the issue of the speed being highly disproportionate is still there.
    Matthew Pham, 2016-06-01 01:50:53 -04:00
  7. Gary Miller
    Gary Miller Member
    Hello all,

    I'm running into a similar issue with a Power Function motor running on the PiStorms. I have a Blockly program that ramps through speeds from 0 to 100 by 1 and the motor only spins slower at the 1%. I hooked up a multimeter to see the volatage levels assuming th motor speed is adjsuted via PWM but found that the volatage was 9.3v through the entire range. I modified the program and if I ramp from 0 to 10 by .05 I found the voltage was -3.9 from 0 to 1 and then ramped down to -9.3v by a speed setting of 1.6. I cannot reproduce these voltage levels however if I set the speed to 1 or any other value. The voltage goes to -9.3v. Do the lego EV3 motors us encoder feedback for the speed? Thank you.
    Gary Miller, 2016-12-29 18:57:06 -05:00
  8. @Gary Miller: A question for you. How do you connect the Power Function motor to the PiStorms? Do you use some custom cable or adaptor? Or are you using mindsensors PF mate?

    thanks!

    jordi


    Jordi FARAUDO, 2017-03-08 09:34:49 -05:00
  9. (You must log in or sign up to post here)

Log in | Sign up
Tems & Conditions!
Help!