Answers.Body: <p>I found a solution: I multiplied the master motor's value by -1. So, the calculation was: (a-b) it changed to : (-a-b). The result was passed to the slave motor and it did the job.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T20:00:45.537Z
Answers.Text: If you want the blocks, feel free to ask.
Answers.UserDisplayName: bio512
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T19:59:24.757Z
Answers.LastActivityDate: 2015-05-21T19:59:24.757Z
Answers.UserDisplayName: bio512
Answers.Body: <p>I think the main problem is, that you use the "Motor on for # degrees". The program will wait until this command is executed (i.e. the required turn is made), and this can take quite long. The next measurement of the angle difference is taken after that. Having a high start deviation and/or fast turning rates of your reference motor, you will not get a stable result.
  Instead I propose to use the angle difference for the "Power" input of the "Motor on" command. In that scenario the angle difference is measured very often, and the "slave" motor is following your "master" motor very pecisely.
  <img src="https://i.sstatic.net/9KmMS.jpg" alt="Motor Sync"> </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-17T16:28:12.853Z
Answers.Text: Thanks for the reply, appreciate it. Won't be able to test it until next Wednesday, only then I can give my feedback. One thing, the 'slave' motor, in my project, is desired to move in 180 degrees, does the 'On' mode treat that aspect?
Answers.UserDisplayName: bio512
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-17T20:22:50.090Z
Answers.Text: I want it to move by the given degree and then stop. The ev3 help says: "The motor will run until it is stopped or changed by another block".
Answers.UserDisplayName: bio512
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T13:01:25.030Z
Answers.Text: Since the angle difference is the "power" input of the slave motor, it will only move untill the difference is zero. So it will follow exactly your "master" motor. If that master stays within 180°, the slave will, too. And don't worry about the timing, one loop cycle in above program takes only ~1ms. So the deviation is checked and corrected ~1000 times per sec.
Answers.UserDisplayName: alexs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T19:56:54.573Z
Answers.Text: I tested the code and unfortunately it didn't help.
Answers.UserDisplayName: bio512
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-15T08:59:53.850Z
Answers.LastActivityDate: 2015-05-15T08:59:53.850Z
Answers.UserDisplayName: alexs
Body: <p>I've designed a robot with two motors. It works as follows:</p>
  
  <p>The first motor is attached to the the person's arm, the second motor receives the calculated movement and moves accordingly.</p>
  
  <p>When the person moves his hand (open/close) the other robot moves the the opposite direction; upon opening it closes and vise-versa.</p>
  
  <p>I've tried to invert the movement by multiplying by -1 but the second motor keeps moving on his own. I've tried multiplying the results of both motors, before subtracting, with no success.</p>
  
  <p>The <a href="https://i.sstatic.net/ebils.png" rel="nofollow noreferrer">'code'</a> does the following:</p>
  
  <ol>
  <li>I take the movements of motors A and B </li>
  <li>Subtract value of motor A from motor B's</li>
  <li>Save the result to a variable-'moveDist'</li>
  <li>Take the absolute value after subtraction for comparison</li>
  <li>If greater than 6, pass 'moveDist' value to the second motor.</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/ebils.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ebils.png" alt="Current code implementation - click for larger"></a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-13T17:22:13.653Z
Comments.Text: Sorry, don't know how to post my code, here's a link: http://i.imgur.com/OR2uAMP.png
  Also I have a video demonstrating what happens to the hand after the multiplication(If you wanna see).
Comments.UserDisplayName: bio512
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-13T18:29:39.297Z
Comments.Text: I'm not at all well-versed in the spaghetticode that comes from LEGO's EV3 software, but conceptually, isn't the "take the absolute value" part unnecessary and even wrong? Shouldn't you be moving B the difference between A and B so that B' = B+ (A-B) = A ?
Comments.UserDisplayName: Phil B.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-14T10:23:43.827Z
Comments.Text: That's why I used the variable 'moveDist', to save the B' value. The absolute value is used for comparison (A threshold), if I don't do so, the hand will keep on shaking.
Comments.UserDisplayName: bio512
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-14T11:27:20.367Z
Comments.Text: Ok I see that now - couple of more things: You need to clarify what the issue is: is it that movements seem to be mirrored but passing -1 * MoveDist does not seem to reverse the movement? or is it that `but the second motor keeps moving on his own.` - i.e. motor B keeps making movements even if motor A does not register any movement (or movements below your '6' threshold)?
Comments.UserDisplayName: Phil B.
Tags: <ev3><motor>
Title: Inverting motor's rotation
UserDisplayName: bio512
ThreadText: # Inverting motor's rotation
  
  (Asked by: username_0 on 2015-05-13)
  
  I've designed a robot with two motors. It works as follows:
  
  The first motor is attached to the the person's arm, the second motor receives the calculated movement and moves accordingly.
  
  When the person moves his hand (open/close) the other robot moves the the opposite direction; upon opening it closes and vise-versa.
  
  I've tried to invert the movement by multiplying by -1 but the second motor keeps moving on his own. I've tried multiplying the results of both motors, before subtracting, with no success.
  
  The ['code'](https://i.sstatic.net/ebils.png) does the following:
  
  1. I take the movements of motors A and B
  2. Subtract value of motor A from motor B's
  3. Save the result to a variable-'moveDist'
  4. Take the absolute value after subtraction for comparison
  5. If greater than 6, pass 'moveDist' value to the second motor.
  
  [![Current code implementation - click for larger](https://i.sstatic.net/ebils.png)](https://i.sstatic.net/ebils.png)
  
  **Tags:** ev3, motor
  > **Comments:**
  > **username_0**: Sorry, don't know how to post my code, here's a link: http://i.imgur.com/OR2uAMP.png Also I have a video demonstrating what happens to the hand after the multiplication(If you wanna see).  
  > **username_1**: I'm not at all well-versed in the spaghetticode that comes from LEGO's EV3 software, but conceptually, isn't the "take the absolute value" part unnecessary and even wrong? Shouldn't you be moving B the difference between A and B so that B' = B+ (A-B) = A ?  
  > **username_0**: That's why I used the variable 'moveDist', to save the B' value. The absolute value is used for comparison (A threshold), if I don't do so, the hand will keep on shaking.  
  > **username_1**: Ok I see that now - couple of more things: You need to clarify what the issue is: is it that movements seem to be mirrored but passing -1 * MoveDist does not seem to reverse the movement? or is it that `but the second motor keeps moving on his own.` - i.e. motor B keeps making movements even if motor A does not register any movement (or movements below your '6' threshold)?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-05-21. Score: 0 | Accepted answer
  
  I found a solution: I multiplied the master motor's value by -1. So, the calculation was: (a-b) it changed to : (-a-b). The result was passed to the slave motor and it did the job.
  
  > **Comments:**
  > **username_0**: If you want the blocks, feel free to ask.  
  
  ---
  
  ### Answer by username_2 on 2015-05-15. Score: 0
  
  I think the main problem is, that you use the "Motor on for # degrees". The program will wait until this command is executed (i.e. the required turn is made), and this can take quite long. The next measurement of the angle difference is taken after that. Having a high start deviation and/or fast turning rates of your reference motor, you will not get a stable result.
  Instead I propose to use the angle difference for the "Power" input of the "Motor on" command. In that scenario the angle difference is measured very often, and the "slave" motor is following your "master" motor very pecisely.
  ![Motor Sync](https://i.sstatic.net/9KmMS.jpg)
  
  > **Comments:**
  > **username_0**: Thanks for the reply, appreciate it. Won't be able to test it until next Wednesday, only then I can give my feedback. One thing, the 'slave' motor, in my project, is desired to move in 180 degrees, does the 'On' mode treat that aspect?  
  > **username_0**: I want it to move by the given degree and then stop. The ev3 help says: "The motor will run until it is stopped or changed by another block".  
  > **username_2**: Since the angle difference is the "power" input of the slave motor, it will only move untill the difference is zero. So it will follow exactly your "master" motor. If that master stays within 180°, the slave will, too. And don't worry about the timing, one loop cycle in above program takes only ~1ms. So the deviation is checked and corrected ~1000 times per sec.  
  > **username_0**: I tested the code and unfortunately it didn't help.  
  
  ---
  
  