4

I'm trying to make a program in NXT 2.0 that mirrors the (manual) movements of one motor to another.

I managed to start motor B running in the right direction but I am having trouble controlling the number of degrees. I tried using the degree output of the sensor as input for the motor but it doesn't work: the B motor moves a bit but not the same amount of motor A.

enter image description here

So I tried with a loop instead: rotate motor B until its position is equal to motor A.

enter image description here

The second solution works slightly better but is still not precise.

Any suggestions?

6
  • i am not familiar with NXT programming, but is there no way to tell a motor to go to a specific position?
    – user253751
    May 10 at 10:19
  • @user253751 doesn't look like it's possible. I can only set the amount of degrees, rotations or time
    – algiogia
    May 10 at 11:31
  • position would be degrees? I don't know whether if you say degrees 90, it means rotate BY 90 degrees (from wherever it currently is), or rotate TO exactly 90 degrees (so it goes to the same place every time).
    – user253751
    May 10 at 11:59
  • @user253751 it (should) rotates of the given degrees from the current position
    – algiogia
    May 10 at 12:37
  • Maybe calculate the position of motor B minus the position of motor A, and move motor A that number of degrees?
    – user253751
    May 10 at 13:28

1 Answer 1

2

A good way to do this is to use a control algorithm with feedback to control the position of the second motor. You can research "PID" to learn how to make your own.

Or if you want an out-of-the-box experience, there is a PID block from HiTechnic available that does this. It can be downloaded from here (search for "PID"). There is also a YouTube video showing how the block works.

2
  • That's great! I didn't know you could program your own blocks. Is there a guide on how to create them?
    – algiogia
    May 13 at 11:39
  • This sounds like a great question that others might be interested in. So you should ask it as a new question rather than in the comments. :-) May 13 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.